Analysis of commonly used low-power configuration options for ESP

This blog describes common low-power configuration options for ESPs.

1. Common power consumption optimization configuration options

1.1. Dynamic FM

The higher the CPU frequency, the greater the power consumption. Through DFS (dynamic frequency scaling, dynamic frequency modulation), the system can automatically switch the operating frequency to achieve a balance between power consumption and performance. To enable this function, you need to enable these two items in Figure 1-1, so that the system will switch to the maximum frequency when it is working, and switch to the lowest frequency when the system is idle. The maximum frequency defaults to the main frequency, such as ESP32-C3 is 160 MHz, the lowest frequency is the frequency of the external main crystal oscillator, generally 40 MHz. The maximum and minimum frequencies can be set by calling esp_pm_configure.

insert image description here

Figure 1-1 Dynamic frequency adjustment configuration items
Configuration item name PM_ENABLE
Configuration item path (Top) -> Component config -> Power Management -> Support for power management
Configuration item name PM_DFS_INIT_AUTO
Configuration item path

(Top) -> Component config -> Power Management -> Support for power management

-> Enable dynamic frequency scaling (DFS) at startup

Note: If it is auto-tuning with Wi-Fi application, the minimum frequency cannot be less than 40 MHz.

1.2. Automatic light sleep

If you need to further reduce power consumption after dynamic frequency modulation is enabled, as shown in Figure 1-2, you need to enable automatic light sleep. Modem sleep mode plus automatic light sleep is what we often call power save mode .

insert image description here

Figure 1-2 Automatic light sleep configuration items
Configuration item name FREERTOS_HZ
Configuration item path (Top) -> Component config -> FreeRTOS -> Tick rate (Hz)
Configuration item name FREERTOS_USE_TICKLESS_IDLE
Configuration item path (Top) -> Component config -> FreeRTOS -> Tickless idle support

There are two configuration items involved here, item A is the Tick frequency of FreeRTOS, the default is 100, that is, each Tick needs 1000 / 100 = 10 ms. Item B is the minimum number of idle Ticks required to automatically enter the light sleep state, and the default is 3, that is

When the system detects that the idle time is greater than 3 Ticks, it will automatically enter light sleep. As shown in the figure above, when the idle time is greater than 3 * 10 = 30 ms, the system will automatically enter light sleep. By increasing the A term, the system can detect idle time more sensitively and go to sleep. For example, if the tick rate is configured as 1000, it will go to sleep when there is no task within 3 ms, so as to achieve lower power consumption.

Notice:

1. Automatically entering light sleep can only be configured after enabling the configuration item in 2.1.

2. After turning on the automatic frequency adjustment and automatic sleep, the communication of some peripheral devices will be affected. For details, please refer to the programming guide .

1.3. Isolation GPIO

GPIO leakage during system sleep will cause current consumption and increase system power consumption. When the light sleep in esp-idf sleeps, the GPIO pin is suspended (prohibiting the internal pull-down resistor of the pin) and isolated (disconnecting the input and output of the pin) to eliminate the GPIO leakage current. The corresponding menuconfig configuration items of this function are as follows.

Note: This configuration item must be enabled after the automatic sleep of 2.2 is enabled.

insert image description here

Figure 1-3 Isolate GPIO configuration items
Configuration item name PM_SLP_DISABLE_GPIO
Configuration item path (Top) -> Component config -> Power Management -> Disable all GPIO when chip at sleep
When this option is turned on, all GPIO pins will be disabled during system sleep, which eliminates the impact of GPIO leakage on sleep power consumption, but also causes GPIO to be unable to perform signal input and output during sleep. However, in some applications, the application layer It is hoped that the GPIO function (input/output/internal pull-down) can be used normally during the system hibernation process, so a set of APIs are provided in IDF to manage the GPIO state during the hibernation process. The relevant API references are as follows:

Sleep process GPIO management API:

  • Set the GPIO input and output state in sleep stategpio_sleep_set_direction

  • Set the GPIO pull-up and pull-down state in sleep stategpio_sleep_set_pull_mode

  • Enable automatic GPIO state switchinggpio_sleep_sel_en

  • Disable automatic GPIO state switchinggpio_sleep_sel_dis

If you want to keep the state of the GPIO pins during sleep, such as controlling the light output and closing the switch, you can use gpio_hold_enand gpio_hold_distwo APIs to hold the GPIO that needs to maintain the level before going to sleep, and do it after waking up hold_dis.

1.4. Power off the flash

ESP32 increases system memory resources by connecting flash and PSRAM. The flash has the characteristic that the data will not be lost after power failure, and the PSRAM data cannot be retained after power failure. When the PSRAM is not used in the system , the flash power-off function can be enabled to reduce the chip sleep current. The relevant menuconfig options are as follows:

insert image description here

Figure 1-4 Flash power-down configuration items
Configuration item name

ESP_SYSTEM_PD_FLASH (release/v4.3)

ESP_SLEEP_POWER_DOWN_FLASH (after 4.4)

Configuration item path (Top) -> Component config -> ESP System Settings -> PD flash at light sleep when there is no SPIRAM (release/v4.3)
(Top) -> Component config -> Hardware Settings -> Sleep Config -> Power down flash in light sleep when there is no SPIRAM (4.4以后)

Note: In reality, it is difficult to predict the time required for flash power-off. Even if the time required for flash complete power-off can be predicted, sometimes it is impossible to ensure the safety of flash power-off by setting a long enough sleep time (for example, sudden The asynchronous wake-up source will make the actual sleep time uncontrollable), so the configuration items can be adjusted as follows:

insert image description here

insert image description here

Figure 1-5 Flash power-down configuration optimization

This method is better than power-off flash, in contrast, it increases the bottom current consumption of more than ten μA, but at the same time, safety and power consumption are taken into account.

2. Wi-Fi / Bluetooth low energy optimization configuration

The Espressif chip is a wireless MCU, so most of the low power consumption functions need to be used together with the Wi-Fi/Bluetooth function. Some low-power configurations and parameters related to Wi-Fi / Bluetooth are explained here.

2.1. Bluetooth low energy optimization items

At present, there are relatively few optimized configurations on the Bluetooth side, and BLE modem sleep can be enabled

insert image description here

Figure 2-1 Bluetooth low energy configuration
Configuration item name BT_CTRL_MODEM_SLEEP
Configuration item path (Top) -> Component config -> Bluetooth -> Bluetooth -> Bluetooth controller -> MODEM SLEEP Options

If you want to enter light sleep instead of modem sleep when keeping alive, just refer to 2.2 .

Bluetooth requires a 32K external crystal oscillator.

2.2. Wi-Fi low power consumption optimization items

There are many configuration items involved in Wi-Fi optimization, the more common ones are as follows:

2.2.1. Wireless digital circuit power down

After enabling automatic light sleep, you can turn on this option, so that the wireless digital circuit module will also be powered off correspondingly when the physical layer is turned off.
insert image description here

Figure 2-2 Wireless digital circuit power-down configuration
Configuration item name ESP_PHY_MAC_BB_PD
Configuration item path (Top) -> Component config -> PHY -> Power down MAC and baseband of Wi-Fi and Bluetooth when PHY is disabled

2.2.2. Change the minimum waiting time and maximum keep-alive time

When the ESP32 communicates with the AP as a STA, it needs to wait for a period of time after receiving a data before turning off the RF. This time is called the Minimum active time, and the default value is 50 ms . On the basis of ensuring each data throughput, it can be appropriately Reducing this wait time reduces power consumption.

When ESP32 is in power save mode, it needs to periodically send a keep alive packet to AP to tell AP that it is still connected. The Maximum keep alive time is the time period for sending the keep alive packet. The default is 10 s . You can increase this parameter to reduce sending packets and reduce power consumption.

insert image description here

Figure 2-3 Minimum waiting time and maximum keepalive time configuration
Configuration item name ESP_WIFI_SLP_DEFAULT_MIN_ACTIVE_TIME
Configuration item path (Top) -> Component config -> Wi-Fi -> WiFi SLP IRAM speed optimization -> Minimum active time
Configuration item name ESP_WIFI_SLP_DEFAULT_MAX_ACTIVE_TIME
Configuration item path (Top) -> Component config -> Wi-Fi -> WiFi SLP IRAM speed optimization -> Maximum keep alive time

Recommended configuration: Minimum active time = 15~20, Maximum keep alive time = 60.

2.2.3. Enable disconnection power management

After enabling this configuration item, the Modem sleep state can still be maintained when disconnection occurs.

insert image description here

Figure 2-4 Enable disconnection power management
Configuration item name ESP_WIFI_STA_DISCONNECTED_PM_ENABLE
Configuration item path (Top) -> Component config -> Wi-Fi -> Power Management for station at disconnected

2.2.4. Enable Beacon lost optimization (only release/v4.4 and above)

Configuration item name ESP_WIFI_SLP_BEACON_LOST_OPT
Configuration item path (Top) -> Component config -> Wi-Fi -> Wifi sleep optimize when beacon lost

3. Supplementary content

3.1. The difference between DTIM and listen interval

When the chip acts as an STA to establish a connection with the router, it will be informed of the DTIM of the router, that is, how often the router will send a beacon, and the STA needs to get up to receive the beacon at this time to check whether there is any information that needs to be processed by itself. The listen interval is the STA telling the router how long I need to get up to accept the beacon, that is, the former is determined according to the router, and the latter can be configured into the chip by itself. The time interval is the number of DTIM or listen interval * 100 ms, if DTIM = 10, that is, the time interval of each wake-up is 10 * 100 ms = 1 s.

3.2. External 32 KHz crystal oscillator

Lower power consumption can be obtained by using an external 32 KHz crystal oscillator. There are mainly the following reasons:

The internal crystal oscillator is susceptible to interference. In contrast, the external crystal oscillator has higher precision and can be used in various sleep situations.

For applications that require high time accuracy, such as Bluetooth and Wi-Fi keep-alive, it is necessary to receive beacons at regular intervals. Once the clock drifts too much and the receiving point is missed, the waiting window for turning on RF will become longer, which greatly increase power consumption.

Enabling an external clock source requires the following configuration:

insert image description here

Figure 3-1 Enable external crystal oscillator
Configuration item name ESP32C3_RTC_CLK_SRC_EXT_CRYS
Configuration item path (Top) -> Component config -> ESP32XX-Specific -> RTC clock source

There are two types of external crystal oscillators. External 32 kHz crystal is an external passive crystal oscillator, which is also recommended most of the time. External 32 kHz oscillator at 32K_XP pin is an external active crystal oscillator, which is more expensive and will cause the bottom current to rise. The layout of the crystal oscillator You can refer to the hardware design guide corresponding to each chip.

Guess you like

Origin blog.csdn.net/Marchtwentytwo/article/details/128344949