ESP32 - Auto Light Sleep (arduino-IDF)?

Hi all,

This is my first post so take it easy on me XD.

I’ve been surfing the internet looking for information on putting the esp32 into automatic light sleep while maintaining a WiFi connection. I know this has been done using the ESP-IDF (esp-idf/power_save.c at master · espressif/esp-idf · GitHub), but my entire project has already been built in arduino framework.

I came across the esp_pm.h library and was hoping to use esp_pm_configure() with auto light sleep enabled.

Has anyone had some success with this or is it simply not supported yet?

thanks for your help in advance

@ivankravets Hi Ivan, was hoping you could weigh in on this

The function is also available with Arduino-ESP32 since it’s a function included from the SDK.

However, I’m not sure if FreeRTOS is configured in tickless mode, as that is needed for the light-sleep.

This issue seems to indicate that it’s not enabled, but you should double-check it by writing a firmware which outputs whether CONFIG_FREERTOS_USE_TICKLESS_IDLE is defined to a value or not.

Then again, you can try and use Arduino as ESP-IDF component to still have a configurable ESP-IDF base (in which you can then e.g. reconfigure FreeRTOS) while still compiling the Arduino core and thereby enabling your code to run without any modifications to it.

thanks for the reply, and yes the library does exist in the arduino framework, it just never seems to be happy, either ill get ESP_ERR_NOT_SUPPORTED when calling config or ill get complaints about the idle time while compiling.

My build flags:


Adding the configuration flags in an Arduino-only build does not enable it, because the underlying SDK (ESP-IDF) was compiled once with a sdkconfig and is linked via binary libraries. And there it was, disabled

Have you tried it with the above linked Arduino as ESP-IDF component and a modified sdkconfig to enable those changes?

@maxgerhardt I have been trying to use the example project espidf-arduino-blink and yes i can now use arduino APIs, however im having an issue with #include <ESPAsyncWebServer.h>.

These are the includes i added to the example project:

and i get the following errors on build:

I have gone and tweaked the ESP-IDF Arduino blink project and have tried to implement both modem sleep and auto light sleep. I get confirmation via serial that both have indeed been enabled…yet i see no difference in power consumption. In fact no matter what i do, I cant seem to get below 45mA current draw at 3.3V


ø[00]øx€øxøxø[00]€[00]xx[00]x[00][00]øxxxø€øø[00]øøx[00]€xøxø[00]€[00]øø[00]øøx[00]€øø€ø€€€€€xøx€€[00]€[00]x€ø€[00]€xx[00]€boot: ## Label            Usage          Type ST Offset   Length[1B][0m
[1B][0;32mI (67) boot:  0 nvs              WiFi data        01 02 00009000 00006000[1B][0m
[1B][0;32mI (75) boot:  1 phy_init         RF data          01 01 0000f000 00001000[1B][0m
[1B][0;32mI (82) boot:  2 factory          factory app      00 00 00010000 00100000[1B][0m
[1B][0;32mI (90) boot: End of partition table[1B][0m
[1B][0;32mI (94) boot_comm: chip revision: 1, min. application chip revision: 0[1B][0m
[1B][0;32mI (101) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x19b4c (105292) map[1B][0m
[1B][0;32mI (148) esp_image: segment 1: paddr=0x00029b74 vaddr=0x3ffb0000 size=0x0354c ( 13644) load[1B][0m
[1B][0;32mI (154) esp_image: segment 2: paddr=0x0002d0c8 vaddr=0x40080000 size=0x00400 (  1024) load[1B][0m
[1B][0;32mI (155) esp_image: segment 3: paddr=0x0002d4d0 vaddr=0x40080400 size=0x02b40 ( 11072) load[1B][0m
[1B][0;32mI (168) esp_image: segment 4: paddr=0x00030018 vaddr=0x400d0018 size=0x6c974 (444788) map[1B][0m
[1B][0;32mI (331) esp_image: segment 5: paddr=0x0009c994 vaddr=0x40082f40 size=0x13a54 ( 80468) load[1B][0m
[1B][0;32mI (379) boot: Loaded app from partition at offset 0x10000[1B][0m
[1B][0;32mI (379) boot: Disabling RNG early entropy source...[1B][0m
[1B][0;32mI (380) cpu_start: Pro cpu up.[1B][0m
[1B][0;32mI (383) cpu_start: Application information:[1B][0m
[1B][0;32mI (388) cpu_start: Project name:     SmartLockV2[1B][0m
[1B][0;32mI (394) cpu_start: App version:      1[1B][0m
[1B][0;32mI (398) cpu_start: Compile time:     May 26 2020 10:48:49[1B][0m
[1B][0;32mI (404) cpu_start: ELF file SHA256:  284f489a85a5fd6c...[1B][0m
[1B][0;32mI (410) cpu_start: ESP-IDF:          HEAD-HASH-NOTFOUND[1B][0m
[1B][0;32mI (416) cpu_start: Starting app cpu, entry point is 0x40081720[1B][0m
[1B][0;32mI (0) cpu_start: App cpu up.[1B][0m
[1B][0;32mI (426) heap_init: Initializing. RAM available for dynamic allocation:[1B][0m
[1B][0;32mI (433) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM[1B][0m
[1B][0;32mI (439) heap_init: At 3FFB9848 len 000267B8 (153 KiB): DRAM[1B][0m
[1B][0;32mI (446) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM[1B][0m
[1B][0;32mI (452) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM[1B][0m
[1B][0;32mI (458) heap_init: At 40096994 len 0000966C (37 KiB): IRAM[1B][0m
[1B][0;32mI (465) cpu_start: Pro cpu start user code[1B][0m
[1B][0;32mI (484) spi_flash: detected chip: generic[1B][0m
[1B][0;32mI (485) spi_flash: flash io: dio[1B][0m
[1B][0;32mI (485) cpu_start: Starting scheduler on PRO CPU.[1B][0m
[1B][0;32mI (0) cpu_start: Starting scheduler on APP CPU.[1B][0m
ÿstarting station...
I (100) wifi: wifi driver task: 3ffc38a0, prio:23, stack:3584, core=0
I (790) wifi: wifi firmware version: 581f422
I (790) wifi: config NVS flash: enabled
I (790) wifi: config nano formating: disabled
I (790) wifi: Init dynamic tx buffer num: 32
I (790) wifi: Init data frame dynamic rx buffer num: 32
I (800) wifi: Init management frame dynamic rx buffer num: 32
I (800) wifi: Init management short buffer num: 32
I (810) wifi: Init static rx buffer size: 1600
I (810) wifi: Init static rx buffer num: 10
I (820) wifi: Init dynamic rx buffer num: 32
[1B][0;32mI (960) phy: phy_version: 4180, cb3948e, Sep 12 2019, 16:39:13, 0, 0[1B][0m
I (960) wifi: mode : sta (cc:50:e3:a2:0c:e4)
[D][WiFiGeneric.cpp:339] _eventCallback(): Event: 2 - STA_START
[D][WiFiGeneric.cpp:339] _eventCallback(): Event: 0 - WIFI_READY
[1B][0;32mI (1170) pm_esp32: Frequency switching config: CPU_MAX: 80, APB_MAX: 80, APB_MIN: 13, Light sleep: ENABLED[1B][0m
I (1170) wifi: Set ps type: 1

Modem Sleep Enabled!
I (1180) wifi: Set ps type: 2

I (1300) wifi: new:<6,0>, old:<1,0>, ap:<255,255>, sta:<6,0>, prof:1
I (1300) wifi: state: init -> auth (b0)
I (1310) wifi: state: auth -> assoc (0)
I (1310) wifi: state: assoc -> run (10)
I (1580) wifi: connected with Cottages, aid = 4, channel 6, BW20, bssid = 84:16:f9:d5:1e:1d
I (1580) wifi: security type: 3, phy: bgn, rssi: -47
I (1580) wifi: pm start, type: 2

[D][WiFiGeneric.cpp:339] _eventCallback(): Event: 4 - STA_CONNECTED
I (1650) wifi: AP's beacon interval = 102400 us, DTIM period = 1
CàË?[00]àààà[00]àà[00]à[00]ààà[00]àà[00]ààà[00]à[00]àrrààà[00][00]à[00]Cøàà[00]àà[00]àààà[00]àà[00]à[00]ààà[00]àà[00]ààà[00]à[00]ÉÉ©Hø[1B][0;32mI (3230) tcpip_adapter: sta ip:, mask:, gw:[1B][0m
[D][WiFiGeneric.cpp:339] _eventCallback(): Event: 7 - STA_GOT_IP
[D][WiFiGeneric.cpp:383] _eventCallback(): STA IP:, MASK:, GW:
Connection Successful!
Cottages, jostheboss
local IP:
[1B][0;31mE (9200) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:[1B][0m
[1B][0;31mE (9200) task_wdt:  - IDLE1 (CPU 1)[1B][0m
[1B][0;31mE (9200) task_wdt: Tasks currently running:[1B][0m
[1B][0;31mE (9200) task_wdt: CPU 0: IDLE0[1B][0m
[1B][0;31mE (9200) task_wdt: CPU 1: loopTask[1B][