I have an application where I want to sleep for X amount of time. If an interrupt comes in I want to proceed from the instruction after the sleep command. Currently it runs the int handler and then finishes the sleep timer. Is there a way to do this? The goal is to use as little power as possible during sleep for battery life.
Ideally I need to have an external int wake up the deice from deepsleep. Any plans to make this happen?
BetterAuto Pybytes Beta last edited by
Rock and roll! Good timing.
jmarcelino last edited by
It is now, was added in firmware 1.7.2:
BetterAuto Pybytes Beta last edited by BetterAuto
@jmarcelino said in Interrupt Sleep:
Waking up from deep sleep using pins isn't possible on the current version.
Is this still not possible? I see it in the docs.
jmarcelino last edited by
I'm not sure the deep sleep mode will work for your purposes. There will always be some initialisation time (a few seconds) because most of the contents of the RAM are lost when entering deep sleep (at least for now, maybe it will change in future modules which have external RAM)
It should be fairly constant number so you could try to account for it in your time calculation.
I guess light sleep mode would work (~ 0.8 mA, only CPU is paused ) but that's not yet available on ESP-IDF and consequently neither on MicroPython.
Thanks. I've been trying to avoid building the FW but looks like I need to get to that soon. How about just stopping the time.sleep(30) command? I don't want to put a bunch of logic in the ISR. I currently set a flag in the ISR and then process it in my main loop but I have for to for the sleep time to expire before I can process it. I want to time how long a button has been pressed and act accordingly but can't do that unless I can break out of the sleep command.
jmarcelino last edited by jmarcelino
That's not really possible yet.
Only sleep mode currently available is deep sleep which restarts the board and your script from the beginning. As a workaround you could store your state in Flash before entering sleep and then restore at the start but it's not automatic and there will be a few seconds startup delay.
Waking up from deep sleep using pins isn't possible on the current version. There is however a pull request to implement that so if you're willing to build a custom firmware image you could try it: https://github.com/pycom/pycom-micropython-sigfox/pull/3
The firmware is gaining features all the time and I guess these will come eventually. The chip and underlying ESP-IDF C stack support it.