ESP32 Button Triggering False Presses Over Time

Hi everyone,

I have an ESP32 setup that includes:

  • an LD2420 mmWave radar motion sensor,
  • a BH1750 light sensor,
  • and a push button connected to a GPIO pin.

Everything works perfectly for a few months, but then, all of a sudden, the button starts to behave erratically, it detects false presses continuously even when it’s not being touched.

The rest of the system (radar and light sensor) continues to function normally.

The button is currently connected to GPIO 11 with the internal pull-up resistor enabled, and it’s wired to close to ground when pressed.
I’ve also added a 100 ms software debounce filter, but even increasing that value doesn’t make any difference.

Originally, the button was connected to GPIO 10, but after some time it started to switch on and off and then completely stopped working, so I moved it to GPIO 11 and now it has started detecting false triggers there as well.

Below is my code. Maybe I’m missing something obvious?

esphome:
  name: esphome-radar
  friendly_name: radar

esp32:
  board: esp32-c6-devkitc-1
  framework:
    type: esp-idf

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

ota:
  - platform: esphome
    password: "xxxxxxxxxxxxxxxxxxxx"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  reboot_timeout: 120s
  manual_ip:
    static_ip: 192.168.10.105
    gateway: 192.168.10.1
    subnet: 255.255.255.0
#  output_power: 20.4 dB
#  power_save_mode: none 
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: hotspot_radar
    password: !secret hotspot_wifi_password

i2c:
  sda: GPIO6
  scl: GPIO7
  scan: true
  id: bus_a
 

uart:
  id: ld2420_uart
  tx_pin: GPIO0
  rx_pin: GPIO1
  baud_rate: 115200
  parity: NONE
  stop_bits: 1

captive_portal:

ld2420: 

binary_sensor:
  - platform: gpio
    pin: 
      number: GPIO11 
      mode:
        input: true 
        pullup: true
      inverted: true
    filters:
      - delayed_on: 500ms
   #   - delayed_off: 200ms
    name: "Pulsante Luce Bagno"
    id: pulsante_luce_bagno
  - platform: ld2420
    has_target:
      name: Presenza    

text_sensor:
  - platform: ld2420
    fw_version:
      name: Versione firmware

sensor:
  - platform: ld2420
    moving_distance:
      name : Distanza di movimento

  - platform: bh1750
    i2c_id: bus_a
    name: "Sensore Luminosità Bagno"
    address: 0x23
    update_interval: 30s  

  - platform: uptime
    name: "Uptime"

  #Availabe on esp32 and not on 8266
  - platform: internal_temperature
    name: "Internal Temperature"

  - platform: wifi_signal # Reports the WiFi signal strength/RSSI in dB
    name: "WiFi Signal dB"
    id: wifi_signal_db
    update_interval: 60s
    entity_category: "diagnostic"

  - platform: copy # Reports the WiFi signal strength in %
    source_id: wifi_signal_db
    name: "WiFi Signal Percent"
    filters:
      - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
    unit_of_measurement: "Signal %"
    entity_category: "diagnostic"
    device_class: ""  

switch:
  - platform: restart
    name: Riavvio nodo ESPHome

select:
  - platform: ld2420
    operating_mode:
      name: Modalità operativa

number:
  - platform: ld2420
    presence_timeout:
      name: Timeout di rilevazione presenza
    min_gate_distance:
      name: Distanza minima gate
    max_gate_distance:
      name: Distanza massima gate
    gate_select:
      name: Selezione gate
    still_threshold:
      name: Impostazione soglia immobilità
    move_threshold:
      name: Impostazione soglia movimento
button:
  - platform: ld2420
    apply_config:
      name: Applica configurazione
    factory_reset:
      name: Reset a impostazioni di fabbrica
    restart_module:
      name: Riavvio modulo
    revert_config:
      name: Undo modifiche

Has anyone encountered a similar issue?
Could it be a hardware problem, GPIO wear-out, or maybe something related to the internal pull-up stability over time?

Any insights or troubleshooting tips would be greatly appreciated.

Thanks in advance!

Choose another GPIO. 10 & 11 are not good choices. See the table lower down on this page: ESP32 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials

Also check for cold solder joints / loose wiring.

How long are the wires connecting the button?

Is your power supply still up to the task? Bulging capacitors are a sure sign it is failing.

hi, thanks for your hints!
Ok, I’ll try moving it to GPIO 13
I didn’t know that some of the exposed GPIOs are not recommended for general use. thanks for pointing that out!

However, I have other projects that use GPIOs 6–11 as UART, SPI, or I2C without any issues

Unfortunately, the button is located about 3 meters away from the ESP32, and I don’t really have any alternative placement.
The power supply seems fine, so I don’t think that’s the issue.

3 meter wire to button.

That could be acting as an antenna for the 15m shortwave Ham radio band.

1 Like

There’s some confusion with different esp32 boards now.
For C6 Gpio13 is not best choice since it’s USB_D+ pin, just stay with 11.

For your button, add 1k external pull-up resistor and see how it behaves.

Put a 0.1uF capacitor from the GPIO to ground. As close as possible to the GPIO. Keep the capacitor leads as short as possible.

This should shunt any picked up RF to ground.

1 Like