#include <LiquidCrystal.h>
#include <DHT.h> //include the DHT library
#define DHTTYPE DHT11 // define dhttype as dht11
#define DHTPIN 4 // Name dhtPin as pin 7
// initialize the LCD library with the numbers of the interface pins
LiquidCrystal lcd(12, 14, 5, 18, 19, 21);
DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor
void setup () {
dht.begin();
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("DHT11");
lcd.setCursor(0, 1);
lcd.print("Humidity/Temp.");
}
void loop() {
delay(1000);
float H = dht.readHumidity(); //Read Humidity
float T = dht.readTemperature(); // Read temperature as Celsius
// Check if any reads failed and if exit
if (isnan(H) || isnan(T)) {
lcd.print("Failed to read from DHT sensor!");
return;
}
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Humidity:");
lcd.print(H);
lcd.print("%");
lcd.setCursor(0, 1);
lcd.print("Temp.:");
lcd.print(T);
lcd.print((char)223);
lcd.print("C");
}