#include <DHT.h>
#define DHT_SENSOR_PIN 15 // ESP32 pin GPIO21 connected to DHT22 sensor
#define DHT_SENSOR_TYPE DHT22
DHT dht_sensor(DHT_SENSOR_PIN, DHT_SENSOR_TYPE);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
dht_sensor.begin();
}
void loop() {
float tempC = dht_sensor.readTemperature();
float tempF = dht_sensor.readTemperature(true);
float humVal = dht_sensor.readHumidity();
Serial.print("Temperatur: ");
Serial.print(tempC);
Serial.print("°C | ");
Serial.print(tempF);
Serial.println(" F ");
Serial.println("-----------------------------------");
Serial.print("Humidity: ");
Serial.print(humVal);
Serial.println(" %");
// put your main code here, to run repeatedly:
delay(2000); // this speeds up the simulation
}