I have two garage doors on my garage. I used an ESP32, 2 channel 5V relay, and 2 Honeywell garage door sensors to create a garage door opener and door status monitoring device. The relays signal the doors to open and close and the sensors tell me if the door is currently in an open or closed state. Here’s a snippet from my ESPHome yaml file for this device:
esphome:
name: garage_door
platform: ESP32
board: esp32doit-devkit-v1
# ...
binary_sensor:
# Garage Door 1
- platform: gpio
pin:
number: GPIO18
mode: INPUT_PULLUP
inverted: False
name: "Garage Door 1 Sensor"
id: garage_door_1_sensor
device_class: garage_door
filters:
- delayed_on: 500ms
- delayed_off: 500ms
- delayed_on_off: 1s
# Garage Door 2
- platform: gpio
pin:
number: GPIO21
mode: INPUT_PULLUP
inverted: False
name: "Garage Door 2 Sensor"
id: garage_door_2_sensor
device_class: garage_door
filters:
- delayed_on: 500ms
- delayed_off: 500ms
- delayed_on_off: 1s
switch:
# Garage Door 1
- platform: gpio
id: garage_door_1_relay
pin:
number: GPIO22
inverted: False
restore_mode: ALWAYS_OFF
- platform: template
name: "Garage Door 1 Switch"
icon: "mdi:garage"
turn_on_action:
- switch.turn_on: garage_door_1_relay
- delay: 1s
- switch.turn_off: garage_door_1_relay
# Garage Door 2
- platform: gpio
id: garage_door_2_relay
pin:
number: GPIO23
inverted: False
restore_mode: ALWAYS_OFF
- platform: template
name: "Garage Door 2 Switch"
icon: "mdi:garage"
turn_on_action:
- switch.turn_on: garage_door_2_relay
- delay: 1s
- switch.turn_off: garage_door_2_relay
cover:
# Garage Door 1
- platform: template
name: Garage Door 1
device_class: garage
lambda: !lambda |-
if (id(garage_door_1_sensor).state) {
return COVER_OPEN;
} else {
return COVER_CLOSED;
}
open_action:
- switch.turn_on: garage_door_1_relay
- delay: 1s
- switch.turn_off: garage_door_1_relay
close_action:
- switch.turn_on: garage_door_1_relay
- delay: 1s
- switch.turn_off: garage_door_1_relay
stop_action:
- switch.turn_on: garage_door_1_relay
- delay: 1s
- switch.turn_off: garage_door_1_relay
# Garage Door 2
- platform: template
name: Garage Door 2
device_class: garage
lambda: !lambda |-
if (id(garage_door_2_sensor).state) {
return COVER_OPEN;
} else {
return COVER_CLOSED;
}
open_action:
- switch.turn_on: garage_door_2_relay
- delay: 1s
- switch.turn_off: garage_door_2_relay
close_action:
- switch.turn_on: garage_door_2_relay
- delay: 1s
- switch.turn_off: garage_door_2_relay
stop_action:
- switch.turn_on: garage_door_2_relay
- delay: 1s
- switch.turn_off: garage_door_2_relay
This device worked great when I first wired it up and starting using it. A couple of weeks later I noticed that the binary sensor on door 2 (garage_door_2_sensor
) was not reporting correctly. The binary sensor was always showing that the door was closed, even when it was in fact open. The relay switch still worked fine for open/closing it, however.
After doing some basic troubleshooting with my multimeter, I discovered that the sensor hardware and wiring were still working as expected. After rebooting the ESP32 several times, the problem was not resolved so I thought there might be a problem with the GPIO pin. I moved the garage_door_2_sensor
from GPIO19 to GPIO21, made the pin number change in the ESPHome yaml config, loaded new firmware OTA, and everything starting working properly again as expected.
I thought I had solved the problem and it was just some issue with that pin on the ESP32. Fast forward a couple of days, and now the same problem has started happening again on GPIO21. garage_door_2_sensor
is always reporting that the door is closed. I assume that I could move the sensor to another GPIO again and it will start working again temporarily.
Any idea what is going on here? Why would these pins stop working for door 2? Door 1 has not had any problems and it is wired up the same way. One end of the sensor wire goes to ground and the other end to the GPIO. Why are these pins dying?