Button interrupt triggering without button press

anakin78z
Posts: 1
Joined: Fri Jan 24, 2025 7:45 pm

Button interrupt triggering without button press

Postby anakin78z » Fri Jan 24, 2025 7:56 pm

Hello!

I have a button connected to the ESP8266 and have an interrupt callback set for when the button is pressed. The issue is, the callback triggers occasionally even when the button is not pressed. It is very inconsistent... it could be a few times a day, or several times in a 15 minute span. I'm trying to figure out how to stop these unwanted triggers, which are ruining my data :(.

To be absolutely clear, this isn't a bounce issue after clicking the button. This happens randomly on its own.
(I do have a little bit of button bounce, which I solve in the code with a simple delay)

I'm using MicroPython:

Code: Select all

button = Pin(5, Pin.IN, Pin.PULL_UP)

def on_button_rising(pin):
	...

button.irq(trigger=Pin.IRQ_RISING, handler=on_button_rising)
I have GPIO 5 going to the button, and then from the button to ground.

I've tried adding a resistor between the button and ground.
I've tried adding a capacitor, connecting to GPIO5 and ground, but that didn't help, and it somehow made the button bounce much worse.
I've tried swapping the usb power adapter.

Any ideas? 🙏

markdh102
Posts: 13
Joined: Sat Apr 18, 2020 12:03 pm

Re: Button interrupt triggering without button press

Postby markdh102 » Thu Feb 06, 2025 7:23 pm

If the wires to your button are long, then the internal pull up may be too weak.
Disable the internal pull up and try an external 10k pull up instead.

Who is online

Users browsing this forum: No registered users and 64 guests