NodeMCU 32 ESPHome mode: INPUT_PULLDOWN not compiling

I’m trying to use the mode: INPUT_PULLDOWN option with my defined binary sensors and having no success.

The docs say it’s supported for ESP32 but I can’t get mode: INPUT_PULLUP to compile either.

My config looks like this:

binary_sensor:
  - platform: gpio
    pin: GPIO18
    name: "Drum motor toggle"
    id: drum_motor_toggle
    mode: INPUT_PULLDOWN
    on_press:
      then:
        - switch.toggle: drum_motor

Firstly, is my assumption correct that INPUT_PULLDOWN should be supported and will using it obviate the need for a pull-down resistor when connecting a switch?

I’d appreciate some help. I’ve been at this for ages!

Maybe this ?

binary_sensor:
  - platform: gpio
    pin: 
      number: D18
      mode: INPUT_PULLDOWN
    name: "Drum motor toggle"
    id: drum_motor_toggle
    on_press:
      then:
        - switch.toggle: drum_motor

Yes, that’s correct, if you connect the switch to +3.3v and the gpio pin. If you connect the switch to gnd and the gpio, use INPUT_PULLUP

1 Like

Thank you so much for the help.

What’s the difference between using D18 and GPIO18?

I don’t have a preference, I’d just like to understand.

Don’t know really, thats just how its shown in the docs

I just tried this. Still no compile. It fails at the number: D18 line.

INPUT_PULLUP gets the same result.

Can you post your whole YAML ?

I just changed it back to GPIO18 and it compiles with both INPUT_PULLUP and INPUT_PULLDOWN.

Seemingly sorted. Thank you.

binary_sensor:
  - platform: gpio
    pin: 
      number: GPIO18
      mode: INPUT_PULLDOWN
    name: "Drum motor toggle"
    id: drum_motor_toggle
    on_press:
      then:
        - switch.toggle: drum_motor

Strange, I use the Dx pin numbers exclusively. I’ll bear it in mind for the future

As usual the docs help with the pin naming. https://esphome.io/guides/configuration-types.html#pin