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-C3 series of products.

Introduction

With the use of advanced power-management technologies, ESP32-C3 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):

  1. Active Mode: CPU and chip radio are powered on. The chip can receive, transmit, or listen.

  2. 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.

  3. 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.

  4. Deep-sleep Mode: CPU and most peripherals are powered down. Only the RTC memory is powered on.

By default, ESP32-C3 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-C3, please refer to ESP32-C3 Series Datasheet.

Note

  • Setting ESP32-C3 to sleep modes in Wi-Fi mode and Bluetooth LE mode will be described separately.

  • In single Wi-Fi mode, only station mode supports Modem-sleep mode and Light-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-C3 module on board, and all other peripheral components have been removed.)

ESP32-C3 Hardware Connection

ESP32-C3 Hardware Connection

Set Modem-sleep mode in Wi-Fi mode

  1. Set the Wi-Fi mode to station mode.

    Command:

    AT+CWMODE=1
    

    Response:

    OK
    
  2. 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.

  3. 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

  1. Set the Wi-Fi mode to station mode.

    Command:

    AT+CWMODE=1
    

    Response:

    OK
    
  2. 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.

  3. 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 Modem-sleep mode in Bluetooth LE advertising mode

  1. Initialize the role of Bluetooth LE as server.

    Command:

    AT+BLEINIT=2
    

    Response:

    OK
    
  2. Set parameters of Bluetooth LE advertising. Set Bluetooth LE advertising interval to 1 s.

    Command:

    AT+BLEADVPARAM=1600,1600,0,0,7,0,0,"00:00:00:00:00:00"
    

    Response:

    OK
    
  3. Start Bluetooth LE advertising.

    Command:

    AT+BLEADVSTART
    

    Response:

    OK
    
  4. Disable Wi-Fi.

    Command:

    AT+CWMODE=0
    

    Response:

    OK
    
  5. Set the sleep mode to Modem-sleep mode.

    Command:

    AT+SLEEP=1
    

    Response:

    OK
    

Set Modem-sleep mode in Bluetooth LE connection mode

  1. Initialize the role of Bluetooth LE as server.

    Command:

    AT+BLEINIT=2
    

    Response:

    OK
    
  2. Start Bluetooth LE advertising.

    Command:

    AT+BLEADVSTART
    

    Response:

    OK
    
  3. Waiting for connection.

    If the connection is established successfully, AT will prompt:

    +BLECONN:0,"47:3f:86:dc:e4:7d"
    +BLECONNPARAM:0,0,0,6,0,500
    +BLECONNPARAM:0,0,0,24,0,500
    
    OK
    

    Note:

    • In this example, Bluetooth LE client address is 47:3f:86:dc:e4:7d.

    • For prompt information (+BLECONN and +BLECONNPARAM), please refer to AT+BLECONN and AT+BLECONNPARAM for more details.

  4. Update parameters of Bluetooth LE connection. Set Bluetooth LE connection interval to 1 s.

    Command:

    AT+BLECONNPARAM=0,800,800,0,500
    

    Response:

    OK
    

    If the connection parameters are updated successfully, AT will output:

    +BLECONNPARAM:0,800,800,800,0,500
    

    Note:

    • For prompt information (+BLECONNPARAM), please refer to AT+BLECONNPARAM for more details.

  5. Disable Wi-Fi.

    Command:

    AT+CWMODE=0
    

    Response:

    OK
    
  6. Set the sleep mode to Modem-sleep mode.

    Command:

    AT+SLEEP=1
    

    Response:

    OK
    

Set Light-sleep mode in Bluetooth LE advertising mode

  1. Initialize the role of Bluetooth LE as server.

    Command:

    AT+BLEINIT=2
    

    Response:

    OK
    
  2. Set parameters of Bluetooth LE advertising. Set Bluetooth LE advertising interval to 1 s.

    Command:

    AT+BLEADVPARAM=1600,1600,0,0,7,0,0,"00:00:00:00:00:00"
    

    Response:

    OK
    
  3. Start Bluetooth LE advertising.

    Command:

    AT+BLEADVSTART
    

    Response:

    OK
    
  4. Disable Wi-Fi.

    Command:

    AT+CWMODE=0
    

    Response:

    OK
    
  5. Set the sleep mode to Light-sleep mode.

    Command:

    AT+SLEEP=2
    

    Response:

    OK
    

Set Light-sleep mode in Bluetooth LE connection mode

  1. Initialize the role of Bluetooth LE as server.

    Command:

    AT+BLEINIT=2
    

    Response:

    OK
    
  2. Start Bluetooth LE advertising.

    Command:

    AT+BLEADVSTART
    

    Response:

    OK
    
  3. Waiting for connection.

    If the connection is established successfully, AT will prompt:

    +BLECONN:0,"47:3f:86:dc:e4:7d"
    +BLECONNPARAM:0,0,0,6,0,500
    +BLECONNPARAM:0,0,0,24,0,500
    
    OK
    

    Note:

    • In this example, Bluetooth LE client address is 47:3f:86:dc:e4:7d.

    • For prompt information (+BLECONN and +BLECONNPARAM), please refer to AT+BLECONN and AT+BLECONNPARAM for more details.

  4. Update parameters of Bluetooth LE connection. Set Bluetooth LE connection interval to 1 s.

    Command:

    AT+BLECONNPARAM=0,800,800,0,500
    

    Response:

    OK
    

    If the connection parameters are updated successfully, AT will output:

    +BLECONNPARAM:0,800,800,800,0,500
    

    Note:

    • For prompt information (+BLECONNPARAM), please refer to AT+BLECONNPARAM for more details.

  5. Disable Wi-Fi.

    Command:

    AT+CWMODE=0
    

    Response:

    OK
    
  6. Set the sleep mode to Light-sleep mode.

    Command:

    AT+SLEEP=2
    

    Response:

    OK
    

Set Deep-sleep mode

  1. 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.