#include "DHT.h"
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd (0x27, 20, 4);
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht (DHTPIN, DHTTYPE);
void setup() {
Serial.begin (9600);
lcd.println (F("DHTxx test! ")) ;
dht.begin();
lcd.init();
lcd.backlight();
}
void loop() {
delay (2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
float f = dht.readTemperature(true);
int analogValue = analogRead (A0 );
float voltage = analogValue / 1024. *5;
if (isnan (h) || isnan (t) || isnan (f)) {
lcd.println (F("failed to read from DHT sensor!"));
return;
}
lcd.setCursor (0, 0);
float hif = dht.computeHeatIndex (f, h);
float hic = dht.computeHeatIndex (t,h, false);
lcd.print(F ("Kelembaban:")) ;
lcd.print(h);
lcd.setCursor (0,1);
lcd.print(F ("Suhu : "));
lcd.print(t);
lcd.print(F ("°C "));
}