Saving power

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
jomas
Posts: 59
Joined: Mon Dec 25, 2017 1:48 pm
Location: Netherlands

Re: Saving power

Post by jomas » Wed Nov 14, 2018 9:06 pm

If you want to switch off the RF circuit, the only thing you have to do is call 'system_deep_sleep_set_option' with value 4 and restart the esp via deepsleep.

Luckiliy you don't need to compile a new image because this function is already implemented in the deepsleep function of module esp.
(don't use deepsleep from machine). This parameter is not documented but if you look at the source code you see system_deep_sleep_set_option is called with the second parameter of deepsleep..

So here are the steps to switch of the RF circuit while processor is running normally ( this means at about 15 mA)

1. Run this code once (it switches off the RF station/ap and will store these settings)

Code: Select all

import network
ap = network.WLAN(network.AP_IF)
ap.active(False)  # Disable access point
sta_if = network.WLAN(network.STA_IF)
sta_if.active(False)  # Disable station interface
Then in you main.py start with:

Code: Select all

from esp import deepsleep
from machine import reset_cause, DEEPSLEEP_RESET

if not reset_cause() == DEEPSLEEP_RESET:
    # call 'system_deep_sleep_set_option' with value 4 and go to sleep for 1 uS 
    deepsleep(1, 4)
else:
    print("Low power !!)
    # Here the start of your program, running at ~ 15mA
    # for example:
    import myapp
    myapp.run()

# Do not put code here otherwise deepsleep will not be called !!

Then power up your esp8266 or reset it.
One thing to remember is that you have to connect the reset pin with gpio16 (to wake up the processor after deepsleep)

holdenweb
Posts: 9
Joined: Wed Mar 09, 2016 12:40 pm

Re: Saving power

Post by holdenweb » Sun Jan 17, 2021 6:17 pm

I wonder if someone could report expected drops in power consumption achievable. Is this still the best ESP8266 solution?

Post Reply