#include <DHTesp.h>
DHTesp dhtsensor;
TempAndHumidity data;
const int DHT_PIN=27;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(18, OUTPUT);
pinMode(5, OUTPUT);
dhtsensor.setup(DHT_PIN,DHTesp::DHT22);
}
void loop() {
data=dhtsensor.getTempAndHumidity();
Serial.println("Hum:"+String(data.humidity,1));
Serial.println("Temp:"+String(data.temperature));
Serial.println("-------");
if ((data.humidity<50)&&(data.temperature<50))
{
digitalWrite(18, HIGH);
digitalWrite(5, LOW);
}
else
{
digitalWrite(18, LOW);
digitalWrite(5, HIGH);
}
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}