ISR to wake from deepsleep?

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
flynnguy
Posts: 4
Joined: Mon Aug 29, 2016 7:03 pm

ISR to wake from deepsleep?

Post by flynnguy » Mon Aug 29, 2016 7:08 pm

So I've read up on deepsleep mode and see I can wake it up from a timer, but can I wake it up from an ISR?

I'd like to make it so when a button is pressed, it wakes up, hits an http endpoint and then goes back to deepsleep to hopefully save batter. Is this possible? I have the latter 1/2 working and I think I could create an interrupt to call a callback but ideally this would run on a battery so I'd like to conserve battery power as much as possible.

User avatar
deshipu
Posts: 1388
Joined: Thu May 28, 2015 5:54 pm

Re: ISR to wake from deepsleep?

Post by deshipu » Mon Aug 29, 2016 8:54 pm

Sure, just connect your button to the RST pin. When you press it, it will reset the board and bring it out of deep sleep.

markxr
Posts: 62
Joined: Wed Jun 01, 2016 3:41 pm

Re: ISR to wake from deepsleep?

Post by markxr » Mon Aug 29, 2016 10:01 pm

You can check the machine.reset_cause() to check whether the reset button has actually been pressed, or whether something else happened (e.g. power-on)

flynnguy
Posts: 4
Joined: Mon Aug 29, 2016 7:03 pm

Re: ISR to wake from deepsleep?

Post by flynnguy » Tue Aug 30, 2016 12:19 am

Thank you all, that worked beautifully, and easy too!

torwag
Posts: 220
Joined: Fri Dec 13, 2013 9:25 am

Re: ISR to wake from deepsleep?

Post by torwag » Tue Aug 30, 2016 8:02 am

I wonder, those kind of application might not need a deep-sleep at all.
With a bit external circuitry, one could use a SR latch to catch the button press, which actually switches on the esp8266, and more important the possible power hungry LDO, which otherwise might consume more power then a deep-sleeping uC. The esp would start up, connect to the wifi network, runs the code on boot.py, which actually contains the entire logic, might run some clearances and shutdown stuff, and then reset the latch and hence its own LDO. Thus, the entire circuit consumes more or less zero power in its hibernation state.

Post Reply