#include <DHT.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 16, 2);
#define relay 12
#define relay2 19
DHT dht(13, DHT22);
float temperature ;
float humidity;
void setup() {
Serial.begin(9600);
lcd.init();
lcd.backlight();
pinMode(relay, OUTPUT);
pinMode(relay2, OUTPUT);
}
void loop() {
temperature = dht.readTemperature();
humidity = dht.readHumidity();
Serial.print("Temperatue:\t"+String(temperature)+ "C");
lcd.setCursor(0, 0);
lcd.print("Temp : ");
lcd.print(temperature);
lcd.print(" C");
Serial.println("Humidity: \t"+String(humidity)+ "%");
lcd.setCursor(0, 1);
lcd.print("Humi : ");
lcd.print(humidity);
lcd.print(" %");
delay(1000);
if(temperature >= 50){
digitalWrite(relay, HIGH);
} else if (temperature <= 45) {
digitalWrite(relay, LOW);
}
if(humidity <= 30){
digitalWrite(relay2, HIGH);
}else if (humidity >= 60) {
digitalWrite(relay2, LOW);
}
}