#include <LiquidCrystal_I2C.h> ;// Library for LCD
#include <DHT.h>;
#define DHTPIN 10
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
float hum;
float temp;
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
// put your setup code here, to run once:
lcd.init(); //initialize the lcd
lcd.backlight(); //open the backlight
Serial.begin(9600);
dht.begin();
}
void loop() {
hum = dht.readHumidity();
temp= dht.readTemperature();
// put your main code here, to run repeatedly:
int chk = temp;
lcd.clear(); // clear display
lcd.setCursor(0, 0); // move cursor to (0, 0)
lcd.print("Temperature=");
lcd.print(temp);
Serial.println(temp);
// print message at (0, 0)
lcd.setCursor(0, 1); // move cursor to (2, 1)
lcd.print("Humidity= ");
lcd.print(hum); // print message at (2, 1)
Serial.println(hum);
delay(2000); // display the above for two seconds
}