// LCD1602 to Arduino Uno connection example
#include <LiquidCrystal.h>
#include <DHT.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
//Constants
#define DHTPIN 2 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE);
//Variables
int chk;
float hum; //Stores humidity value
float temp; //Stores temperature value
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
dht.begin();
lcd.clear();
}
void loop() {
// put your main code here, to run repeatedly:
delay(2000);
lcd.clear();
//Read data and store it to variables hum and temp
hum = dht.readHumidity();
temp= dht.readTemperature();
//Print temp and humidity values to serial monitor
Serial.print("Humidity: ");
Serial.print(hum);
Serial.print(" %, Temp: ");
Serial.print(temp);
Serial.println(" Celsius");
lcd.setCursor(0,0);
lcd.print("Humidity: ");
lcd.print(hum);
lcd.setCursor(1,0);
lcd.print("Temperature; ");
lcd.print(temp);
}