ESP32S2 - Auto Light Sleep (ESP-IDF)

Hi! this is my first post, I’m trying to get my ESP32S2 Saola kit into Automatic Light Sleep, I used a code in an ESP32 and it get into the ALS without a problem, so I tried to implement that code in the ESP32S2, changing the:

esp_pm_config_esp32s2_t pm_config = {
    .max_freq_mhz = 240,
    .min_freq_mhz = 80,
#if CONFIG_FREERTOS_USE_TICKLESS_IDLE
            .light_sleep_enable = true
#endif
    };
    ESP_ERROR_CHECK( esp_pm_configure(&pm_config) );

I’ve used this build flags:

[env]
platform = espressif32
framework = espidf
monitor_speed = 115200

[env:esp32-s2-saola-1]
platform = espressif32
board = esp32-s2-saola-1

build_flags = 
	-D CORE_DEBUG_LEVEL=1
	-D CONFIG_ESP32S2_DEFAULT_CPU_FREQ_80
	-D CONFIG_PM_ENABLE
	-D CONFIG_FREERTOS_USE_TICKLESS_IDLE
	-D CONFIG_PM_USE_RTC_TIMER_REF

And the sdk shows this:

#
# Power Management
#
CONFIG_PM_ENABLE=y
CONFIG_PM_DFS_INIT_AUTO=y
# CONFIG_PM_PROFILING is not set
# CONFIG_PM_TRACE is not set
CONFIG_PM_SLP_IRAM_OPT=y
# CONFIG_PM_RTOS_IDLE_OPT is not set
CONFIG_PM_SLP_DISABLE_GPIO=y
# end of Power Management

But it nevers get into Light sleep. Any help will be welcome.

Instead of adding these as macros to the build system, use the proper menuconfig way to configure those options.

1 Like

Hi Max! I did that, and add this code:

    esp_err_t err = esp_pm_configure(&pm_config);
  if(err == ESP_OK){
    printf("ESP_OK\n");
  }else if (err== ESP_ERR_INVALID_ARG){
    printf("ESP_ERR_INVALID_ARG\n");
  }else if (err == ESP_ERR_NOT_SUPPORTED){
    printf("ESP_ERR_NOT_SUPPORTED\n");
  }

And it prints ESP_OK. But it doesn’t sleep.

␛[0;32mI (653) pm: Frequency switching config: CPU_MAX: 240, APB_MAX: 80, APB_MIN: 80, Light sleep: ENABLED␛[0m
I (653) wifi:state: auth -> assoc (0)
␛[0;32mI (663) sleep: Enable automatic switching of GPIO sleep configuration␛[0m
I (673) wifi:state: assoc -> run (10)
ESP_OK