#include <dht.h>
#include <LiquidCrystal_I2C.h>
dht DHT;
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
lcd.init();
lcd.backlight();
}
void loop() {
// put your main code here, to run repeatedly:
int value = DHT.read22(5);
tampilan_data();
delay(500);
}
void tampilan_data(){
Serial.print(DHT.humidity, 1);
Serial.print(",\t");
Serial.print(DHT.temperature, 1);
Serial.println(",\t");
tampilan_lcd(DHT.temperature, DHT.humidity);
}
void tampilan_lcd(float kelembaban, float suhu){
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("SUHU: ");
lcd.print(DHT.temperature);
lcd.setCursor(0, 1);
lcd.print("LEMBAB: ");
lcd.print(DHT.humidity);
}