ZenoModiff
Published © LGPL

Home Automaton with LDR And DHT22 Sensor Along With Arduino

Home Automation With Temperature & Light Intensity

IntermediateFull instructions provided2,711
Home Automaton with LDR And DHT22 Sensor Along With Arduino

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
I2C 16x2 Arduino LCD Display Module
DFRobot I2C 16x2 Arduino LCD Display Module
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1
Aaware 2 Channel Relay Module
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Schematics

Schematics

Circuit Diagram For The Project

Code

Arduino Code

C/C++
Home Automation Arduino Code
/*feel free to contact
 * sreeramaj53@gmail.com
 * www.youtube.com/ZenoModiff
 * last updated - time 11:51am - date 12 may 2021
 */

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include "DHT.h"
#define DHTPIN 4
#define DHTTYPE DHT11

int Light = 11 ;
int Fan = 12 ;
const int ldrPin = 3;
LiquidCrystal_I2C lcd(0x27, 16, 2);
DHT dht(DHTPIN, DHTTYPE);

void setup()
{
 
  Serial.begin(9600);
  Serial.println(F("Home - Automation With DHT22 - LDR "));
  
  dht.begin();

  lcd.begin();
  lcd.setCursor(0,0);
  lcd.print("Home");
  lcd.setCursor(0,3);
  lcd.print("Automation");
  delay(2000);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("With");
  lcd.setCursor(0,3);
  lcd.print("LDR - DHT22");
  delay(2000);
  lcd.clear();
  lcd.print("By");
  lcd.setCursor(0,3);
  lcd.print("Zeno Modiff");
  delay (3000);
  lcd.clear();
  
  pinMode(Light , OUTPUT);
  pinMode(Fan , OUTPUT);
  pinMode(ldrPin , INPUT);
  
}

void loop()
{
  
 float t = dht.readTemperature();
 float f = dht.readTemperature(true);
 
 if (isnan(t) || isnan(f)) {
 Serial.println(F("Failed to read from DHT sensor!"));
 return;
}

 Serial.print("DHT-Temp: ");Serial.print(t);Serial.println(" c");
  
int Ldr_Status = digitalRead(ldrPin);  
if (Ldr_Status > 0)

{

digitalWrite(Light, LOW);

Serial.print("Its DARK, Turn on the LED : ");
lcd.clear();
lcd.print("Light Turned ON");
lcd.setCursor(0,3);
lcd.print("Temp: ");
lcd.setCursor(6,7);
lcd.println(t);
delay(1000);

Serial.println(Ldr_Status);

}
else 
{

digitalWrite(Light, HIGH);

Serial.print("Its DARK, Turn on the LED : ");

lcd.clear();
lcd.print("Light Turned OFF");
lcd.setCursor(0,3);
lcd.print("Temp: ");
lcd.setCursor(6,7);
lcd.println(t);
delay(2000);

Serial.print("Its BRIGHT, Turn off the LED : ");

Serial.println(Ldr_Status);

}
 if(t>34){          
    digitalWrite(Fan, LOW);   
    lcd.clear();
    lcd.print("Fan Turned ON");
    delay(2000);
   
    
  }
  else 
  digitalWrite(Fan , HIGH);
      lcd.clear();
      lcd.print("Fan Turned OFF");
      delay(1000);
}

Credits

ZenoModiff
17 projects • 10 followers
Contact

Comments

Please log in or sign up to comment.