Sorry for the second reply but I reread and just saw this: The problem with using the rising edge or falling edge modes is that the incoming signal from the button is pulsed so it triggers very rapidly and clutters up the call stack, consuming cpu with it. This is called debouncing. Add a small cap in parallel with the switch. Answer from alzee76 on reddit.com
🌐
The Robotics Back-End
roboticsbackend.com › home › raspberry pi gpio interrupts tutorial
Raspberry Pi GPIO Interrupts Tutorial - The Robotics Back-End
December 30, 2021 - Learn why, when, and how to use interrupts with GPIOs on your Raspberry Pi programs. Complete tutorial with code examples in Python, using RPi.GPIO module.
🌐
All About Circuits
allaboutcircuits.com › home › technical articles › how gpio interrupts work
How GPIO Interrupts Work - Technical Articles
October 25, 2019 - Our GPIO peripheral may have one or more interrupts for it in the list that the interrupt controller keeps. For example, for the CC2544, there is a group of eight pins that are part of the GPIO called PORT0.
Discussions

What are some practical use cases for GPIO Interrupts?
Sorry for the second reply but I reread and just saw this: The problem with using the rising edge or falling edge modes is that the incoming signal from the button is pulsed so it triggers very rapidly and clutters up the call stack, consuming cpu with it. This is called debouncing. Add a small cap in parallel with the switch. More on reddit.com
🌐 r/esp32
9
4
May 4, 2021
Raspberry Pi Interrupts Python (GPIO Library) - Stack Overflow
I have a little problem with my ... about micro-controllers I've learned that interrupts always trigger, no matter where the code is (but it was an actual microprocessor written in C). I found an "equivalent" in python, GPIO library.... More on stackoverflow.com
🌐 stackoverflow.com
c++ - How to handle GPIO interrupt-like handling in Linux userspace - Stack Overflow
The preferred way is usually to configure the interrupt with /sys/class/gpio/gpioN/edge and poll(2) for POLLPRI | POLLERR (important it's not POLLIN!) on /sys/class/gpio/gpioN/value. If your process is some "real-time" process that needs to handle the events in real time, consider decreasing it's niceness. You can even find some example ... More on stackoverflow.com
🌐 stackoverflow.com
GPIO interrupt example
I'm using the nRF51822 Beacon with S110 and the example ble_app_beacon as basic programm. I'm a newbie with the beacon, so maybe I have problem with the basics More on devzone.nordicsemi.com
🌐 devzone.nordicsemi.com
0
0
June 8, 2017
🌐
GitHub
github.com › Infineon › mtb-example-hal-gpio-interrupt
GitHub - Infineon/mtb-example-hal-gpio-interrupt: This example demonstrates how to configure a GPIO to generate an interrupt in PSoC 6 MCU.
This code example uses a GPIO interrupt to wake the Arm® Cortex®-M4 or Cortex®-M7 CPU from deepsleep. An LED is connected to an output pin; it is used for indicating the current state of the CPU.
Forked by 2 users
Languages   C 53.8% | Makefile 46.2% | C 53.8% | Makefile 46.2%
🌐
Reddit
reddit.com › r/esp32 › what are some practical use cases for gpio interrupts?
r/esp32 on Reddit: What are some practical use cases for GPIO Interrupts?
May 4, 2021 -

I've only had the esp32-s2 for a little bit and I've been playing with different ways of performing time-critical tasks. One of these involved reading a HIGH value when a push button is held down on a GPIO pin to go into a GPIO interrupt ISR. However, as long as you are holding the pin down it consumes too much CPU time and then the main watchdog thread throws an exception and restarts the esp32. This is by design it seems so the programmer can make the appropriate changes since it is not very good to have one thing taking all resources.

The way I circumvented this issue was to just use a timer-based interrupt to periodically poll the pins state to see whether it's being held or not at a very slow frequency (1ms). This way it doesn't consume too many cycles and throw the restart error. But it's made me wonder what practical use cases could you use the strict "GPIO Interrupt" feature. Maybe like a hall sensor or something? What have you used this for in your projects?

Also: is there a way I can simply trigger the GPIO interrupt from a purely binary HIGH/LOW change of state? The problem with using the rising edge or falling edge modes is that the incoming signal from the button is pulsed so it triggers very rapidly and clutters up the call stack, consuming cpu with it.

🌐
Microsoft Learn
learn.microsoft.com › en-us › windows-hardware › drivers › gpio › gpio-interrupts
GPIO Interrupts - Windows drivers | Microsoft Learn
March 26, 2025 - Some general-purpose I/O (GPIO) controller devices can configure their GPIO pins to function as interrupt request inputs. These interrupt request inputs are driven by peripheral devices that are physically connected to the GPIO pins.
🌐
Parthssharma
parthssharma.github.io › Pico › GPIOInterrupt.html
GPIO Interrupt
An interrupt can be generated for every GPIO pin in four scenarios: the GPIO is logical 1, the GPIO is logical 0, there is a falling edge or there is a rising edge. The resources for the project include the C SDK User Guide, the RP2040 Datasheet and Prof. Hunter's website.
🌐
RasPi.TV
raspi.tv › 2013 › how-to-use-interrupts-with-python-on-the-raspberry-pi-and-rpi-gpio-part-3
How to use interrupts with Python on the Raspberry Pi and RPi.GPIO – part 3
June 22, 2015 - Then you can run it with… sudo python interrupt3.py · There’s just one more thing. If you want to stop an event detection on a particular port, you can use the following command… GPIO.remove_event_detect(port_number)
Find elsewhere
🌐
DeepBlue
deepbluembedded.com › home › blog › stm32 external interrupt example lab
STM32 External Interrupt Example LAB – DeepBlue
January 20, 2024 - Configure GPIO Output Pin & Input ... · Measure the interrupt response time between event and output change ... Let it be A9 pin for example!...
Top answer
1 of 2
2

There are several things going on in your code. I suspect that what's really causing the problem is that you need to exit the interrupt handler before another interrupt callback can be triggered...but there is also a confusing mix of callback-based handlers and the GPIO.event_detected method.

I think you can simplify things by performing less manipulation of your interrupt configuration. Just have a state variable that starts at 0, increment it to 1 on the first interrupt, so the next time the interrupt method is called you know it's the second interrupt. No need to try setting multiple handlers like that.

Keeping in mind that I don't actually know what you're trying to do...I imagine something like this:

import RPi.GPIO as GPIO
import time

state = 0

GPIO.setmode(GPIO.BCM)
GPIO.setup(26, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(19, GPIO.IN, pull_up_down=GPIO.PUD_UP)


def interrupt_handler(channel):
    global state

    print("interrupt handler")

    if channel == 19:
        if state == 1:
            state = 0
            print("state reset by event on pin 19")
    elif channel == 26:
        if state == 0:
            state = 1
            print("state set by event on pin 26")


GPIO.add_event_detect(26, GPIO.RISING,
                      callback=interrupt_handler,
                      bouncetime=200)

GPIO.add_event_detect(19, GPIO.RISING,
                      callback=interrupt_handler,
                      bouncetime=200)


while (True):
    time.sleep(0)
2 of 2
0

That sleep(0) just causes the process to idle there while waiting for switch interrupts. Since nothing in there programmatically ends the process, doing a Ctl-C will stop it.

🌐
GitHub
gist.github.com › keriszafir › 37d598d6501214da58e0
gpio-interrupt - C routine for handling interrupts generated on GPIO · GitHub
gpio-interrupt - C routine for handling interrupts generated on GPIO · Raw · gpio-interrupt.c · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
🌐
Texas Instruments
software-dl.ti.com › mcu-plus-sdk › esd › AM62X › latest › exports › docs › api_guide_am62x › EXAMPLES_DRIVERS_GPIO_INPUT_INTERRUPT.html
AM62x MCU+ SDK: GPIO Input Interrupt
SK-AM62 or SK-AM62-LP-SK-EVM does not contain any push button connected to MCU GPIOs. M4F example using MCU_GPIO0_15 pin in the MCU_HEADER(J9) for generating GPIO interrupt.
🌐
Reconfigurable Computing Lab
labs.dese.iisc.ac.in › embeddedlab › tm4c123-gpio-port-interrupt-programming
TM4C123 GPIO Port Interrupt Programming | Embedded systems
Each ISER register can be used to enable 32 different types of interrupt sources. For example NVIC_EN0_R is used to enable the interrupt sources whose IRQ numbers are 0-31, similarly the interrupt sources whose IRQ numbers are 32-63 can be enabled by NVIC_EN1_R and so on.
🌐
Ti
dev.ti.com › tirex › explore › node
TI Drivers : GPIO Interrupts
{"role":"tirex","rootNodeDbId":"1","softwareNodePublicId":"AJrQUiceAYbtEIq1GixWhA","version":"4.24.0+202603092154","offline":false,"mode":"remoteserver","frontendConfig":{"enableSearchButton":false}}
🌐
Last Minute Engineers
lastminuteengineers.com › handling-esp32-gpio-interrupts-tutorial
Configuring & Handling ESP32 GPIO Interrupts In Arduino IDE
January 20, 2026 - Let’s look at a simple example to understand how interrupts work on the ESP32. We’ll create a simple project that counts how many times you press a button. For this project, you’ll connect a push button to GPIO 18 (D18) on the ESP32.
🌐
GitHub
github.com › Micro-Studios › Xilinx-GPIO-Interrupt › blob › master › GPIO_Interrupt.sdk › GPIO_Interrupt › src › helloworld.c
Xilinx-GPIO-Interrupt/GPIO_Interrupt.sdk/GPIO_Interrupt/src/helloworld.c at master · Micro-Studios/Xilinx-GPIO-Interrupt
It is a GPIO interrupt example for xilinx ZYNQ FPGA. - Xilinx-GPIO-Interrupt/GPIO_Interrupt.sdk/GPIO_Interrupt/src/helloworld.c at master · Micro-Studios/Xilinx-GPIO-Interrupt
Author   Micro-Studios
🌐
Nordic DevZone
devzone.nordicsemi.com › f › nordic-q-a › 22628 › gpio-interrupt-example
GPIO interrupt example - Nordic Q&A - Nordic DevZone - Nordic DevZone
June 8, 2017 - There is a Pin Change Interrupt example in the SDK. This use the GPIOTE driver, but it is also possible to GPIO sensing to wake up from sleep.
🌐
Microchip
onlinedocs.microchip.com › oxy › GUID-89EADA66-E7AA-4CE9-90FD-CB4FEB9380EF-en-US-4 › GUID-1CCC7BEB-56CA-4EDC-87B7-A765C6A657AE.html
3 Using GPIO Interrupts - Microchip Online Docs
Getting Started with GPIO on PIC18 TB3284 · This example consists of toggling the output pin value when an IOC is detected on the input pin. An interrupt can be generated by detecting a signal at the port pin that has either a rising or falling edge.
🌐
Yurovsky
yurovsky.github.io › 2014 › 10 › 10 › linux-uio-gpio-interrupt.html
Handling GPIO interrupts in userspace on Linux with UIO
That said, for a GPIO interrupt we need an interrupt parent (GPIO port) and pin. In this example I used an Atmel SAM9 SoC and its Port A pin 13.