Can't use IRQ on any pins other than 0 & 2

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
Scarsz
Posts: 6
Joined: Sat Nov 03, 2018 8:03 am

Can't use IRQ on any pins other than 0 & 2

Post by Scarsz » Sat Nov 03, 2018 8:17 am

I'm trying to prototype a script for a future controller for my house's gate. I have reed switches that I want to wire into the ESP8266 to be able to tell whether the gate is open/opening/closed/closing. I saw that MicroPython supports IRQ thus I tried implementing that originally on pins 4 and 5 which didn't work and made me waste a few hours trying to debug it. The only pins that I'm able to use IRQ reliably on are 0 and 2. I have a Lolin v3 board with the latest firmware. Any pointers?

def closedCallback(_): print('closedCallback called') # this never appears in the serial console when repeatedly jumping pin D1/GPIO5 to GND
closedPin = Pin(5, Pin.IN)
closedPin.irq(trigger=Pin.IRQ_RISING | Pin.IRQ_FALLING, handler=lambda p: micropython.schedule(closedCallback, 0))
Last edited by Scarsz on Sat Nov 03, 2018 7:51 pm, edited 2 times in total.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Can't use IRQ on any pins other than 0 & 2

Post by pythoncoder » Sat Nov 03, 2018 11:10 am

I have an application which has an IRQ on pin 5 which works correctly. This is on the reference board. Have you ensured that the pin is pulled up? Pins 0 and 2 have internal pullups (on the reference board) which may explain your results.
Peter Hinch
Index to my micropython libraries.

Scarsz
Posts: 6
Joined: Sat Nov 03, 2018 8:03 am

Re: Can't use IRQ on any pins other than 0 & 2

Post by Scarsz » Sat Nov 03, 2018 7:50 pm

Ah alright, that makes sense. I'm still decently new to using micro-controllers for little projects. What resistance would you suggest I buy a strip of for usage as pull-ups? Would 5k do the trick nicely?

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Can't use IRQ on any pins other than 0 & 2

Post by pythoncoder » Sun Nov 04, 2018 6:31 am

Yes 5KΩ or thereabouts is fine - the resistor should, of course, be to the 3.3V supply. But you can also define Pin objects with an internal pull-up, see the docs. The internal resistor has a higher value, but will work OK for switches connected to the board by reasonably short wires.
Peter Hinch
Index to my micropython libraries.

Post Reply