Week 7
Temperature & Humidity monitor
Temperature & Humidity monitor
This week we are assigned to Build and Program a smart circuit using Arduino UNO which reads a signal from at least two input components (Sensor, Switch, or variable resistor) to control at least two action components (Motor, Buzzer, LED...etc) using Coding on Arduino IDE.
So i decided to make a Temperature/Humidity monitor using DHT11 sensor and an LCD to show on, so these are the first two input and output.
So i thought that this device needs control, somehow i had an idea to use a potentiometer to let the LCD show only the temp. on a page with an RGB LED with red colore, and then when we move the potentiometer to the other side it shows the Humidity on the LCD on another page the the RGB becomes blue.
So let's see how can we made this.👀🌟
220 ohm Resistors
DHT11
(temp/humidity sensor)
Potentiometer
RGB LED
Breadboard
5V Adapter
Arduino UNO with arduino caple
Jumper Wires
Gluegun and glue sticks
Scissors
Cardboard
First when you open tinkercad press on Designs and then choose Circuit to start design the circuit and simulate it before connecting it in reality.
Now from the basic componenets on the right side choose the componenets we're going to use :
1- Breadboard 2- RGB LED 3- Temperature sensor 4- LCD 12C 5- Two resistors of 22o ohm
6- Arduino UNO 7- Potentiometer
Now lets see the wiring pprocess of the circuit:
1- First take two wires (Red one) from the 5V of the arduino to the (+Ve) of the breadboard and (Black one) from the GND to the (-Ve) of the breadboard.
2- Connect the RGB LED with two resistors of 220 ohm in series with the (RED) & (BLUE) colores on the breadboard, then connect them to the (2) & (3) Digital pins on Arduino.
3- Connect the cathode of the RGB to the (-Ve) on the breadboard.
4- Then connect the Temperature sensor the ground to (-Ve) and the VCC to the (+Ve) on the breadboard, and then the middle pin to Digital pin (4) in Arduino.
5- Connect the potentiometer one terminal to the (-Ve) and the other terminal to the (+Ve) on the breadboard, then the middle pin (wiper) to Analog pin (A0) in Arduino.
6- Connect the LCD as following: (VCC ==> +Ve ) , (GND ==> -Ve) , (SDA ==> A4) , (SCL ==> A5)
(1)
First i included the DHT11 library,
then i defined DHT pin on (4) and i defined its type (DHT11)
then i included the LCD 12C library
and i added two integers for the two pins of (Red&Blue) of the RGB on pin 2&3
also one integer to the analog pin of the potentiometer on A0
(2)
Now in the void setup i added dht.begin to start the sensor
then the lcd.init to initialise the LCD and the lcd.backlight to turn on the backlight of the LCD.
also i added the pinmode of every output (Red&Blue of RGB) and input (potentiometer)
(3)
Now make the voide loop,
start by making the LCD clear , and then say
if (A0>512) when we switch on The left half of the potentiometer
then make the RGB Red colore HIGH (turn it ON) , and the RGB Blue colore LOW (turn it OFF)
and then write on the LCD "Temp=(the sensor read)" "Celesius"
then wait for 2000ms in a clear LCD
(4)
Complete the voide loop,
if (A0<512) when we switch on The second half of the potentiometer
then make the RGB Red colore LOW (turn it OFF) , and the RGB Blue colore HIGH (turn it ON)
and then write on the LCD "Humidity=(the sensor read)" "%"
then wait for 2000ms in a clear LCD
In the physical wiring i connected the DHT11 sensor the same way i wired the temp. sensor on tinkercad.
I uploaded the code on Arduino to test it before i make the enclosure.
As you can see the enclosure is very simple and easy, i just made a box with user interface including places for the LCD, the DHT, the potentiometer and the RGB led, then i fixed them with the tabe and then used the gluegun to close the rest of the box sides.
(Before)
The LCD was blinking.
(After)
The LCD stopped blinking.
So i found out that the delay in the code and the clear LCD wasn't supposed to be in the code, so it can do the function i wanted it to do, i Deleted the delays and the LCD clear and uploaded the code again.