#include "LiquidCrystal.h"
LiquidCrystal lcd(8,7,6,5,4,3);
int sensorPin = 0;
#include "DHT.h"
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
Serial.begin(9600);
lcd.begin(20,4);
dht.begin();
} // end of setup
void loop()
{
delay(2000);
int reading = analogRead(sensorPin);
// measure the 5v with a meter for an accurate value
//In particular if your Arduino is USB powered
float voltage = reading * 4.68;
voltage /= 1024.0;
// now print out the temperature
float temperatureC = (voltage - 0.5) * 100;
Serial.print(temperatureC);
Serial.println(" F");
// print out the humidity
float humidityH = (voltage - 0.5) * 35;
Serial.print(humidityH);
Serial.println("% ");
String dehumidifier = d;
if (humidityH >= 60) {
Serial.print(d);
Serial.println("On");
} else {
Serial.print(d);
Serial.println("Off");
}
lcd.setCursor(0,0);
lcd.print("Temp: ");
lcd.setCursor(6,0);
lcd.print(temperatureC);
lcd.setCursor(10,0);
lcd.print("F ");
lcd.setCursor(0,1);
lcd.print("Humidity: ");
lcd.setCursor(10,1);
lcd.print(humidityH);
lcd.setCursor(15,1);
lcd.print("% ");
lcd.setCursor(0,2);
lcd.print("Dehumidifier: ")
lcd.setCursor(10,2);
lcd.print(d);
} // end of loop.
// Initialize DHT sensor.
// Note that older versions of this library took an optional third parameter to
// tweak the timings for faster processors. This parameter is no longer needed
// as the current DHT reading algorithm adjusts itself to work on faster procs.