Esphome garage opener false trigger

Hi

Hoping some one can help
I created a garage door opener with a binary sensor for the reed switch.
I am getting a lot of false signals particularly if I hold the bare wires with my fingers even if they are not directly connected.

If the wires are totally apart then they seem to be fine.

Any Ideas

esphome:
  name: esp_gate
  platform: ESP8266
  board: esp01_1m

 
wifi:
  networks:
  - ssid: 'IOT'
    password: ''
    hidden: true
  - ssid: 'Pumphouse'
    password: ''
    
  
api:
 
ota:
 
#web_server:
#  port: 80
 
logger:
#  level: VERY_VERBOSE 
  
binary_sensor:
  - platform: gpio
    pin:
      number: GPIO5
      mode: INPUT_PULLUP
      inverted: False
    name: "Gate"
    device_class: garage_door
    
switch:
  - platform: gpio
    pin: GPIO12
    id: relay
  - platform: template
    icon: "mdi:arrow-up-down-bold-outline"
    name: "Gate Control"
    turn_on_action:
    - switch.turn_on: relay
    - delay: 500ms
    - switch.turn_off: relay

You need some debouncing. Reed triggers can often get a false positive from any magnetic interference (i.e. being close to power wires).

You need to add a delay_on and delay_off. Or in this case, a delayed_on_off would be best.

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO5
      mode: INPUT_PULLUP
      inverted: False
    name: "Gate"
    device_class: garage_door
    filters:
      - delayed_on_off: 20ms

Now the sensor will only change if it was the same value for a full 20ms. Tweak these values as needed.

1 Like

I’ve found that the debouncer works well when there is only occasional signal interference. In cases where the signal interference is particularly bad due to power wires, the debouncer alone may make the reading completely unresponsive. In this case, you may need to make a hardware change. In this case, I’ve added a lower resistance pull-up circuit (~5-10k ohm) compared to the 30k or 50k internal pullup resistance that might be in the device. This cleaned the signal to the point that I didn’t even need a debouncer.

Matthew Thanks for your comment I assume that you put the pull up in line of the reed switch?

Not in series with the switch itself, but you directly connect your pin, GPIO5, to the 3.3v pin with a 5k ohm resistor or something like that.

https://learn.sparkfun.com/tutorials/pull-up-resistors/all