Saving power

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Posts: 21
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)  # Disable access point
sta_if = network.WLAN(network.STA_IF)  # Disable station interface
Then in you 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)
    print("Low power !!)
    # Here the start of your program, running at ~ 15mA
    # for example:
    import myapp

# 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)

Post Reply