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

    Sleep Mode Description

    Scheduled Pinned Locked Moved Discussion
    deepsleep
    7 Posts 3 Posters 791 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.
    • M Offline
      misterlisty
      last edited by

      How does sleep work, help doc doesn't explain it? When the device goes to sleep, what memory is retained? Does it continue from where it left off or restarts boot & main. Did I miss the doco for this?

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

        @misterlisty If you mean deep sleep, in all cases, all CPU memory and CPU state is lost, and on wake-up it's like the module was just powered on.

        This is in the docs, though it's perhaps not that clear.

        For machine.deepsleep:

        https://docs.pycom.io/firmwareapi/pycom/machine/#machinedeepsleeptimems

        Stops the CPU and all peripherals, including the networking interfaces (except for LTE). Execution is resumed from the main script, just as with a reset.

        Note that at the ESP32 level the RTC domain including its memory is kept active, but there's no support for that at the micropython level.

        In the case of Pysense/Pytrack/Deep Sleep Shield-controlled deep sleep, it's even worse, as power to the ESP32 is cut.

        M 1 Reply Last reply Reply Quote 1
        • P Offline
          Paul Thornton
          last edited by

          The wording on that isnt brilliant. but yes. it restarts from the top of main.py again. ill update the docs to be clearer

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

            @paul-thornton To be precise, it actually starts from the top of boot.py :-)

            While you're in the docs, I don't think the read_battery_voltage method for the Pysense/Pytrack/etc. is in the docs, you may want to add that as well.

            P 1 Reply Last reply Reply Quote 1
            • M Offline
              misterlisty @jcaron
              last edited by

              From what i read above, it would also restart boot.py?

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

                @misterlisty Yes, it acts exactly as on a power on, it executes boot.py then main.py.

                The only way to know whether it's a power on or a wake from sleep (and what the reason for the wake up was) is to call machine.wake_reason.

                The possible reasons are listed in the constants at the bottom of the page: machine.PWRON_WAKE, machine.PIN_WAKE, machine.RTC_WAKE, machine.ULP_WAKE.

                1 Reply Last reply Reply Quote 1
                • P Offline
                  Paul Thornton @jcaron
                  last edited by

                  @jcaron said in Sleep Mode Description:

                  @paul-thornton To be precise, it actually starts from the top of boot.py :-)
                  While you're in the docs, I don't think the read_battery_voltage method for the Pysense/Pytrack/etc. is in the docs, you may want to add that as well.

                  Thanks ill get this added today if its missing.

                  1 Reply Last reply Reply Quote 1

                  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