Sleep AT Examples
This document provides an introduction and detailed command examples to illustrate how to utilize AT commands to set sleep modes on ESP32-C2 series of products.
Introduction
With the use of advanced power-management technologies, ESP32-C2 series can switch between different power modes. Currently, ESP-AT supports the following four power consumption modes (for more sleep modes, please refer to the datasheet):
Active
Mode: CPU and chip radio are powered on. The chip can receive, transmit, or listen.Modem-sleep
Mode: The CPU is operational and the clock speed can be reduced. Wi-Fi baseband, Bluetooth LE baseband, and radio are disabled, but Wi-Fi and Bluetooth LE connection can remain active.Light-sleep
Mode: The CPU is paused. Any wake-up events (MAC, host, RTC timer, or external interrupts) will wake up the chip. Wi-Fi and Bluetooth LE connection can remain active.Deep-sleep
Mode: CPU and most peripherals are powered down. Only the RTC memory is powered on.
By default, ESP32-C2 will enter Active
mode after system reset. When the CPU does not need to work all the time, such as waiting for external activities to wake up, the system can enter low-power modes.
For current consumption of ESP32-C2, please refer to ESP32-C2 Series Datasheet.
Note
Setting ESP32-C2 to sleep modes in Wi-Fi mode and Bluetooth LE mode will be described separately.
In single Wi-Fi mode, only
station
mode supportsModem-sleep
mode andLight-sleep
mode.For Light-sleep mode in Bluetooth LE mode, please ensure that there is an external 32 KHz crystal oscillator. If there is no external 32 KHz crystal oscillator, ESP-AT will work as the Modem-sleep mode.
Measurement Method
In order to avoid some unnecessary interference during the power consumption test process, it is recommended to use the Espressif modules that integrate the chip for the test.
Refer to the following figure for hardware connection. (Note that the development board below only has the ESP32-C2 module on board, and all other peripheral components have been removed.)
Set Modem-sleep mode in Wi-Fi mode
Set the Wi-Fi mode to station mode.
Command:
AT+CWMODE=1
Response:
OK
Connect to an router.
Command:
AT+CWJAP="espressif","1234567890"
Response:
WIFI CONNECTED WIFI GOT IP OK
Note:
The SSID and password you entered may be different from those in the above command. Please replace the SSID and password with those of your router settings.
Set the sleep mode to Modem-sleep mode.
Command:
AT+SLEEP=1
Response:
OK
Note
RF will be periodically closed according to AP DTIM (routers generally set DTIM to 1).
Set Light-sleep mode in Wi-Fi mode
Set the Wi-Fi mode to station mode.
Command:
AT+CWMODE=1
Response:
OK
Connect to an router. Set listen interval to 3.
Command:
AT+CWJAP="espressif","1234567890",,,,3
Response:
WIFI CONNECTED WIFI GOT IP OK
Note:
The SSID and password you entered may be different from those in the above command. Please replace the SSID and password with those of your router settings.
Set the sleep mode to Light-sleep mode.
Command:
AT+SLEEP=2
Response:
OK
Note
CPU will automatically sleep and RF will be periodically closed according to listen interval set by AT+CWJAP.
Set Deep-sleep mode
Set the sleep mode to Deep-sleep mode. Set the deep-sleep time to 3600000 ms.
Command:
AT+GSLP=3600000
Response:
OK
Note:
When the time is up, the device automatically wakes up, calls Deep-sleep wake stub, and then proceeds to load the application.
For Deep-sleep mode, the only wake-up method is timed wake-up.