#include <DHT.h>; // Library for DHT sensor
#include <LiquidCrystal_I2C.h> // Library for LCD display
// Constants
#define DHTPIN 2 // Pin connected to the DHT sensor
#define DHTTYPE DHT22 // Type of DHT sensor (DHT22)
DHT dht(DHTPIN, DHTTYPE); //// Initialise DHT sensor for normal 16mhz Arduino
LiquidCrystal_I2C lcd(0x27,16,2); // Initialise LCD display
// Variables
int chk;
float hum; //Stores humidity value
float temp; //Stores temperature value
void setup()
{
dht.begin(); // Initialise DHT sensor
lcd.init(); // Initialise LCD display
lcd.backlight(); // Turn on LCD backlight
}
void loop()
{
delay(2000); // Delay for stability
//Read data and store it to variables hum and temp
hum = dht.readHumidity(); // Read humidity value
temp= dht.readTemperature(); // Read temperature value
lcd.setCursor(0,0); // Set cursor to first line of LCD
//Print temp and humidity values to serial monitor
lcd.print("Humidity: ");
lcd.print(hum);
lcd.print(" % ");
lcd.setCursor(0,1); // Set cursor to second line of LCD
lcd.print(" Temp: ");
lcd.print(temp);
lcd.println(" Celsius"); // Print temperature in Celsius
delay(10000); // Delay 10 seconds
}