{"id":69,"date":"2026-02-23T22:59:56","date_gmt":"2026-02-23T21:59:56","guid":{"rendered":"https:\/\/elrebo.de\/?p=69"},"modified":"2026-02-26T16:26:47","modified_gmt":"2026-02-26T15:26:47","slug":"deep_sleep","status":"publish","type":"post","link":"https:\/\/www.elrebo.de\/index.php\/2026\/02\/23\/deep_sleep\/","title":{"rendered":"deep_sleep"},"content":{"rendered":"\n<p id=\"block-ba52b210-d104-4fde-a632-10cbcb3c5b2e\">An ESP-IDF component for <a href=\"https:\/\/elrebo.de\/index.php\/2026\/02\/20\/physical-computing\/\">Physical Computing<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"block-04934845-0494-4239-8980-9a0598c094ce\">Purpose<\/h2>\n\n\n\n<p id=\"block-c9a9f4c8-2271-4fa0-96fd-a2934e610c6b\">Deep Sleep functionality for ESP32 systems.<\/p>\n\n\n\n<p>Wakeup sources can be:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>one gpio pin<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>timer<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"block-dab95eeb-30b1-4adb-aff2-59912931069c\">How it is done<\/h2>\n\n\n\n<p id=\"block-57d32859-10bd-4201-83ab-9f44dd3122db\">A simple Deep Sleep functionality is implemented through class DeepSleep. <\/p>\n\n\n\n<p id=\"block-57d32859-10bd-4201-83ab-9f44dd3122db\">If wakeup from Deep Sleep shall be triggered by a timer the method <code>EnableTimerWakeup<\/code> has to be called.<\/p>\n\n\n\n<p id=\"block-4f69c3ff-5528-4658-8a97-691a22ca7a34\">If wakeup from Deep Sleep shall be triggered by pushing a button the method <code>EnableGpioWakeup<\/code> has to be called.<\/p>\n\n\n\n<p id=\"block-20e17c82-5c24-4ce1-898d-ee4aee30b4ed\">To go to Deep Sleep the method <code>GoToDeepSleep<\/code> has to be called.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"block-4b33a468-7d65-4059-81cd-f05bc139bcf2\">Where to find it<\/h2>\n\n\n\n<p id=\"block-e3570804-282a-42fb-a1a7-15866fc48f65\"><code>deep_sleep<\/code> is published on the ESP Registry at <a href=\"https:\/\/components.espressif.com\/components\/elrebo-de\/deep_sleep\">https:\/\/components.espressif.com\/components\/elrebo-de\/deep_sleep<\/a>.<\/p>\n\n\n\n<p id=\"block-9bf38eb0-dd0a-4903-8854-b667d909a1dc\">The source code can be found at <a href=\"https:\/\/github.com\/elrebo-de\/deep_sleep\">https:\/\/github.com\/elrebo-de\/deep_sleep<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"block-81787b41-dec8-474a-a616-9fdad19eba72\">How to use it<\/h2>\n\n\n\n<p id=\"block-f1356d26-fba4-428e-be89-9152fcbbb58f\">As an ESP-IDF component deep_sleep must be included into idf_component.yml as a dependency. As usual this can be done by executing this command:<\/p>\n\n\n\n<p id=\"block-01365eb0-23de-4086-9e6d-efb27460c2ee\"><code>idf.py add-dependency \"elrebo-de\/deep_sleep^1.1.1\"<\/code><\/p>\n\n\n\n<p id=\"block-38365fcf-8f84-48a9-ac55-0bfda022161d\">In CMakeLists.txt <code>\"elrebo-de__deep_sleep\"<\/code> has to be added as a requirement.<\/p>\n\n\n\n<p>Now you can include <code>deep_sleep.hpp<\/code> and use the DeepSleep class in your program.<\/p>\n\n\n\n<p>The constructor of class DeepSleep needs a pointer to an <code>RTC_DATA_ATTR int bootCount<\/code>. This bootCount variable is incremented for every boot.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"836\" src=\"https:\/\/elrebo.de\/wp-content\/uploads\/2026\/02\/Bildschirmfoto-2026-02-23-um-22.56.59-1024x836.png\" alt=\"\" class=\"wp-image-91\" srcset=\"https:\/\/www.elrebo.de\/wp-content\/uploads\/2026\/02\/Bildschirmfoto-2026-02-23-um-22.56.59-1024x836.png 1024w, https:\/\/www.elrebo.de\/wp-content\/uploads\/2026\/02\/Bildschirmfoto-2026-02-23-um-22.56.59-300x245.png 300w, https:\/\/www.elrebo.de\/wp-content\/uploads\/2026\/02\/Bildschirmfoto-2026-02-23-um-22.56.59-768x627.png 768w, https:\/\/www.elrebo.de\/wp-content\/uploads\/2026\/02\/Bildschirmfoto-2026-02-23-um-22.56.59-1536x1255.png 1536w, https:\/\/www.elrebo.de\/wp-content\/uploads\/2026\/02\/Bildschirmfoto-2026-02-23-um-22.56.59.png 1878w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"464\" src=\"https:\/\/elrebo.de\/wp-content\/uploads\/2026\/02\/Bildschirmfoto-2026-02-23-um-22.57.18-1024x464.png\" alt=\"\" class=\"wp-image-92\" srcset=\"https:\/\/www.elrebo.de\/wp-content\/uploads\/2026\/02\/Bildschirmfoto-2026-02-23-um-22.57.18-1024x464.png 1024w, https:\/\/www.elrebo.de\/wp-content\/uploads\/2026\/02\/Bildschirmfoto-2026-02-23-um-22.57.18-300x136.png 300w, https:\/\/www.elrebo.de\/wp-content\/uploads\/2026\/02\/Bildschirmfoto-2026-02-23-um-22.57.18-768x348.png 768w, https:\/\/www.elrebo.de\/wp-content\/uploads\/2026\/02\/Bildschirmfoto-2026-02-23-um-22.57.18-1536x696.png 1536w, https:\/\/www.elrebo.de\/wp-content\/uploads\/2026\/02\/Bildschirmfoto-2026-02-23-um-22.57.18.png 1868w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p id=\"block-b415668b-e119-412d-b053-5f7582a8df98\">There are two parameters in the constructor of class DeepSleep:<\/p>\n\n\n\n<ul id=\"block-d4974587-b133-49e3-9294-ed2e7d0fa108\" class=\"wp-block-list\">\n<li>tag &#8211; the tag used for logging from this instance of DeepSleep class<\/li>\n\n\n\n<li>bootCount &#8211; a pointer to an <code>RTC_DATA_ATTR int<\/code> which counts the number of boots<\/li>\n\n\n\n<li><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>An ESP-IDF component for Physical Computing Purpose Deep Sleep functionality for ESP32 systems. Wakeup sources can be: How it is done A simple Deep Sleep functionality is implemented through class DeepSleep. If wakeup from Deep Sleep shall be triggered by a timer the method EnableTimerWakeup has to be called. If wakeup from Deep Sleep shall [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":104,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-69","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oss"],"_links":{"self":[{"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/posts\/69","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/comments?post=69"}],"version-history":[{"count":5,"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/posts\/69\/revisions"}],"predecessor-version":[{"id":133,"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/posts\/69\/revisions\/133"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/media\/104"}],"wp:attachment":[{"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/media?parent=69"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/categories?post=69"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.elrebo.de\/index.php\/wp-json\/wp\/v2\/tags?post=69"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}