#include <DHT.h>
#define DHT_SENSOR_PIN 32 // 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();
pinMode(13, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
//digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) // wait for a second
//digitalWrite(13, LOW); // turn the LED off by making the voltage LOW // wait for a second
float tempC = dht_sensor.readTemperature();
float tempF = dht_sensor.readTemperature(true);
if (isnan(tempC) || isnan(tempF)) {
Serial.println("Fehler beim Auslesen des Sensors");
}
else {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
Serial.print("Temperatur: ");
Serial.print(tempC);
Serial.print("°C | ");
Serial.print(tempF);
Serial.println(" F ");
}
float Luft = dht_sensor.readHumidity();
if (isnan(Luft)) {
Serial.println("Fehler beim Auslesen des Sensors");
}
else {
Serial.print("Luftfeuchtigkeit: ");
Serial.print(Luft);
Serial.println(" %");
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
}
delay(2000); // this speeds up the simulation
}
#include <WiFi.h>
void setup() {
Serial.begin(9600);
Serial.print("Connecting to WiFi");
WiFi.begin("Wokwi-GUEST", "", 6);
while (WiFi.status() != WL_CONNECTED) {
delay(100);
Serial.print(".");
}
Serial.println(" Connected!");
}
void loop() {
delay(100); // TODO: Build something amazing!
}