#include <DHTesp.h>
DHTesp dhtSensor;
TempAndHumidity data;
const int DHT_PIN = 15;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
dhtSensor.setup(DHT_PIN, DHTesp::DHT22);
pinMode(12, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int temp = data.temperature;
// int humi=data.humidity;
data = dhtSensor.getTempAndHumidity();
if(temp>20)
{
digitalWrite(12, HIGH);
Serial.println("DHT is On");
}
else if(temp<20)
{
digitalWrite(12, LOW);
Serial.println("DHT is Off");
}
Serial.println("temp : " + String(data.temperature,1));
Serial.println("-----------------");
delay(1000);
//delay(10); // this speeds up the simulation
}