#include "DHT.h"
#define dhtPin 27
#define dhtType DHT22
DHT dht(dhtPin, dhtType);
void setup() {
// put your setup code here, to run once:
dht.begin();
Serial.begin(115200);
Serial.println("Hello, ESP32!");
}
void loop() {
// put your main code here, to run repeatedly:
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
Serial.println("========================");
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.println(F("%"));
Serial.print(t);
Serial.println(F("°C "));
Serial.println("========================");
delay(10); // this speeds up the simulation
}