Deep sleep: example of getting wakeup cause (#3663)

* Deep sleep: example of getting wakeup cause

* Update deep_sleep.rst

---------

Co-authored-by: H. Árkosi Róbert <robreg@zsurob.hu>
This commit is contained in:
Kevin Reilly 2024-03-12 01:13:45 -07:00 committed by GitHub
parent cde95b10cf
commit def1caf939
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 28 additions and 0 deletions

View File

@ -87,6 +87,34 @@ when the deep sleep should start? There are three ways of handling this using th
then re-configure deep sleep to wake up on a LOW signal and vice versa. Useful in situations when you want to
use observe the state changes of a pin using deep sleep and the ON/OFF values last longer.
ESP32 Wakeup Cause
------------------
On the ESP32, the ``esp_sleep_get_wakeup_cause()`` function can be used to check which wakeup source has triggered
wakeup from sleep mode.
.. code-block:: yaml
sensor:
- platform: template
name: "Wakeup Cause"
accuracy_decimals: 0
lambda: return esp_sleep_get_wakeup_cause();
The following integers are the wakeup causes:
- **0** - ``ESP_SLEEP_WAKEUP_UNDEFINED``: In case of deep sleep, reset was not caused by exit from deep sleep
- **1** - ``ESP_SLEEP_WAKEUP_ALL``: Not a wakeup cause, used to disable all wakeup sources with esp_sleep_disable_wakeup_source
- **2** - ``ESP_SLEEP_WAKEUP_EXT0``: Wakeup caused by external signal using RTC_IO
- **3** - ``ESP_SLEEP_WAKEUP_EXT1``: Wakeup caused by external signal using RTC_CNTL
- **4** - ``ESP_SLEEP_WAKEUP_TIMER``: Wakeup caused by timer
- **5** - ``ESP_SLEEP_WAKEUP_TOUCHPAD``: Wakeup caused by touchpad
- **6** - ``ESP_SLEEP_WAKEUP_ULP``: Wakeup caused by ULP program
- **7** - ``ESP_SLEEP_WAKEUP_GPIO``: Wakeup caused by GPIO (light sleep only on ESP32, S2 and S3)
- **8** - ``ESP_SLEEP_WAKEUP_UART``: Wakeup caused by UART (light sleep only)
- **9** - ``ESP_SLEEP_WAKEUP_WIFI``: Wakeup caused by WIFI (light sleep only)
- **10** - ``ESP_SLEEP_WAKEUP_COCPU``: Wakeup caused by COCPU int
- **11** - ``ESP_SLEEP_WAKEUP_COCPU_TRAP_TRIG``: Wakeup caused by COCPU crash
- **12** - ``ESP_SLEEP_WAKEUP_BT``: Wakeup caused by BT (light sleep only)
.. _deep_sleep-enter_action: