Ideation
This Week's assignment
Circuits wth Arduino UNO
"More Complexity"
This week's assignment is to Design and program a smart device that performs a certain function or solves a problem: program Arduino UNO to read signals from multiple input components (Sensor, Switch, or variable resistor) to control multiple action components (Motor, Buzzer, LED...etc) using Arduino C (Text Code).
Attaching LDR sensor "input) wth LCD (output) & DHT11 (input) sensor wth buzzer (output).
so
*I Pick up first the input component for the Project and then I decided on the suitable outputs.
*The moment that I achieve the project requirements " I felt reassured when I finished the connections and the code, and everything worked correctly.
* I attached the LDR sensor "input) wth LCD (output) & DHT11 (input) sensor wth buzzer (output).
*Finally I thought that it'll be perfect as a smart home features ^^. 🤯🤯
Tool Chain "Software * Materials * Machines "
Software
Arduino IDE
Electronics Components
LDR sensor
LCD
DHT11
Buzzer
Arduino UNO
Jumpers
Breadboard
Arduino IDE software
LDR
Breadboard
DHT11
Arduino UNO
Buzzer
LCD
Input Component
DHT11 sensor
LDR sensor
Action Component
Buzzer starts to beep depending on Temperature and/or Humidity statements.
LCD gives me the LDR sensor reading
"Dark/DIM/Bright/Very Bright"
depending on the light mood in the room.
Arduino IDE
Using Arduino IDE software for coding " C (Text Code)"
Power Source
Arduino USB Cable .
This is Just a simulation of my circuit "graphical tool"
to represent it;
Cause there is no LDR sensor Or DHT11 in Tinker CAD
I used my hand drawing as a graphical illustration
Circuits On breadboard wth Arduino
Arduino
Breadboard
I supply the breadboard with GND & VCC from Arduino.
LDR sensor …. I connect
A0 = A0 on Arduino.
GND = GND on breadboard.
VCC = VCC on breadboard.
DHT11 sensor connection
GND = GND on breadboard.
DAT = Pin 2 on Arduino.
VCC = VCC on breadboard.
Buzzer connection
GND = GND on breadboard.
VCC = Pin 3 on Arduino.
LCD connection
GND = GND on breadboard.
VCC = VCC on breadboard.
SDA = I2C data on Arduino.
SCL = I2C clock on Arduino.
file:///C:/Users/Jeasy-Othman/Desktop/LCD&LDR_DHT&Buz.html
Arduino Code *.ino
file:///E:/Maker%20Diploma/DHT_LDR_LCD_Buzzer_arduino/LDR_LCD_DHT11_Buzz.htm
Coding
LDR sensor reading shows in LCD
LDR sensor sense the Intensity of illumination then shows this on LCD
Dark /DIM / Bright / Very Bright
DHT11 sensor reading reflect on a buzzer
DHT11 sensor when it detects Temperature reading "23ْ " or Humidity "70" the buzzer makes a sound .
our code divided to 3 sections
- Header:
includes all the global variables and importing needed libraries
setup function
initializing the different pins and output/input components
-loop function : do the main job as below
readHumidity()
readTemperature()
if (failed to read Humidity or Temperature) the display error message and stop
else
write the Temperature and Humidity values to the LCD
if the Humidity >70 or Temperature>23
start buzzer 1 second
if the light degree of illumination (>=0 & <5 ) then write to LCD "Dark"
else if the degree of illumination (>5 & <=14 ) then lcd.print("DIM")
else if degree of illumination (>14 & <=50 ) then lcd.print("BRIGHT")
else if > 50 then lcd.print(" Very BRIGHT"
///
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
int Buzzer = 3;
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd (0x27 , 16,2);
float RLDR;
float Vout;
void setup() {
Serial.begin(9600);
dht.begin();
pinMode (Buzzer , OUTPUT);
pinMode(A0, INPUT);
lcd.begin(16, 2);
lcd.backlight();
lcd.setCursor(4, 0);
}
void loop()
{
int sensorValue = analogRead(A0);
Vout = (sensorValue * 0.0048828125);
RLDR = (10000.0 * (5 - Vout))/Vout;
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("LIGHT : ");
//DHT_Buzzer//
delay (1000);
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t) ) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.print(F("°C "));
//LDR_LCD//
delay(100);
lcd.setCursor(0, 1);
if (((RLDR/500) >= 0) && ((RLDR/500) <= 5))
{
lcd.print("DARK");
}
else if (((RLDR/500) > 5) && ((RLDR/500) <= 14))
{
lcd.print("DIM");
}
else if (((RLDR/500) > 14) && ((RLDR/500) <= 50))
{
lcd.print("BRIGHT");
}
else
{
lcd.print("VERY BRIGHT");
}
delay(50);
//DHT with Buzzer Code //
if (t > 23 || h > 70) {
digitalWrite (Buzzer, HIGH);
delay (1000);
digitalWrite (Buzzer, LOW);
}
else {
digitalWrite (Buzzer, LOW);
}
}
MY LEGO enclosure "SMART Home"
“Self-Monitoring, Analysis, and Reporting Technology”
LCD is like a T.V Screen for lightning tracking.
I built a Home with LEGO to represent my SMART Home project.
LDR, DHT11 sensors on the left room wall ^^.
Overcoming Ghallenge
The component I found on Tinker CAD
The hand drawing diagram.
There are no DHT, or LDR sensors on Tinker CAD so
I had to search for another Program or Website like Fritzing …
Then I get the Idea
That I can draw My OWN one "why not :)"
Another Challenges that I have overcome them الحمد لله, Honestly I don't realize till now how I do that بفضل الله
How to Connect the LCD with the LDR sensor to read his environmental reading
I searched for all the projects on all the platforms that use the same component (LCD with LDR sensor + Arduino).
it wasn't easy at all to get that so,
I had to take my need from each project till it works.
I had to change some syntax on Code to fit my LCD Module.
I had to Coding Separately to check will it work or not, take notes in this Google D to save the right code.
https://docs.google.com/document/d/1gqQbXRYrhuRWcIYt7u-ewlNLbuILrGEaan50WsImFxs/edit?usp=share_link
Some resources links غيض من فيض الحقيقة
https://www.elec-cafe.com/dht11-temperature-and-humidity-with-lcd-display/
https://arduinogetstarted.com/tutorials/arduino-temperature-humidity-sensor-lcd
https://www.instructables.com/Arduino-TempHumidity-Sensor-Using-DHT11-and-I2C-LC/
https://www.robotique.tech/robotics/measuring-temperature-with-dht11-sensor-and-arduino/
https://iotprojectsideas.com/interface-dht11-sensor-with-arduino-and-lcd/
https://www.instructables.com/Arduino-Two-7-LED-Segments-DHT11-temperature-humid/ I was trying to use 7 Segment instead of LCD.
https://howtomechatronics.com/tutorials/arduino/lcd-tutorial/
https://docs.arduino.cc/learn/electronics/lcd-displays
https://www.circuitbasics.com/how-to-set-up-the-dht11-humidity-sensor-on-an-arduino/
Another Challenges that I have overcome them الحمد لله, Honestly I don't realize till now how I do that بفضل الله
I change it to that 👆🏻
cause our LCD module has 4 Pins not 16
On Void Loop
I put the LCD&LDR code under the DHT11&Buzzer code, it doesn't work till I Put it above.
Buzzer beep
I checked the Tempreture&Humidity on Serial monitor first then I changed the if situation code to fit the current Tempreture&Humidity.
Implementing Some of SMART Homes Features
Pairing with 2 beautiful Ladies ^^
This Week I'm able to بفضل الله ^^
Understand Arduino Code structure and write Arduino C code syntax correctly
Create and Use Variables to store and manipulate different types of data in Arduino C
Use Looping (For) for repeating actions in Arduino C
Create and use Functions in Arduino C
Switching between Manual Mode and Automatic Mode for the electronic components.