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

    Looking for advice - Wipy & Expansion Board power saving.

    Scheduled Pinned Locked Moved WiPy 2&3
    4 Posts 4 Posters 65 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
      jgomez
      last edited by

      Hello, beginner here.

      I'm starting an IoT project using WiPy and the expansion board, and I would like to know which options would be the best ones for me regarding power consumption.

      What I'm trying to do right now is sending a message every 15 minutes via MQTT (Adafruit IO). Between these 15 minutes the microcontroller should hibernate in order to save power. With that in mind:

      • I have found machine.deepsleep() and machine.lightsleep(), but it seems these functions act as a reset basically, meaning the microcontroller would have to start reading the code from the scratch over and over.

      Are there some other options that can lower the consumption in a significant way? I have also read that you can turn off WiFi in the meantime, but I don't know how impactful that may be.

      A 1 Reply Last reply Reply Quote 0
      • A Offline
        agotsis @jgomez
        last edited by

        @jgomez Actually machine.deepsleep() is the best way to save power with WiPy modules, and it operates exactly as you say (maybe you are confused because you come from Arduino world?).
        So, your code in main.py should be like this:

        import <libraryX>
        import <libraryY>
        
        # core functionality
        # connect to WiFi network
        # establish an mqtt connection and publish a message
        # close mqtt connection
        # disconnect from WiFi
        
        machine.deepsleep(15*60*1000) # sleep for 15 mins
        

        So, each time the module wakes up the whole process will be repeated.

        Now, theoretically you don't need to disable WiFi before going to deep sleep as it goes together with the main functionalities (this is not the case with the NB-IoT modules though), but in any case you can use the following snippet just before deep sleep, to be sure:

        from network import WLAN
        WLAN().deinit()
        

        If you get rid of the expansion board and use WiPy with a breadboard, during deep sleep you should measure something like 17-20 μΑ, whereas during normal operation 100-120 mA.

        1 Reply Last reply Reply Quote 2
        • rcolisteteR Offline
          rcolistete
          last edited by

          Another option is "pycom.wifi_on_boot(False)", which is effective after boot/reset.

          My "MicroPython Samples". My "MicroPython Firmwares" with many options (double precision, ulab, etc).

          1 Reply Last reply Reply Quote 1
          • R Offline
            railmonitor
            last edited by

            @jgomez Deepsleep is the best option for powersaving since you can get down to a uA level of consumption. When i use lightsleep on my FiPy + Pysense, and remember to disable all network capabilities and sensors on the board, i get a consumption of about 6.8 mA.

            Lightsleep does however not "reset" the FiPy, it remembers where it went to sleep, and starts from there. So lightsleep is great, if you want to be able to save power, but you still need the capability to wake-up fast without re-booting.

            So if a project requires that your WiPy must be sleeping, unless it gets an interrupt, and then must be able to quickly wake up to, lets say, start sampling from a sensor immediately, then lightsleep is the way to go. Then if you know that there are longer periods with inactivity, you could always time it so thats when it goes into deepsleep mode.

            1 Reply Last reply Reply Quote 2

            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