I do not agree that you cannot use IRQ/ISR on ESP32. Many people do. It just does not come easy. And many of the problems like bouncing and picking up noise on high impedance inputs with wires are common to the technology in general. The only ESP32/ESP8266 specific problem I have found was the multiple trigger on slow slopes.
In your case, you either have to use a different I/O pin with pull-up capability or use external pull-up resistor.
Problem with interrupt callback being called all the time without button being pressed
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Problem with interrupt callback being called all the time without button being pressed
@solarjoe It does sound as if you have an M5stack-specific hardware problem. I would write a simple test script, with the ISR just printing a message (perhaps with a timestamp) each time it's called, and a continuously running function which keeps using the WiFi. With no link in code between the ISR and the function, and nobody pressing the button, the ISR should never run.
If it does it's a strong indication that the hardware is broken, although I suppose it could conceivably be a firmware problem if the firmware is M5stack-specific. If it's an official build I guess you or one of us could run your script on the ESP32 reference board. I've never heard of a generic problem like this on standard hardware.
If it does it's a strong indication that the hardware is broken, although I suppose it could conceivably be a firmware problem if the firmware is M5stack-specific. If it's an official build I guess you or one of us could run your script on the ESP32 reference board. I've never heard of a generic problem like this on standard hardware.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Problem with interrupt callback being called all the time without button being pressed
I had the exact same problem, same hardware.
I've tried to fiddle with its electronics, no luck with passives.
I could solve the problem polling the button although, like so:
At first I thought about connecting and disconnecting WiFi whenever needed, but there is no sense in that and could cause problems.
Other pins doesn't suffer from this, since they are not right near the WiFi Antenna nor soldered right next to it.
I hope it have helped some way.
I've tried to fiddle with its electronics, no luck with passives.
I could solve the problem polling the button although, like so:
Code: Select all
lastState = button.value()
while True:
if button.value() == 0 and lastState == 1:
toggle_power()
lastState = button.value()
if button.value() == 1 and lastState == 0:
lastState = button.value()
time.sleep_ms(50)
Other pins doesn't suffer from this, since they are not right near the WiFi Antenna nor soldered right next to it.
I hope it have helped some way.