Binary sensor doesn't work

so I have an esp32 devkitc in use, and I want to control an (existing) relay with a pushbutton. I have done this before with another esp32 model and it worked perfectly. I have connected gpio17 to a pushbutton and back to the ground, but the problem is that I get no message in my logs that it does something. I know for sure that my connections are good, tested with a multimeter.

this is my configuration in esphome:

esphome:
  name: esp32-1

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "***"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  manual_ip:
    static_ip: 192.168.111.80
    gateway: 192.168.111.1
    subnet: 255.255.255.0
    dns1: 208.67.220.220
    dns2: 208.67.222.222

switch:
  - platform: gpio
    pin: 18
    name: "Relay_1"
    id: Relay_1
    inverted: true
    
  - platform: gpio
    pin: 19
    name: "Relay_2"
    id: Relay_2
    inverted: true
    
  - platform: gpio
    pin: 21
    name: "Relay_3"
    id: Relay_3
    inverted: true

binary_sensor:
 - platform: gpio
   pin:
      number: GPIO17
      mode:
        input: true
        pullup: true
        output: false
        open_drain: false
        pulldown: false
      inverted: true
   name: "Lamp Computer Button"
   on_press:
     then:
      - switch.toggle: Relay_1
   filters:
     - delayed_on_off: 100ms

web_server:
  port: 80
  version: 2
  ota: false

Which type is your pushbutton ?

NC, but if I use a NO it doesn’t work either.

NC should work as you have pullups and inverted operation configured.

Double check you have the correct pin connected to the PB (labelled 17 or TX2 depending on which board you have):

If that’s all good find your board here and click the link to the page which shows which board: you should use.

Yeah its this one, but where do I need to change anything? If I try to set it as the board name it shows an error that the board doesn’t exist.

esp32-c3-devkitc-02
Naamloos

Try the recommended config for the ESP32-C3: https://esphome.io/components/esp32.html#esp-idf-framework

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: esp-idf
    version: recommended
    # Custom sdkconfig options
    sdkconfig_options:
      CONFIG_COMPILER_OPTIMIZATION_SIZE: y
    # Advanced tweaking options
    advanced:
      ignore_efuse_mac_crc: false

Now I really have no idea what is wrong.
Naamloos

Scroll down to the next red cross. I’m guessing it will be next to the web server component. Not all components are available in the esp-idf framework yet but switches and binary sensors should be.

There’s a note further up the page I linked to that says:

Note
Support for the ESP32-S2 and ESP32-C3 is still in development and there could be issues.

You have chosen a “bleeding edge” board.

So I did what you said, it was next to the web server indeed, so I deleted that part. Then I got the error:

INFO Reading configuration /config/esphome/esp32-1.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing esp32-1 (board: esp32-c3-devkitm-1; framework: espidf; platform: platformio/[email protected])
--------------------------------------------------------------------------------
Platform Manager: Installing platformio/espressif32 @ 2.3.1
Error: Please upgrade to the PlatformIO Core 6

I fixed that by removing the esphome add-on and reinstalling it. That worked, kinda. Got the following error while installing:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
esphome 2023.5.3 requires pyparsing>=3.0, but you have pyparsing 2.3.1 which is incompatible.
Reading CMake configuration...
-- Found Git: /usr/bin/git (found version "2.30.2") 
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- The ASM compiler identification is GNU
-- Found assembler: /data/cache/platformio/packages/toolchain-riscv32-esp/bin/riscv32-esp-elf-gcc
-- Check for working C compiler: /data/cache/platformio/packages/toolchain-riscv32-esp/bin/riscv32-esp-elf-gcc
-- Check for working C compiler: /data/cache/platformio/packages/toolchain-riscv32-esp/bin/riscv32-esp-elf-gcc -- broken
-- Configuring incomplete, errors occurred!
See also "/data/esp32-1/.pioenvs/esp32-1/CMakeFiles/CMakeOutput.log".
See also "/data/esp32-1/.pioenvs/esp32-1/CMakeFiles/CMakeError.log".

fatal: not a git repository (or any parent up to mount point /)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
CMake Error at /data/cache/platformio/packages/tool-cmake/share/cmake-3.16/Modules/CMakeTestCCompiler.cmake:60 (message):
  The C compiler

    "/data/cache/platformio/packages/toolchain-riscv32-esp/bin/riscv32-esp-elf-gcc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /data/esp32-1/.pioenvs/esp32-1/CMakeFiles/CMakeTmp
    
    Run Build Command(s):/data/cache/platformio/packages/tool-ninja/ninja cmTC_99c16 && [1/2] Building C object CMakeFiles/cmTC_99c16.dir/testCCompiler.c.obj
    FAILED: CMakeFiles/cmTC_99c16.dir/testCCompiler.c.obj 
    /data/cache/platformio/packages/toolchain-riscv32-esp/bin/riscv32-esp-elf-gcc   -march=rv32imc -o CMakeFiles/cmTC_99c16.dir/testCCompiler.c.obj   -c testCCompiler.c
    riscv32-esp-elf-gcc: error trying to exec 'as': execvp: No such file or directory
    ninja: build stopped: subcommand failed.
    
    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  /data/cache/platformio/packages/framework-espidf/tools/cmake/project.cmake:296 (__project)
  CMakeLists.txt:3 (project)



========================= [FAILED] Took 578.30 seconds =========================

Did not found any clear help on the dear internet, so I deleted the part below and made the board back to just: esp32dev

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: esp-idf
    version: recommended
    # Custom sdkconfig options
    sdkconfig_options:
      CONFIG_COMPILER_OPTIMIZATION_SIZE: y
    # Advanced tweaking options
    advanced:
      ignore_efuse_mac_crc: false

I ran the install, and it succeeded. I then tested if the binary sensor worked, it did not. So I just played around changing the GPIO numbers of the binary sensor (it was still on GPIO17), I changed it to GPIO5 and now it works when I short GPIO5 to ground so I am happy. Why it doesn’t work on 17? I wouldn’t know, but it does work on 5.

This is the configuration I use now:

esphome:
  name: esp32-1

esp32:
  board: esp32dev
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: "ba46d4713d407fa74d443217be3a320c"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  manual_ip:
    static_ip: 192.168.111.80
    gateway: 192.168.111.1
    subnet: 255.255.255.0
    dns1: 208.67.220.220
    dns2: 208.67.222.222

switch:
  - platform: gpio
    pin: 18
    name: "Relay_1"
    id: Relay_1
    inverted: true
    
  - platform: gpio
    pin: 19
    name: "Relay_2"
    id: Relay_2
    inverted: true
    
  - platform: gpio
    pin: 21
    name: "Relay_3"
    id: Relay_3
    inverted: true

binary_sensor:
 - platform: gpio
   pin:
      number: GPIO5
      mode:
        input: true
        pullup: true
        output: false
        open_drain: false
        pulldown: false
      inverted: true
   name: "Lamp Computer Button"
   on_press:
     then:
      - switch.toggle: Relay_1
   filters:
     - delayed_on_off: 50ms

web_server:
  port: 80
  version: 2
  ota: false

Because you have the wrong pin schema loaded because you have the wrong board defined.

Actually, scroll down to the table on this page that shows the available GPIO for the ESP32-C3: https://www.studiopieters.nl/esp32-c3-pinout/

GPIO17 is connected to the integrated SPI flash.

Ahh thanks, this is the pinout from the seller.
devkitc seller page

Ok that is not an ESP32-C3 chip as you specified here:

The WROVER module uses an ESP32-D0WD processor.

So (as you discovered) this is the required config:

platform: espressif32
board: esp32dev

So I’m not sure why GPIO17 is not working for you.