#include <LiquidCrystal_PCF8574.h>
#include <DHT.h>
LiquidCrystal_PCF8574 lcd(0x27);
#define DHTPIN 0
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
char grados = 223;
void setup() {
// put your setup code here, to run once:
dht.begin();
lcd.begin(20, 4); // initialize the lcd
delay(200);
lcd.setBacklight(255);
lcd.print("Humedad:");
lcd.setCursor(0, 1);
lcd.print("Temperatura:");
}
void loop() {
// put your main code here, to run repeatedly:
// 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();
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, 1);
lcd.print("% ");
lcd.setCursor(13, 1);
lcd.print(t, 1);
lcd.print(grados);
lcd.print("C ");
delay(1000);
}