deepsleep wake with external interrupt

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
GryKyo
Posts: 15
Joined: Sat Dec 15, 2018 12:43 am

deepsleep wake with external interrupt

Post by GryKyo » Thu Jan 03, 2019 6:29 pm

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

Post Reply