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

    machine.idle vs machine.sleep

    Scheduled Pinned Locked Moved Firmware
    wipylopy
    6 Posts 3 Posters 3.0k 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.
    • E Offline
      Eric24
      last edited by

      What is the difference between these calls? The docs only mention machine.idle, but help(machine) shows both.

      L 1 Reply Last reply Reply Quote 1
      • L Offline
        livius @Eric24
        last edited by

        @Eric24
        do you mean
        machine.deepsleep ?

        from docs - https://docs.pycom.io/pycom_esp32/library/machine.html

        machine.idle()
        Gates the clock to the CPU, useful to reduce power consumption at any time during short or long periods. Peripherals continue working and execution resumes as soon as any interrupt is triggered (on many ports this includes system timer interrupt occurring at regular intervals on the order of millisecond).

        machine.deepsleep([time_ms])
        Stops the CPU and all peripherals (including networking interfaces, if any). Execution is resumed from the main script, just as with a reset. If a value in milliseconds is given then the device will wake up after that period of time, otherwise it will remain in deep sleep until the reset button is pressed

        as described above idle only reduce power consumption
        but deepsleep "restart" the board - near the same as pressing reset button

        think about people first, then computers

        E 1 Reply Last reply Reply Quote 0
        • E Offline
          Eric24 @livius
          last edited by

          @livius Thanks, but I actually mean machine.sleep(). Maybe it does nothing, but it is a valid function on the machine object, per help(machine).

          robert-hhR 1 Reply Last reply Reply Quote 0
          • robert-hhR Offline
            robert-hh @Eric24
            last edited by

            @Eric24 machine.sleep() does nothing. Here is the code:

            STATIC mp_obj_t machine_sleep (void) {
                // TODO
                return mp_const_none;
            }
            
            E 1 Reply Last reply Reply Quote 1
            • E Offline
              Eric24 @robert-hh
              last edited by

              @robert-hh Aha! That explains it. By the way, is that code you're showing available to look at somewhere (having it would probably answer a lot of questions and cut down on stupid questions)?

              L 1 Reply Last reply Reply Quote 0
              • L Offline
                livius @Eric24
                last edited by

                @Eric24
                you have here whole source code
                https://github.com/pycom/pycom-micropython-sigfox

                think about people first, then computers

                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