// Include the libraries we need
#include <LiquidCrystal_PCF8574.h>
#include <DHT.h>
LiquidCrystal_PCF8574 lcd(8*27); // set the LCD address to 0*27 for a 16 chars and
2 line display
#define DHTPIN 23
// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DTH 11
//#define DHTTYPE DHT22 //DHT 22 (AM2302), AM2321
//#define DHTTYPE DHT21 //DHT 21 (AM2302)
DHT dht(DHTPIN, DHTTYPE);
char grados = 223;
void setup() {
// put your setup code here, to run once:
dht.begin();
lcd.begin(20, 4); // inicialize the lcd
delay(200);
lcd.setBackligt(255);
lcd.print("Humedad:");
lcd.setCursor(0,1);
lcd.print("Temperatura:");
}
void loop() {
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor reading may also be up to 2 seconds
float h = dht.readHumidity();
//Read temperature as Celsius (the default)
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
lcd.setCursor(13,0);
lcd.print("error!");
lcd.setCursor(13,1);
lcd.print("error!");
return;
}
lcd.setCursor(13,0);
lcd.print(h,0);
lcd.print("% ");
lcd.setCursor(13,1);
lcd.print(t,0);
lcd.print((char) grado);
lcd.print("C ");
delay(1000);