How to reduce power consumption on GPy?

  • Hello! I am building a water temperature sensor using a PyCom GPy on the Makr board, but I am not very impressed with the battery performance so far.

    I am using a 6700mAh power bank to power everything, but only gets around 17 hours of battery life. The code is set up so that it sends a request to a web server every 6 minutes, with machine.idle() while waiting. I am connecting via WiFi to an access point I have set up nearby.

    I have tried to decrease the time between updates, and yes, it does make a difference, but I am still not satisfied. Here is what I have done so far in my code to save power:

    • Using machine.idle() before every time.sleep() in the code
    • Deinit the Bluetooth radio in

    My questions are how I can reduce power consumption even more, preferably to a level where I would only have to recharge and replace the battery once every day or every 2 days. Using LTE isn´t really an option for me since my carrier doesn't support LTE Cat M1 at the moment.
    I am also using the LED to show status and the heartbeat while idle. I can remove that, but I am just thinking how much it affecting the battery life.

    Also, another issue I have is that when my power bank runs out of battery, I have a backup battery connected on the 2-pin battery connector on the Makr board, but it seems like the board detects some current from the power bank that is too low to power the GPy, but that still doesn´t make it switch to the secondary battery until the USB cable is unplugged from the nearly-dead power bank (too dead to power the GPy). Can you somehow route or change the power source the GPy uses?

  • @nwjlyons It improved drastically, from 17 hours to 2-3 days.
    Definitely use deepsleep!

  • @techykermit what kind of battery life did you get once you used deepsleep? I am looking at creating a similar project except using LTE instead of wifi to transmit a request every five mins.

  • @robert-hh That´s what I assumed, thank you so much!

  • @techykermit After deepsleep the device performs a soft reset with all code. Assuming you do init WiFi during that, it will be done by that. There is a flag you can check whether the device went though a hard reset or reset after deepsleep. The flag is returned by machine.reset_cause(). (see

  • @robert-hh Do I have to reconnect to the WiFi network after a deepsleep?

  • @robert-hh Okay, thank you! I found the documentation about this to be a bit unclear, but maybe it was just me looking at the wrong place. Thanks!

  • @techykermit You can use machine.deepsleep(), which powers the device down. Recovery from deepsleep is equivalent to a boot after reset. Take care to deinit LTE before going to deepsleep.
    Machine.idle() does not save any power. It just tells the underlying RTOS that you code is not busy.
    There are quite a few posts in this forum about this topic.

Pycom on Twitter