#include <DHT.h>
#include <LiquidCrystal_I2C.h>
#define DHTPIN 3 // Pin data DHT11 terhubung ke pin 2
#define DHTTYPE DHT22 // Tipe sensor DHT (DHT11)
LiquidCrystal_I2C lcd(0x27, 20, 4); // Alamat I2C modul dan ukuran LCD (16x2)
DHT dht(DHTPIN, DHTTYPE);
void setup() {
pinMode(DHTPIN, OUTPUT);
lcd.init(); // Inisialisasi LCD
lcd.backlight(); // Nyalakan lampu latar LCD
Serial.begin(9600);
dht.begin();
}
void loop()
{
float temperatureC = dht.readTemperature(); // Baca suhu dalam Celsius
float temperatureF = dht.readTemperature(true); // Baca suhu dalam Fahrenheit (true)
float humidity = dht.readHumidity();
lcd.setCursor(0,0);
lcd.print("GALANG VIRGIAWAN");
lcd.setCursor(0,1);
lcd.print("EK-2D_06");
lcd.setCursor(0, 2);
lcd.print("suhu :");
lcd.print(temperatureC);
lcd.print("C");
lcd.setCursor(0, 3);
lcd.print("H:");
lcd.print(humidity);
delay(1000);
lcd.clear();
}