#include <DHT.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define DHTPIN 2
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
Adafruit_SSD1306 display(128, 64, &Wire, -1);

  float h = dht.readHumidity();
  float t = dht.readTemperature();
  float f = dht.readTemperature(true);

void updateDisplay(){
  display.clearDisplay();
  display.setFont();
  display.setTextColor(1);

  display.setCursor(2, 2);
  display.print("Suhu:");
  display.println(t);
}

void setup() {
  // put your setup code here, to run once:
  dht.begin();
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  updateDisplay();
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(2000);
  updateDisplay();

  


  /*if(isnan(h) || isnan(t) || isnan(f)){
    Serial.println(F("Gagal!"));
    return;
  }
   Serial.print("Humidity: ");
   Serial.println(h);
   Serial.print("Temperature in Celecius: ");
   Serial.println(t);
   Serial.print("Temperature in Farenheit: ");
   Serial.println(f);
   Serial.println();*/
}