ESP32 "WifFi Sleep"

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
Posts: 13
Joined: Sun Sep 22, 2019 8:43 pm

ESP32 "WifFi Sleep"

Post by groger57 » Thu Nov 28, 2019 12:40 am


I was reading the Expressif documentation, please refer to this page: ... modes.html

It says this, please note the bold text

WiFi/BT and sleep modes
In deep sleep and light sleep modes, wireless peripherals are powered down. Before entering deep sleep or light sleep modes, applications must disable WiFi and BT using appropriate calls (esp_bluedroid_disable(), esp_bt_controller_disable(), esp_wifi_stop()). WiFi and BT connections will not be maintained in deep sleep or light sleep, even if these functions are not called.

If WiFi connection needs to be maintained, enable WiFi modem sleep, and enable automatic light sleep feature (see Power Management APIs). This will allow the system to wake up from sleep automatically when required by WiFi driver, thereby maintaining connection to the AP.

Is this available in the current (latest) firmware revision of the ESP32-WROOM-32U device? If not, how can it be implemented, or when will it be implemented?

Reason: I use the device in AP mode, that works. A remote PC connects to it, that works fine. But after that, I want the ESP32 to reduce power without losing the WiFi connection, based on the activity of a GPIO high/low. When the pin goes HIGH, I want to begin transmitting.
Some of these issues are not easy to solve, seems like there's a disconnect between what the device can do (Micropython) and what Expressif has implemented down below. Is this feature one of those things?

Incidentally, I set down and running at minimal CPU speed, etc, but still it consumes about 130mA while not sending/receiving. Too much!

Thanks for any information and help on this!

User avatar
Posts: 2072
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia

Re: ESP32 "WifFi Sleep"

Post by jimmo » Sun Dec 01, 2019 11:28 am

Unfortunately most of what you're looking for isn't currently available in MicroPython but would not be difficult to add. Here are some notes:
groger57 wrote:
Thu Nov 28, 2019 12:40 am
enable automatic light sleep feature (see Power Management APIs)
Light sleep requires CONFIG_FREERTOS_USE_TICKLESS_IDLE ... kless-idle (which is not currently enabled in MicroPython).

It then requires `esp_pm_config_esp32_t.light_sleep_enable` to be set for the call to esp_pm_configure (see esp32/modmachine.c for where we call this with that field set to false). I guess you'll need a new Python-level API for this.
groger57 wrote:
Thu Nov 28, 2019 12:40 am
enable WiFi modem sleep
This is done via `esp_wifi_set_ps` which will need a new Python-level API also.

See ... power_save which uses both of these features.

Post Reply