Page 1 of 1

Button interrupt triggering without button press

Posted: Fri Jan 24, 2025 7:56 pm
by anakin78z
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? 🙏

Re: Button interrupt triggering without button press

Posted: Thu Feb 06, 2025 7:23 pm
by markdh102
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.