Binary sensor - invert usage

Hi,

i have some Wallmount Push-Buttons, which turn to Ground on push.

When i use a binary sensor with the following configuration, i receive OFF/ON-Triggers even if the buttons are not pushed. Sometimes more, sometimes less:

- platform: gpio
    pin:
      number: GPIO19
      mode: INPUT_PULLUP
    filters:
      - delayed_on: 50ms
      - delayed_off: 50ms
    name: "Taster Tuer oben"
    id: taster_tuer_oben

When i use the following config, everything seems fine:

- platform: gpio
    pin:
      number: GPIO19
      mode: INPUT_PULLUP
    filters:
      - invert:
      - delayed_on: 50ms
      - delayed_off: 50ms
    name: "Taster Tuer oben"
    id: taster_tuer_oben

The only difference here is “invert”.

My question:

I thought that “invert” simply inverts the signal - but it looks to me, as that there is some “magic” happening here.
Otherwise i don’t understand, why i get “ghost-triggers” without “invert”. Should not the pullup in combination with the “debounce”-Statements be sufficient to get a stable binary status?

What am i missing?

cu,
Ben

Last year, I too had a case of ghost triggers with a Sonoff Touch. I tried everything on the software side and nothing gave satisfactory results. In the end, I changed the hardware to a DIY touch switch and I never had ghost switching. What you can do is add a capacitor to filter out noise.

Hmm, i took a look at the corresponding Source-Code. “invert” indeed does a simple !value, so no special treatment that would prevent “ghost”-Push-button-bouncing.

Any other ideas, why a binary sensor with activated Pullup and no “invert”-usage does “ghost”-triggering?

I used the same push-buttons on Atmel-ATMega32 before without any problems.

cu
Ben

Can you show your circuit diagram?

Sure:

30

Nothing really special. GPIO5 is only an example. The described behavior ist replicable on any other Port/Push-Button combination,

cu,
Ben

I’m using these Outdoor-Push-Buttons (8x):

1 Like

Hi,

i’ve found the problem: It was not an esphome-fault. I had some weird electromagnetic-interferences which caused big trouble on the binary-inputs. The wires to the push-buttons are about 10m long (CAT5) an seemed to work like an antenna.

I disabled the internal pushup and used a 1k external Pullup: Problems gone for all 8 push-buttons.

cu,
Ben

2 Likes