mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-02 20:24:32 +02:00
examples/power_save: enable modem sleep and DFS by default
This commit is contained in:
@@ -14,7 +14,7 @@ config WIFI_PASSWORD
|
|||||||
|
|
||||||
choice POWER_SAVE_MODE
|
choice POWER_SAVE_MODE
|
||||||
prompt "power save mode"
|
prompt "power save mode"
|
||||||
default POWER_SAVE_NONE
|
default POWER_SAVE_MODEM
|
||||||
help
|
help
|
||||||
Power save mode for the esp32 to use.
|
Power save mode for the esp32 to use.
|
||||||
|
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
#include "esp_wifi.h"
|
#include "esp_wifi.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "esp_event_loop.h"
|
#include "esp_event_loop.h"
|
||||||
|
#include "esp_pm.h"
|
||||||
#include "nvs_flash.h"
|
#include "nvs_flash.h"
|
||||||
|
|
||||||
/*set the ssid and password via "make menuconfig"*/
|
/*set the ssid and password via "make menuconfig"*/
|
||||||
@@ -89,5 +90,17 @@ void app_main()
|
|||||||
}
|
}
|
||||||
ESP_ERROR_CHECK( ret );
|
ESP_ERROR_CHECK( ret );
|
||||||
|
|
||||||
|
#if CONFIG_PM_ENABLE
|
||||||
|
// Configure dynamic frequency scaling: maximum frequency is set in sdkconfig,
|
||||||
|
// minimum frequency is XTAL.
|
||||||
|
rtc_cpu_freq_t max_freq;
|
||||||
|
rtc_clk_cpu_freq_from_mhz(CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ, &max_freq);
|
||||||
|
esp_pm_config_esp32_t pm_config = {
|
||||||
|
.max_cpu_freq = max_freq,
|
||||||
|
.min_cpu_freq = RTC_CPU_FREQ_XTAL
|
||||||
|
};
|
||||||
|
ESP_ERROR_CHECK( esp_pm_configure(&pm_config) );
|
||||||
|
#endif // CONFIG_PM_ENABLE
|
||||||
|
|
||||||
wifi_power_save();
|
wifi_power_save();
|
||||||
}
|
}
|
||||||
|
6
examples/wifi/power_save/sdkconfig.defaults
Normal file
6
examples/wifi/power_save/sdkconfig.defaults
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Use lower CPU frequency
|
||||||
|
CONFIG_ESP32_DEFAULT_CPU_FREQ_80=y
|
||||||
|
# Enable support for power management
|
||||||
|
CONFIG_PM_ENABLE=y
|
||||||
|
# Use RTC timer as reference
|
||||||
|
CONFIG_PM_USE_RTC_TIMER_REF=y
|
Reference in New Issue
Block a user