#define dhtPin 13
#define DHTTYPE DHT22
#include "DHT.h"
#include <LiquidCrystal_I2C.h>
DHT dht(dhtPin,DHTTYPE);
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  Serial.begin(9600);
  Serial.println(F("Test DHT22"));
  dht.begin();
  lcd.init();
  lcd.backlight();
}

void loop() {
  
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  float f = dht.readTemperature(true);
  if(isnan(h) || isnan(t) || isnan(f)) {
    Serial.println("Sensor gagal");
    return;
  }
  Serial.print("Humidity = ");
  Serial.print(h);
  Serial.print("    Temperature = ");
  Serial.println(t);
  lcd.setCursor(0,1);
  lcd.print("Suhu: ");
  lcd.print(t);
  if(t<20) {
    lcd.setCursor(0,0);
    lcd.print("SUHU DINGIN");
  } else if(t>32) {
    lcd.setCursor(0,0);
    lcd.print("SUHU PANAS ");
  } else {
    lcd.setCursor(0,0);
    lcd.print("SUHU NORMAL");
  }
  delay(100);

}