Using pullup on binary sensor

I’m trying to use a ESP32 with a 1-Bit AC 220V Optocoupler Isolatie Module


I don’t get a stable readout. It is constantly bouncing between on and off. I found that you can activate internal pullup or pulldown resistors with this code.

Blockquote

binary_sensor:

  • platform: gpio
    pin:
    number: D2
    mode:
    input: true
    pullup: true

Blockquote

If I do so I’m receving errors like this:

INFO ESPHome 2023.11.6
INFO Reading configuration /config/esphome/monitoring.yaml…
Failed config

binary_sensor.gpio: [source /config/esphome/monitoring.yaml:33]
platform: gpio
pin: GPIO14

[mode] is an invalid option for [binary_sensor.gpio]. Please check the indentation.
mode:
input: True
pullup: True
name: Groep 1
device_class: power

It’s not possible to tell if you have indented your code correctly as you have not formatted it correctly. It should be something like this:

binary_sensor:
  - platform: gpio
    device_class: power
    pin:
      number: GPIO14
      mode:
        input: true
        pullup: true

If it still bounces try this:

binary_sensor:
  - platform: gpio
    device_class: power
    pin:
      number: GPIO14
      mode:
        input: true
        pullup: true
    filters:
      - delayed_off: 100ms

Sometimes things are easy. Read the manual the right way. :slightly_smiling_face: The problem is partialy solved. Without the module connected no problems anymore. As soon I connected it the problem is back. When I connect the module to the mains, the out port goes down (0 volt) and the bouncing begines. Experimented with higher values of the delay, condensor over the out to the ground nothing helpes. If I look at scoop the signal is not very decent. It think those modules are simply crap.

After all I found the real problem. On the circuit board was a misprint. The pin next to 5V was marked GND. So I used it as GND. It has to be marked CMD. The sensor signal was floating when I used this pin as GND. Works perfect now. Thanks for your help.

1 Like