Page 1 of 1

deepsleep wake with external interrupt

Posted: Thu Jan 03, 2019 6:29 pm
by GryKyo
Hoping this will be of some help...

I struggled over much online help to find code that worked for deepsleep and external wake interrupt.

# magnetic reed switch on IO13
reed = machine.Pin(13, mode = machine.Pin.IN, pull = machine.Pin.PULL_DOWN)
# an external interrupt to wake from sleep if the door opens
reed.irq(trigger=machine.Pin.WAKE_LOW, wake=machine.DEEPSLEEP)
machine.deepsleep()

...this works well. I can pass a wake timer value in ms to the deepsleep() function or wake on interrupt.

Garry