power_save
Overview
This example shows how to use power save mode of wifi.
Power save mode only works in station mode. If the modem sleep mode is enabled, station will switch between active and sleep state periodically after connecting to AP successfully. In sleep state, RF, PHY and BB are turned off in order to reduce power consumption. Station can keep connection with AP in modem sleep mode.
No power save: This is default mode. And will work with full power.
Minimum modem sleep: In minimum modem sleep mode, station wakes up every DTIM to receive beacon. Broadcast data will not be lost because it is transmitted after DTIM.
Maximum modem sleep: In maximum modem sleep mode, station wakes up every listen interval to receive beacon. Broadcast data may be lost because station may be in sleep state at DTIM time. If listen interval is longer, more power is saved but broadcast data is more easy to lose.
Requirements
Configure WiFi SSID and WiFi Password in menuconfig
Configure WiFi listen intervaland WiFi beacon timeout menuconfig
Configure power save mode in menuconfig
Building and flashing
Example Location: examples/wifi/power_save
compile, burn, and more, see: get started
Running result
Successfully running will output the following logs
D/main [0.002] boot reason 0
D/main [0.004] heap size 270856(264.51KB)
D/fls [0.010] flash size 0x200000(2MB)
D/ptb [0.014] partition table base 0x800e000
D/ft [0.020] ft_0 base 8000000, ft_1 base 8001000
D/ft [0.026] ft init too
D/ft [0.030] ft init error
E/nvs [0.034] use new hash entry num=53
I/ota_http [0.040] 0.3.0 build at Jun 13 2024 13:53:08
I/power_save [2.278] wm_wifi_set_ps().
I/power_save [17.904] retry to connect to the AP
D/wifi [20.132] distribution event 2
D/wifi [20.138] sta disconnected reason 3
D/wifi [22.944] distribution event 1
D/wifi [22.948] sta connected 42-C1-82-80-2A-15 channel 6 authmode 3
I/power_save [23.626] got ip: 192.168.3.102
D/wifi [23.630] distribution event 0
D/wifi [23.634] sta got ip 192.168.3.102