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

    How to use deep sleep in a loop!!!

    Scheduled Pinned Locked Moved Discussion
    3 Posts 3 Posters 210 Views 4 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.
    • J Offline
      Jacobcullen
      last edited by livius

      Hi all,

      I have a LoPy4 with a pytrack.
      I have a loop that essentially looks like this:

      init_timer = time.time()
      while True:
          final_timer = time.time()
          diff = final_timer - init_timer
              if diff > 300:
                  do some stuff here
                  init_timer = time.time()
      I'd like to incorporate this:
      machine.deepsleep(300*1000)
      

      into the code to make it deep sleep while it's waiting for those 5 minutes but it doesn't seem to be working.
      Can anyone help with this?

      J 1 Reply Last reply Reply Quote 0
      • J Offline
        jcaron @Jacobcullen
        last edited by

        @Jacobcullen deep sleep will reset the board and it will start again at the top of boot.py and main.py. No need for a loop, but you need to find a way to save any variables / state as all python state will be reset.

        1 Reply Last reply Reply Quote 1
        • P Offline
          Panis lenin Banned
          last edited by

          This post is deleted!
          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