/* Make by Rahul Kurniawan */
#include <DHT.h>
#define DHTPIN 4
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
const int relay = 10;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("kontrol relay dengan sensor suhu");
dht.begin();
pinMode(relay, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
float suhu = dht.readTemperature(); //menghitung suhu
if(suhu > 30){
digitalWrite(relay, HIGH);
}else{
digitalWrite(relay, LOW);
}
delay(1000);
Serial.print("Suhu: ");
Serial.print(suhu);
Serial.println(" C");
}