Chapter 2. API Reference
UART output handling
Before entering sleep mode, esp_deep_sleep_start() will flush the contents of UART FIFOs.
When entering light sleep mode using esp_light_sleep_start(), UART FIFOs will not be flushed. Instead,
UART output will be suspended, and remaining characters in the FIFO will be sent out after wakeup from light sleep.
Checking sleep wakeup cause
esp_sleep_get_wakeup_cause() function can be used to check which wakeup source has triggered wakeup
from sleep mode.
For touch pad, it is possible to identify touch pad which has caused wakeup using
esp_sleep_get_touchpad_wakeup_status() functions.
For ext1 wakeup sources, it is possible to identify pin which has caused wakeup using
esp_sleep_get_ext1_wakeup_status() functions.
Disable sleep wakeup source
Previously configured wakeup source can be disabled later using esp_sleep_disable_wakeup_source()
API. This function deactivates trigger for the given wakeup source. Additionally it can disable all triggers if the
argument is ESP_SLEEP_WAKEUP_ALL.
Application Example
Implementation of basic functionality of deep sleep is shown in protocols/sntp example, where ESP module is peri-
odically waken up to retrieve time from NTP server.
More extensive example in system/deep_sleep illustrates usage of various deep sleep wakeup triggers and ULP co-
processor programming.
API Reference
Header File
• components/esp_hw_support/include/esp_sleep.h
Functions
esp_err_t esp_sleep_disable_wakeup_source(esp_sleep_source_t source)
Disable wakeup source.
This function is used to deactivate wake up trigger for source defined as parameter of the function.
See docs/sleep-modes.rst for details.
Note This function does not modify wake up configuration in RTC. It will be performed in esp_sleep_start
function.
Return
• ESP_OK on success
• ESP_ERR_INVALID_STATE if trigger was not active
Parameters
• source: - number of source to disable of type esp_sleep_source_t
esp_err_t esp_sleep_enable_ulp_wakeup(void)
Enable wakeup by ULP coprocessor.
Note In revisions 0 and 1 of the ESP32, ULP wakeup source cannot be used when RTC_PERIPH power
domain is forced to be powered on (ESP_PD_OPTION_ON) or when ext0 wakeup source is used.
Espressif Systems 1041
Submit Document Feedback
Release v4.4