Resetting from DeepSleep wake



  • Re: Deepsleep stops execution of main

    The above link suggests that deepsleep works like a rest. So essentially the device powers down and restarts?

    If this is the case, can I please explain what I want to do and see if someone can provide some thoughts as to how I can do it?

    I would like to have my device go to DeepSleep for 30mins. At the end of 30mins, read the input of a analogue pin, send it via sigfox, and then go back to sleep. One of the other variables that I would like to send though is the status of a GPIO pin, either high or low. Now this GPIO pin can go high or low at any point in time, so I was going to tie this to pin17 and if it goes low, wakes the device, sets a variable (increments it) to send, and then goes back to Deepsleep from where it came from. Now the challenge I can see is that if a wake from a DeepSleep causes a start from the beginning, I will lose the value of the variable that I am incrementing. Would this be right? And how would I know how long the device was in DeepSleep for before it was woken so I can be sure that I can continue from the remaining time?

    I hope this makes sense?

    Thanks
    Brad



  • Ok, thanks for this - didnt see that one. And what are your thoughts on making sure i can resume the deepsleep. For thi, I really need to be able to send the data every 30mins. If its getting restarted because of a deepsleep wake, how do I know how far into the deepsleep the device was so that I dont get a wake 29mins into the deepsleep, and then go to sleep again for another 30mins once the wake is processed? I hope this makes sense. Its almost like I need to write the remaining time to a variable, save the variable in NVRAM, and then call that once the device has been reset. What do you think?



  • You can use nvs_set() and nvs_get() methods to save and retrieve your counter after deep sleep, see

    https://docs.pycom.io/chapter/firmwareapi/pycom/pycom.html


Log in to reply
 

Pycom on Twitter