Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Resetting from DeepSleep wake

    Scheduled Pinned Locked Moved SiPy
    deepsleepsipy
    3 Posts 2 Posters 989 Views 3 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B Offline
      bradnz
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • bmarkusB Offline
        bmarkus
        last edited by bmarkus

        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

        1 Reply Last reply Reply Quote 0
        • B Offline
          bradnz
          last edited by

          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?

          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • 1 / 1
          • First post
            Last post

          Pycom on Twitter

          Pycom