#include <LiquidCrystal.h>
#include <DHT.h>
LiquidCrystal lcd(18, 5, 17, 16, 4, 0);
const int dhtPin = 14;
DHT dht(dhtPin, DHT22);
void setup() {
dht.begin();
lcd.begin(20, 4);
lcd.print("DHT Example");
delay(1000);
}
void loop() {
// Wait a few seconds between measurements.
delay(2000);
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Humidity: " + String(h) + "%");
lcd.setCursor(0,1);
lcd.print("Temp: " + String(t) + (char)223 + "C"); //(char)223 = degree symbol
lcd.setCursor(0,2);
lcd.print("Temp: " + String(f) + (char)223 + "F");
}