Ich habe ein ESP32-Setup aufgebaut, bei dem sowohl der ESP32 selbst als auch mein MOSFET-Relaismodul sichtbar mit Strom versorgt werden, da bei beiden die Status-LED leuchtet. Trotzdem funktioniert das System nicht wie erwartet.
Mein Temperatursensor liefert keinerlei Daten an den ESP32, obwohl ich ihn laut Beschreibung korrekt angeschlossen habe, also an D2 (Daten), GND und 3,3 Volt. Parallel dazu habe ich das MOSFET-Relaismodul mit zwei Jumper-Kabeln an D18 und ebenfalls an 3,3 Volt angeschlossen. Allerdings kann ich weder Temperaturwerte auslesen noch das Relaismodul bzw. die Stromdurchleitung darüber steuern.
Das führt dazu, dass ich unsicher bin, wo genau der Fehler liegt. Entweder stimmt etwas in meiner ESPHome-Konfiguration beziehungsweise im Code nicht, oder ich habe ein grundlegendes technisches Problem in der Verdrahtung oder im Verständnis der Komponenten.
Der Code nach dem grundlegenden Code
# OneWire Bus
one_wire:
- platform: gpio
pin: GPIO4
id: bus_a
# Temperatur Sensor
sensor:
- platform: dallas_temp
name: “Temperatur”
id: temp_sensor
one_wire_id: bus_a
update_interval: 10s
on_value:
then:
- lambda: |-
// MANUELLER OVERRIDE
if (id(manual_override).state) {
id(relais).turn_on();
return;
}
// Failsafe: Sensorfehler
if (isnan(x)) {
id(relais).turn_off();
return;
}
static bool hot_active = false;
static bool cold_active = false;
float high_on = id(temp_high_on).state;
float high_off = id(temp_high_off).state;
float low_on = id(temp_low_on).state;
float low_off = id(temp_low_off).state;
// HITZE (Lüfter)
if (!hot_active && x >= high_on) {
hot_active = true;
id(relais).turn_on();
} else if (hot_active && x <= high_off) {
hot_active = false;
if (!cold_active) {
id(relais).turn_off();
}
}
// KÄLTE (Frostschutz)
if (!cold_active && x <= low_on) {
cold_active = true;
id(relais).turn_on();
} else if (cold_active && x >= low_off) {
cold_active = false;
if (!hot_active) {
id(relais).turn_off();
}
}
# Einstellbare Werte (Home Assistant)
number:
- platform: template
name: “Max Temperatur Lüfter an”
id: temp_high_on
min_value: 20
max_value: 40
step: 0.5
initial_value: 30
restore_value: true
optimistic: true
- platform: template
name: “Max Temperatur Lüfter aus”
id: temp_high_off
min_value: 20
max_value: 40
step: 0.5
initial_value: 28
restore_value: true
optimistic: true
- platform: template
name: “Min Temperatur Frost an”
id: temp_low_on
min_value: -10
max_value: 10
step: 0.5
initial_value: 5
restore_value: true
optimistic: true
- platform: template
name: “Min Temperatur Frost aus”
id: temp_low_off
min_value: -10
max_value: 10
step: 0.5
initial_value: 7
restore_value: true
optimistic: true
switch:
- platform: gpio
pin: GPIO18
id: relais
internal: True
name: “Lüfter Frostschutz”
restore_mode: RESTORE_DEFAULT_OFF
- platform: template
name: “Manueller Override”
id: manual_override
optimistic: true
by HarryP: Post formatiert

