#include "DHTesp.h"
const int DHT_PIN = 15;
DHTesp dhtSensor;
int rele=22;
int boton=12;
int botonState=HIGH;
void setup() {
Serial.begin(115200);
dhtSensor.setup(DHT_PIN, DHTesp::DHT22);
serial.println("Hello, ESP32");
pinMode(rele, OUTPUT);
pinMode(boton, INPUT_PULLUP);
digitalWrite(rele, LOW);
}
void loop() {
TempAndHumidity data = dhtSensor.getTempAndHumidity();
Serial.println("Temp: " + String(data.temperature, 2) + "°C");
Serial.println("Humidity: " + String(data.humidity, 1) + "%");
Serial.println("---");
delay(1000);
delat(10);
botonState=digitalRead(boton);
serial,println(botonState);
delay(200);
if(botonState==LOW){
digitalWrite(rele, HIGH);
}else
{
digitalWrite(rele, LOW);
}
}