#include <DHT.h>
#include <Adafruit_Sensor.h>
DHT dht(3, DHT22);
#include "DHTesp.h"
DHTesp dhtSensor;
const int DHT_PIN = 3;
int ijo =4;
int kuning =5;
int merah =6;
void setup() {
Serial.begin(9600);
Serial.println("cek suhu dan kelembaban");
dht.begin();
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
Serial.begin(9600);
dhtSensor.setup(DHT_PIN, DHTesp::DHT22);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
}
void loop() {
float kelembaban = dht.readHumidity();
float suhu = dht.readTemperature();
if( suhu >= 32.00 and suhu <= 35.00)
{
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
}
if (suhu >= 36.00 and suhu <= 45.00) {
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
digitalWrite(6, LOW);
}
if(suhu >= 46.00 and suhu <= 50.00) {
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, HIGH);
}
Serial.println("kelembaban");
Serial.print(kelembaban);
Serial.println(" %");
Serial.println("suhu");
Serial.print(suhu);
Serial.println(" C");
delay(1000);
}