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.
ISR to wake from deepsleep?
Re: ISR to wake from deepsleep?
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.
Re: ISR to wake from deepsleep?
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)
Re: ISR to wake from deepsleep?
Thank you all, that worked beautifully, and easy too!
Re: ISR to wake from deepsleep?
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.
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.