# Micropython to hanlde hardware interrupts for gpio

**URL:** <https://forums.digi.com/t/micropython-to-hanlde-hardware-interrupts-for-gpio/28738>\
**Category:** XBee - Zigbee\
**Tags:** xbee\
**Created:** [December 8, 2023, 8:34pm UTC](https://forums.digi.com/t/micropython-to-hanlde-hardware-interrupts-for-gpio/28738 "2023-12-08T20:34:44Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Reacquire5985](https://avatars.discourse-cdn.com/v4/letter/r/c0e974/32.png) [@Reacquire5985](https://forums.digi.com/u/Reacquire5985)\
**Post date:** [December 8, 2023, 8:34pm UTC](https://forums.digi.com/t/micropython-to-hanlde-hardware-interrupts-for-gpio/28738/1 "2023-12-08T20:34:45Z")

</div>

I’m looking to implement interrupt driven code for a button connected via the gipo pins. Is it possible to handle hardware interrupts for gpio in micropython or is it only possible to wake from sleep off of gpio? I haven’t seen any examples that show how to use micropython to write interrupt service routines that are triggered from edge triggers on gpio.

---

<div class="post-metadata">

**Author:** ![ROCHA\_R](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/rocha_r/32/1441_2.png) [@ROCHA\_R](https://forums.digi.com/u/ROCHA_R)\
**Post date:** [December 10, 2023, 3:58pm UTC](https://forums.digi.com/t/micropython-to-hanlde-hardware-interrupts-for-gpio/28738/2 "2023-12-10T15:58:52Z")

</div>

I see you going through something similar to what I went through. I’m an electrical engineer and as my project became more complex I came across the information that Xbee 3.0 in micropython mode did not support the 1-wire library, asynchronous library and hardware interrupts (irq). There are other ways to overcome the absence of these characteristics.

---

<div class="post-metadata">

**Author:** ![pedroc](https://avatars.discourse-cdn.com/v4/letter/p/d6d6ee/32.png) [@pedroc](https://forums.digi.com/u/pedroc)\
**Post date:** [January 10, 2024, 1:27pm UTC](https://forums.digi.com/t/micropython-to-hanlde-hardware-interrupts-for-gpio/28738/3 "2024-01-10T13:27:21Z")

</div>

Hi! did you get any resolution on this? I have the exact same issue haha

---

<div class="post-metadata">

**Author:** ![ROCHA\_R](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/rocha_r/32/1441_2.png) [@ROCHA\_R](https://forums.digi.com/u/ROCHA_R)\
**Post date:** [January 10, 2024, 11:37pm UTC](https://forums.digi.com/t/micropython-to-hanlde-hardware-interrupts-for-gpio/28738/4 "2024-01-10T23:37:58Z")

</div>

Answering your inquiry. I posted this image below because I thought it was relevant to your question. I believe this topic helped me to persist on my learning path.

 ![image](https://us1.discourse-cdn.com/flex016/uploads/digi/original/2X/e/e69ef9ff696cbc8d13fa36d0e4b169c6f0a7b088.png)

> [https://forums.digi.com/t/finding-libraries-to-control-neopixel-programmable-led-strips/27417/12](https://forums.digi.com/t/finding-libraries-to-control-neopixel-programmable-led-strips/27417/12)  
> @miadrew

About “use an Intermediary Microcontroller:”  
I’m working on this kind of solution for my own.  
In the first version of PCB design I used UART protocol and experienced unsatisfactory results. The image below show my second version of PCB layout . This time the approach is 100% SPI protocol, I will soon validate the level of reliability in my project. 🤔 My goal is handle gpio interrupts in microython.

 ![desk](https://us1.discourse-cdn.com/flex016/uploads/digi/original/2X/3/319f0556e4f825cfe0080a919713079d4d532f9a.jpeg)

If you want more information, just contact me privately.

2024-01-10T23:37:00Z  
timezone: UTC-03:00

---

<div class="post-metadata">

**Author:** ![mvut](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/mvut/32/31_2.png) [@mvut](https://forums.digi.com/u/mvut)\
**Post date:** [January 11, 2024, 2:00pm UTC](https://forums.digi.com/t/micropython-to-hanlde-hardware-interrupts-for-gpio/28738/5 "2024-01-11T14:00:07Z")

</div>

@Reacquire5985 Yes, Digi does have sample Micro Python code that will allow you to push a button and trigger some code to perform a function. I would suggest looking at the Sample apps in the PyCharm plugin.

---

<div class="post-metadata">

**Author:** ![pedroc](https://avatars.discourse-cdn.com/v4/letter/p/d6d6ee/32.png) [@pedroc](https://forums.digi.com/u/pedroc)\
**Post date:** [January 24, 2024, 8:40pm UTC](https://forums.digi.com/t/micropython-to-hanlde-hardware-interrupts-for-gpio/28738/6 "2024-01-24T20:40:22Z")

</div>

Thanks! and yes, I also opted to use an external microcontroller to implement the interrupts I required. Very strange that Xbee doesn’t have these basic features.

---

<div class="post-metadata">

**Author:** ![indrinovia88](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.digi.com/indrinovia88/32/3911_2.png) [@indrinovia88](https://forums.digi.com/u/indrinovia88)\
**Post date:** [January 30, 2024, 5:41am UTC](https://forums.digi.com/t/micropython-to-hanlde-hardware-interrupts-for-gpio/28738/7 "2024-01-30T05:41:34Z")

</div>

nice, this is good articel
