/**
Nama : Ferdy Luqman Djunaedi
Jurusan : Sistem Informasi
NPM : 2122.02.0002
Whatsapp : wa.me/6281222858372 (081222858372)
*/
#include "DHTesp.h"
const int DHT_PIN = 19;
DHTesp dhtSensor;
void setup() {
Serial.begin(115200);
dhtSensor.setup(DHT_PIN, DHTesp::DHT22);
}
void loop() {
TempAndHumidity data = dhtSensor.getTempAndHumidity();
float temperature = data.temperature;
Serial.println("Temp: " + String(temperature, 2) + "°C");
Serial.println("Humidity: " + String(data.humidity, 1) + "%");
if (temperature > 30.0) {
Serial.println("Hidupkan AC");
} else if (temperature > 20.0) {
Serial.println("Hidupkan Kipas Angin");
} else {
Serial.println("Gunakan Jaket Anda");
}
delay(2000); // Wait for a new reading from the sensor (DHT22 has ~0.5Hz sample rate)
}