Looking for advice - Wipy & Expansion Board power saving.
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.
@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.
rcolistete last edited by
Another option is "pycom.wifi_on_boot(False)", which is effective after boot/reset.
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.pyshould 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.