Air Conditioning
This week assignment is an Air Conditioning interact like the Fan/Air Conditioner in our home.
The hot September days are what inspired me to this idea. In addition to traveling and moving a lot these days, I was aware of the value of having such an air conditioner considering the high temperature.
The idea flashed in my mind one night while traveling, and fortunately I was with some friends in the diploma, and I proposed the idea to them, and they liked it. We tried to think more about the possibility of implementing this until I decided to implement the idea with the materials available to me and using an enclosure of cardboard that contains the conditioner. The main objective of the assignment this week is to program an Arduino UNO to read signals from multiple input components. So, I will have two resulting actions and that's what I tried to get through this assignment. I will explain how this can be implemented next, what challenges I faced and how much time and effort it took to finish and get to a happy ending. Stay informed!
Enclosure
I used the following gadgets/components to design and simulate the circuit:
· Jumper & Crocodile Wires
· Large Breadboard
· Dc Fan
· Two LEDs (Red & White colors)
· Two Resistances (220 ohm)
· On/Off Switch
· 9V Adapter
Relay module 5V
Arduino UNO with USB Cable
LCD Screen
TinkerCad Software
DHT11 Sensor
Arduino IDE
Selector Switch
And to build the enclosure for the components I used:
Cardboard
Glue Gun
pencil
Scissors
I went through mainly steps that include the following:
Prepared the required components/tools which I will be using as I mentioned previously.
Installed the LiquidCrystal and DHT11 sensor libraries from the Manage Libraries tool as shown in the following pics.
Selecting Manage Libraries bar
Install LiquidCrystal
Pick it up now from Examples
Install DHT Sensor Binary
Pick it up now from Examples!
Next, I started writing the text code using the ARDUINO IDE app in parallel starting to connect the wires and components on the breadboard using the Arduino UNO board.
I used jumper wire to connect the DC fan to the 5v relay module and a 9v adapter, then the relay module to the Arduino Uno to terminate the connections for this phase at pin 4 on the Arduino UNO board.
Also, I made connections for two LEDs and a 220 ohm resistors and started connecting them to pin 8 and 9 on the Arduino UNO board.
The selector switch, the DHT11 sensor and the on/off switch are now left waiting to be connected, so I started connecting them, the selector switch to pin 2, the DHT11 sensor to pin 5 and the on/off switch to pin 3 on the Arduino Uno board. Let's not miss that all wires must be attached to the breadboard as well considering the positive and negative terminals.
Now it remains the LCD, so I hooked it up to the connections which are used for the two jumper wires on the positive and negative of the breadboard and the other two to connect A5 and A4 on the Arduino board.
I used a crocodile wires with on/off switch and a male - female wires with DHT11 sensor to make connections longer for cardboard enclosure space. Keep amazed!
Wiring behind the scenes
Now, it's time to write the code as follows:
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
#define DHTPIN 5 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11 // DHT 11
DHT_Unified dht(DHTPIN, DHTTYPE);
uint32_t delayMS;
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
int Selector = 2;
int Switch = 3;
int relay = 4;
int LEDRed = 8;
int LEDWhite = 9;
void setup()
{
pinMode (relay, OUTPUT);
pinMode (Switch, INPUT_PULLUP);
pinMode (Selector, INPUT);
pinMode (LEDRed, OUTPUT);
pinMode (LEDWhite, OUTPUT);
Serial.begin(9600);
// Initialize device.
dht.begin();
Serial.println(F("DHTxx Unified Sensor Example"));
// Print temperature sensor details.
sensor_t sensor;
dht.temperature().getSensor(&sensor);
Serial.println(F("------------------------------------"));
Serial.println(F("Temperature Sensor"));
Serial.print (F("Sensor Type: ")); Serial.println(sensor.name);
Serial.print (F("Driver Ver: ")); Serial.println(sensor.version);
Serial.print (F("Unique ID: ")); Serial.println(sensor.sensor_id);
Serial.print (F("Max Value: ")); Serial.print(sensor.max_value); Serial.println(F("°C"));
Serial.print (F("Min Value: ")); Serial.print(sensor.min_value); Serial.println(F("°C"));
Serial.print (F("Resolution: ")); Serial.print(sensor.resolution); Serial.println(F("°C"));
Serial.println(F("------------------------------------"));
// Print humidity sensor details.
dht.humidity().getSensor(&sensor);
Serial.println(F("Humidity Sensor"));
Serial.print (F("Sensor Type: ")); Serial.println(sensor.name);
Serial.print (F("Driver Ver: ")); Serial.println(sensor.version);
Serial.print (F("Unique ID: ")); Serial.println(sensor.sensor_id);
Serial.print (F("Max Value: ")); Serial.print(sensor.max_value); Serial.println(F("%"));
Serial.print (F("Min Value: ")); Serial.print(sensor.min_value); Serial.println(F("%"));
Serial.print (F("Resolution: ")); Serial.print(sensor.resolution); Serial.println(F("%"));
Serial.println(F("------------------------------------"));
// Set delay between sensor readings based on sensor details.
delayMS = sensor.min_delay / 1000;
lcd.init();
lcd.backlight();
}
void loop()
{
delay(delayMS);
sensors_event_t event;
dht.temperature().getEvent(&event);
if (isnan(event.temperature)) {
Serial.println(F("Error reading temperature!"));
}
else {
Serial.print(F("Temperature: "));
Serial.print(event.temperature);
Serial.println(F("°C"));
}
dht.humidity().getEvent(&event);
if (isnan(event.relative_humidity)) {
Serial.println(F("Error reading humidity!"));
}
else {
Serial.print(F("Humidity: "));
Serial.print(event.relative_humidity);
Serial.println(F("%"));
}
if (digitalRead (Selector) == LOW)
{
if (digitalRead (Switch) == HIGH)
{
lcd.setCursor(1, 0);
lcd.print("Manual Mode");
lcd.setCursor(3, 1);
lcd.print("Active Fan");
digitalWrite (relay, HIGH);
digitalWrite (LEDRed, HIGH);
digitalWrite (LEDWhite, LOW);
Serial.println("Active fan");
}
else
{
lcd.setCursor(1, 0);
lcd.print("Manual Mode");
lcd.setCursor(2, 1);
lcd.print("Disactive Fan");
digitalWrite (relay, LOW);
digitalWrite (LEDRed, LOW);
digitalWrite (LEDWhite, LOW);
Serial.println("Disactive Fan");
}
}
else {
if (event.temperature > 30) // read event.temperature
{
lcd.setCursor(0, 0);
lcd.print("Automatic Mode");
lcd.setCursor(2, 1);
lcd.print("The fan is on");
lcd.setCursor(2, 0);
Serial.println("The fan is turned on");
digitalWrite(relay, HIGH); // turn on
digitalWrite (LEDRed, LOW);
digitalWrite (LEDWhite, HIGH);
}
else {
digitalWrite(relay, LOW); // turn off
digitalWrite (LEDRed, LOW);
digitalWrite (LEDWhite, LOW);
Serial.println("The fan is Off");
lcd.setCursor(0, 0);
lcd.print("Automatic Mode");
lcd.setCursor(2, 1);
lcd.print("The fan is off");
lcd.setCursor(2, 0);
}
}
}
Programing Text Code
I defined the Selector and on/off switch as, inputs while the last components like LEDs and relay module was intergerned as output/action components and outputs and programmed the DHT sensor and LiquidCrystal_I2C by downloading their libraries as mentioned previously.
The forward text code of the assignment says there are two modes for manual and automatic mode,
In manual mode, the fan is supposed to turn on and off manually by clicking the switch if selector in manual mode.
In automatic mode, the fan is programmed to turn on/off according to the temperature measured in the room using the DHT11 sensor, so if the room temperature is below 30 degrees, the fan will be turned off otherwise the fan will run. There is also a LCD screen which show a text with state of the fan at all her states as follow:
"Manual mode
Active fan"
and in case of auto mode it shows next:
"Auto mode
the fan is turned on"
i programmed the text letters according to row & column of the screen as follows:
lcd.setCursor(0, 0);
lcd.print("Automatic Mode");
lcd.setCursor(2, 1);
lcd.print("The fan is on");
lcd.setCursor(2, 0);
In the following demo video, it will be more clear explaining what the text code is saying. Stay amazed!
Automatic Mode
(White LED is turned on)
Manual Mode "Switch on"
(Red LED is turned on)
Wiring in TinkerCad
Circuit with the TEXT CODE
First of all I have to admit it wasn't easy at all to put all the wires plugged with the components inside the enclosure, but I finally got it and checked all the connections over and over to make sure nothing bad happened while I was trying to run and simulate the desired function of the air conditioning.
Now, to get the function of air conditioning, I had to go through some steps as follows:
Gave the circuit ingredients and wires connections like a home from the cardboard.
Uploaded the TEXT CODE from the Arduino IDE app to the Arduino Uno board using a USB cable.
Tested the manual mode by turning the switch on and off the selector switch. The action was to turn on the fan and by turning off the switch, the fan is turned off.
Tested the automatic mode by turning on the selector switch. Hence, according to the temperature measurement via the DHT11 sensor, if it is above 30 degrees, the fan must be on, otherwise the fan is off.
Serial monitor on the Arduino IDE was my helpful guide at this stage showing me the measured humidity and temperature readings upon which the automatic's condition was based.
Finally had a happy ending and it worked as planned, yes!
In the next auto mode animation video the yellow DC fan motor was shown because the Dc fan is suddenly became not working, so I had to use an alternative for the DC fan only, while everything works in the text code as programmed as the LCD writes in time A text message indicates the fan is on/off and there is a white LED inside the enclosure emitting light in the fan's working mode and vice versa. I should not forget to mention that according to the DHT11 sensor in the video it measures the temperature and humidity and takes action based on it and this is the function of the auto mode.
Automatic Mode Animation
Enclosure
Demo of the Assignment
I presented the idea of air-conditioning to some of my colleagues and I was thinking of making two states of manual operation with an on/off switch and automatic via a remote control and according to the room temperature using the DHT11 sensor.
They recommend using an LM298 module to power the fan, but I've found it might be good enough to use a 5V relay module that will be enough to power the fan. They encouraged me to go ahead and implement this idea.
I got stuck at various stages like when I wanted to set the auto mode according to the temperature generated by the DHT 11 sensor, so I called for help and thanks to the amazing diploma manager for his patience and time we were able to troubleshoot.
Also, I stumbled and took a lot of time and effort searching on Google and did a lot of trials with the "Keypad Challenge" as a remote control but unfortunately I couldn't make it. It may be because I didn't have a good enough level to be more knowledgeable about how to do different functions with the keypad and to program the required text code.
The idea for the remote control was that I could turn the fan on/off without having to make it manually each time.
The method was when I press a custom number on the keypad like "number 1", the fan should turn on if the switch was off or the fan would turn off if the switch was on. Then, if the pressed number is "zero", it takes me back to the zero state where I started.
Getting to know how to make a smart device that has 2 inputs and produces 2 actions/outputs using a selector switch, I guess this will be a great useful gadget in my final project when I switch the interactive lamp from manual to auto with selector switch!
Back in the early 1940s, when the Operational Amplifier (Op Amp) was invented, the use at this time was for two main purposes; The first was to amplify the output/audio and the second was to perform a filtering of the output jam. Now, in our session, I used it for another purpose, using two inputs to get one output keeping in mind not to depend on the Arduino UNO. The inputs were a potentiometer and temperature sensor labeled LM 35 while the output was emitting light using two LEDs.
It's like a condenser in a refrigerator so at a low temperature it turns on and turns off if the air is cold enough. Are you Starting to visualize it now? Good, keep going!
First I started connecting the components to the breadboard and the Arduino Uno board using the following components/tools:
Breadboard
jumper Wires
Two LEDs & Two resistances (220 ohm)
Super Solder Wire
DHT11 Sensor
Operational Amplifier (Op Amp)
soldering iron
soldering board
LM35 Temperature Sensor
Potentiometer 5K
Resistance 10 ohm
The next step was to try to test the connections as shown in the demo video, the LED should turn on at the same time as the second LED when it's off. Of course, according to the use of the potentiometer direction/output value, if the value is higher than the temperature (LM 35 sensor value) or vice versa, the LED will light up or not.
The expected next step was to rebuild the same circuit including the same connections but using a soldering iron and super soldering wire to attach the components to the new soldering board I had.
I enjoyed doing this work as it was a new experience to get familiar with and gain, so I am very thankful to the helpful instructors in the session especially Sherif and Amani who are the same instructors for my diploma group as well, so What a nice coincidence, yeah!
I followed this link Folder - Google Drive to finish my prototype, so I recommend following it to anyone interested in doing the same project idea. Good luck!
Session Progress
Demo of Changing LEDs using Potentiometer
LED Toggling Riddle!
This exercise basically relies on 4 LEDs to switch ON and then OFF sequentially in one direction from right to left (the first LED will turn on, then turn off at the same moment the second LED is on, then turn off at the same time the moment That the third LED is on … and so on).
Whenever I press the pushbutton, the illumination order of the 4 LEDs will be reversed in the direction. Also, turning the potentiometer knob changes the speed of switching LEDs; either faster or slower
The components used were as follows:
1 Arduino UNO
4 LEDs
1 Push Button
1 Potentiometer
1 Breadboard
Jumper wires
TEXT CODE
Wires and Circuit
Display Simulation
Smart Home Challenge
Smart Home Challenge is simply a way to interact with a human who lives in a house and used to come into his room to do something like read a book or something else. So, the idea is that when he entered the room through a door (the DC motor in our case), he would flash a lamp to light up the room. What I did in this smart home project is a simulation of what a human does but I relied on two modes which are hands mode and automatic mode.
First of all,, I decided to use some of the ingredients that do the required purpose like:
Jumper & Crocodile wires
A bulb
Arduino Uno board
LDR Sensor
5V relay module
push buttons
9v adapter
And other such as the next pics ..
LM298 module
5V DC Motor
Selector Switch
Microwave Sensor
LDR Sensor
Actually, it seems that it is easy to do it but honestly it was not easy to implement at all .. we have many connections and also a TEXT CODE but it was finally done after many attempts, let's see how it worked …
It was implemented as follows:
Integrated wiring for manual mode using essential components such as pushbuttons, DC motor, bulb and 5V relay module.
Next, I tested the mode by pressing one pushbutton to turn on the lamp and pressing another pushbutton to turn on the DC motor. So, after some struggle with code and wiring, I've been able to succeed with this level so far.
Now, the time to try the auto mode, so i completed the required text code and attached a LDR sensor, selector switch to covert from manual mode to auto one and of course a microwave sensor to sense the motion and deliver the output to the LDR sensor, hence if there a light in the room ambiance, the bulb will not be blinked, otherwise it will be blinked.
For both modes I used the LM298 module because I need to power the DC motor and the 5v from the Arduino wouldn't be enough to power the whole circuit. Also, I used a 9v adapter and connected it to a 5v relay module to power the bulb i have.
Manual Mode
Selector Mode
Manual Mode "TEXT CODE"
Automatic Mode "TEXT CODE"
Lock System
The idea of the lock system is to make connections via wires and using a servo motor (180) and a keypad to simulate the process of opening a safe protected with a secret number.
The idea of the lock system is to make connections via wires and use a servomotor (180) and a keypad to simulate the process of opening a safe protected by a password.
I started plugging in the components on a mini breadboard using the Arduino Uno board and a text code by the Arduino IDE app to have the function of entering/pressing custom numbers as passcode to access the protected safe like when I press 1234# the lock must be unlocked (the servo motor will take action at a 90 degree angle) with a little tone from the puzzer, otherwise if the number doesn't have At least one number/symbol of the password. The puzzer (piezo) will emit a huge beep that acts as an emergency alarm. Meanwhile, the servo motor is supposed to take no action as shown in the next video.
Safe Protected TEXT CODE
Demo of Lock System Exercise
LED Fading Simulation
LED Fading
The main idea of LED fade is to make the LED using an Arduino Uno board and a breadboard reach its highest light-emitting point (at 255) and gradually return to the zero state in the next second and so on.
Then I found that I could control the LED light by typing the numbers chosen in the range 0 to 255 where 255 is the max. value and 0 is the lowest. Thus, any numbers assigned between them can radiate light with a certain amount of illumination.
LED Fading TEXT CODE