// ===================================================
// Nama : Muhammad Farchan Setyawan
// NIM : 1002210072
// Prodi: TI Karyawan
// ===================================================
#include <DHT.h>
#define pin_led 12
#define pin_led2 33
#define DHT22PIN 23
bool KipasStatus = false;
float temp = 0.0;
float humi = 0.0;
DHT dht(DHT22PIN, DHT22);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(pin_led, OUTPUT);
pinMode(pin_led2, OUTPUT);
dht.begin();
}
void loop() {
// put your main code here, to run repeatedly:
humi = dht.readHumidity();
temp = dht.readTemperature();
Serial.print("Temperature: ");
Serial.print(temp);
Serial.print(" C, ");
Serial.print("Humidity: ");
Serial.print(humi);
Serial.println(" % ");
if (temp > 35){
KipasStatus=HIGH;
}else if (temp < 30){
KipasStatus=LOW;
}
digitalWrite(pin_led, KipasStatus);
delay(10); // this speeds up the simulation
}