//LiquidCrystal displays (LCDs)
#include <LiquidCrystal.h>
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT22
#define CELSIUS_DEGREES
DHT dht(DHTPIN, DHTTYPE);
int rs = 12;
int enable=11;
int d4=10;
int d5=9;
int d6=8;
int d7=13;
LiquidCrystal lcd(rs,enable,d4,d5,d6,d7);
void setup() {
Serial.begin(9600);
dht.begin();
delay(1000);
//lcd.begin(cols, rows)
lcd.begin(16,2);
}
void loop() {
// put your main code here, to run repeatedly:
// put your main code here, to run repeatedly:
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
//by setting the following argument to true, we can get
//fahrenheit values
float f = dht.readTemperature(true);
//test whether the values from DHT sensor can be read, and if not
//display to screen that it cannot read values from sensor
if(isnan(h)||isnan(t)||isnan(f)){
Serial.println("Fail to read values from DHT sensor");
}
//compute and return heat index in fahrenheit. Heat index measures
//how hot it feels according to both humidity and temperature
float heatInFahrenheit = dht.computeHeatIndex(f,h);
//compute and return heat index in celsius. Heat index measures
//how hot it feels according to both humidity and temperature
float heatInCelsius = dht.computeHeatIndex(t,h,false);
lcd.setCursor(0,0);
lcd.print(h);
lcd.print("%");
lcd.setCursor(0,1);
lcd.print(t);
lcd.print("*C");
lcd.setCursor(8,0);
lcd.print(heatInCelsius);
lcd.print("*C");
}