#include <LiquidCrystal_I2C.h>
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT22
LiquidCrystal_I2C lcd (0x27, 16, 2); // I2C address 0x3F, 16 column and 2 rows
DHT dht (DHTPIN, DHTTYPE);
void setup() {
dht.begin(); // initialize the sensor
lcd.init(); // initialize the lcd
lcd.backlight(); // open the backlight
}
void loop() {
delay(2000); // wait for 2 seconds between measurements
float humi = dht.readHumidity(); // read humidity
float tempC = dht.readTemperature(); // read temperature
lcd.clear(); // clear the screen
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(tempC);
lcd.print((char)223); // print degree symbol
lcd.print("C");
lcd.setCursor(0, 1);
lcd.print("Humi: ");
lcd.print(humi);
lcd.print("%");
}