{"id":83645,"date":"2024-10-08T10:28:36","date_gmt":"2024-10-08T10:28:36","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=83645"},"modified":"2024-10-12T09:59:23","modified_gmt":"2024-10-12T09:59:23","slug":"esp32-touch-wake-up-deep-sleep","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp32-touch-wake-up-deep-sleep\/","title":{"rendered":"ESP32 Touch Wake Up from Deep Sleep"},"content":{"rendered":"\n<p>This guide shows how to wake up the ESP32 from deep sleep using the touch-sensitive pins. The ESP32 will be programmed using Arduino IDE.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1024\" height=\"576\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/ESP32-Deep-Sleep-Touch-Wake-Up.jpg?resize=1024%2C576&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Touch Wake Up from Deep Sleep\" class=\"wp-image-162961\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/ESP32-Deep-Sleep-Touch-Wake-Up.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/ESP32-Deep-Sleep-Touch-Wake-Up.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/ESP32-Deep-Sleep-Touch-Wake-Up.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/ESP32-Deep-Sleep-Touch-Wake-Up.jpg?resize=1536%2C864&amp;quality=100&amp;strip=all&amp;ssl=1 1536w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/ESP32-Deep-Sleep-Touch-Wake-Up.jpg?w=1920&amp;quality=100&amp;strip=all&amp;ssl=1 1920w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p class=\"rntbox rntclgray\"><em>Updated 8 October 2024.<\/em><\/p>\n\n\n\n<p>The ESP32 can be awake from deep sleep using several wake-up sources: <a href=\"https:\/\/randomnerdtutorials.com\/esp32-timer-wake-up-deep-sleep\/\" title=\"\">timer<\/a>, <a href=\"https:\/\/randomnerdtutorials.com\/esp32-external-wake-up-deep-sleep\/\" title=\"\">external wake-up<\/a>, and touch wake-up. This article shows how to use touch wake-up.<\/p>\n\n\n\n<p>To learn more about deep sleep and other wake-up sources, you can follow the next tutorials:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-deep-sleep-arduino-ide-wake-up-sources\/\"><strong>[Complete Guide]<\/strong> ESP32 Deep Sleep with Arduino IDE and Wake-Up Sources<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-external-wake-up-deep-sleep\/\">ESP32 External Wake-Up from Deep Sleep<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-timer-wake-up-deep-sleep\/\">ESP32 Timer Wake Up from Deep Sleep<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Writing a Deep Sleep Sketch<\/h2>\n\n\n\n<p>To write a sketch to put your ESP32 into deep sleep mode, and then wake it up, you need to:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>First, configure the wake-up sources. This means configuring what will wake up the ESP32. You can use one or combine more than one wake-up source. This tutorial covers how to use the touch pins as a wake-up source. For that, use the <span class=\"rnthl rntliteral\">touchSleepWakeUpEnable()<\/span> function and pass as arguments the touch pin and the touch threshold.<\/li>\n\n\n\n<li>You can decide what peripherals to shut down or keep on during deep sleep. However, by default, the ESP32 automatically powers down the peripherals that are not needed with the wake-up source you define.<\/li>\n\n\n\n<li>Finally, you use the <span class=\"rnthl rntliteral\">esp_deep_sleep_start()<\/span> function to put your ESP32 into deep sleep mode.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Touch Wake Up<\/h2>\n\n\n\n<p>The ESP32 board has 10 capacitive touch GPIOs (that might change depending on the ESP32 chip). These GPIOs can sense variations in anything that holds an electrical charge, like the human skin. So they can detect variations induced when touching the GPIOs with a finger. These ESP32 touch pins can be used to wake up the ESP32 from deep sleep.<\/p>\n\n\n<div class=\"wp-block-image is-resized\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"302\" height=\"303\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/touch-wake-up.png?resize=302%2C303&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Touch Wake Up\" class=\"wp-image-81691\" style=\"width:188px;height:auto\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/touch-wake-up.png?w=302&amp;quality=100&amp;strip=all&amp;ssl=1 302w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/touch-wake-up.png?resize=150%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 150w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/touch-wake-up.png?resize=300%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/touch-wake-up.png?resize=80%2C80&amp;quality=100&amp;strip=all&amp;ssl=1 80w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/touch-wake-up.png?resize=220%2C220&amp;quality=100&amp;strip=all&amp;ssl=1 220w\" sizes=\"(max-width: 302px) 100vw, 302px\" \/><\/figure><\/div>\n\n\n<p class=\"rntbox rntclgreen\">Learn more about the ESP32 touch pins: <a href=\"https:\/\/randomnerdtutorials.com\/esp32-touch-pins-arduino-ide\/\">ESP32 Capacitive Touch Sensor Pins with Arduino IDE<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Touch Pins<\/h3>\n\n\n\n<p>The ESP32 touch pins are highlighted in pink color in the following diagram.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"538\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/ESP32-DOIT-DEVKIT-V1-Board-Pinout-36-GPIOs-updated.jpg?resize=750%2C538&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-72102\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/ESP32-DOIT-DEVKIT-V1-Board-Pinout-36-GPIOs-updated.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2018\/08\/ESP32-DOIT-DEVKIT-V1-Board-Pinout-36-GPIOs-updated.jpg?resize=300%2C215&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>You can see that touch sensor 0 corresponds to GPIO 4, touch sensor 2 to GPIO 2, and so on.<\/p>\n\n\n\n<p><strong>Learn everything you need to know about the ESP32 GPIOs<\/strong>: <a href=\"https:\/\/randomnerdtutorials.com\/esp32-pinout-reference-gpios\/\">ESP32 Pinout Reference: Which GPIO pins should you use?<\/a><\/p>\n\n\n\n<p>If you&#8217;re using an ESP32 with the S3 chip, <a href=\"https:\/\/randomnerdtutorials.com\/esp32-s3-devkitc-pinout-guide\/\" title=\"\">check this GPIOs guide instead<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Enable Touch Wake-Up<\/h3>\n\n\n\n<p>Enabling the ESP32 to wake up using a touchpin is simple. In the Arduino IDE, you need to use the following function\u2014pass as argument the touch pin and the touch threshold:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>touchSleepWakeUpEnable(TOUCH_PIN, THRESHOLD);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Code &#8211; Touch Wake-Up<\/h3>\n\n\n\n<p>To program the ESP32 we\u2019ll use Arduino IDE. So, you need to make sure you have the ESP32 core installed. Follow the next tutorial if you haven\u2019t already:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/installing-esp32-arduino-ide-2-0\/\">Installing ESP32 Board in Arduino IDE 2 (Windows, Mac OS X, Linux)<\/a><\/li>\n<\/ul>\n\n\n\n<p>Let\u2019s see how touch wake-up works using an example from the ESP32 Arduino core. Open your Arduino IDE, and go to <strong>File&nbsp;<\/strong>&gt;&nbsp;<strong>Examples&nbsp;<\/strong>&gt;&nbsp;<strong>ESP32<\/strong> <strong>Deep Sleep<\/strong>, and open the <strong>TouchWakeUp <\/strong>example sketch.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*\nDeep Sleep with Touch Wake Up\n=====================================\nThis code displays how to use deep sleep with\na touch as a wake up source and how to store data in\nRTC memory to use it over reboots\n\nESP32 can have multiple touch pads enabled as wakeup source\nESP32-S2 and ESP32-S3 supports only 1 touch pad as wakeup source enabled\n\nThis code is under Public Domain License.\n\nAuthor:\nPranav Cherukupalli &lt;cherukupallip@gmail.com&gt;\n*\/\n\n#if CONFIG_IDF_TARGET_ESP32\n#define THRESHOLD 40   \/* Greater the value, more the sensitivity *\/\n#else                  \/\/ESP32-S2 and ESP32-S3 + default for other chips (to be adjusted) *\/\n#define THRESHOLD 5000 \/* Lower the value, more the sensitivity *\/\n#endif\n\nRTC_DATA_ATTR int bootCount = 0;\ntouch_pad_t touchPin;\n\/*\nMethod to print the reason by which ESP32\nhas been awaken from sleep\n*\/\nvoid print_wakeup_reason() {\n  esp_sleep_wakeup_cause_t wakeup_reason;\n\n  wakeup_reason = esp_sleep_get_wakeup_cause();\n\n  switch (wakeup_reason) {\n    case ESP_SLEEP_WAKEUP_EXT0:     Serial.println(&quot;Wakeup caused by external signal using RTC_IO&quot;); break;\n    case ESP_SLEEP_WAKEUP_EXT1:     Serial.println(&quot;Wakeup caused by external signal using RTC_CNTL&quot;); break;\n    case ESP_SLEEP_WAKEUP_TIMER:    Serial.println(&quot;Wakeup caused by timer&quot;); break;\n    case ESP_SLEEP_WAKEUP_TOUCHPAD: Serial.println(&quot;Wakeup caused by touchpad&quot;); break;\n    case ESP_SLEEP_WAKEUP_ULP:      Serial.println(&quot;Wakeup caused by ULP program&quot;); break;\n    default:                        Serial.printf(&quot;Wakeup was not caused by deep sleep: %d\\n&quot;, wakeup_reason); break;\n  }\n}\n\n\/*\nMethod to print the touchpad by which ESP32\nhas been awaken from sleep\n*\/\nvoid print_wakeup_touchpad() {\n  touchPin = esp_sleep_get_touchpad_wakeup_status();\n\n#if CONFIG_IDF_TARGET_ESP32\n  switch (touchPin) {\n    case 0:  Serial.println(&quot;Touch detected on GPIO 4&quot;); break;\n    case 1:  Serial.println(&quot;Touch detected on GPIO 0&quot;); break;\n    case 2:  Serial.println(&quot;Touch detected on GPIO 2&quot;); break;\n    case 3:  Serial.println(&quot;Touch detected on GPIO 15&quot;); break;\n    case 4:  Serial.println(&quot;Touch detected on GPIO 13&quot;); break;\n    case 5:  Serial.println(&quot;Touch detected on GPIO 12&quot;); break;\n    case 6:  Serial.println(&quot;Touch detected on GPIO 14&quot;); break;\n    case 7:  Serial.println(&quot;Touch detected on GPIO 27&quot;); break;\n    case 8:  Serial.println(&quot;Touch detected on GPIO 33&quot;); break;\n    case 9:  Serial.println(&quot;Touch detected on GPIO 32&quot;); break;\n    default: Serial.println(&quot;Wakeup not by touchpad&quot;); break;\n  }\n#else\n  if (touchPin &lt; TOUCH_PAD_MAX) {\n    Serial.printf(&quot;Touch detected on GPIO %d\\n&quot;, touchPin);\n  } else {\n    Serial.println(&quot;Wakeup not by touchpad&quot;);\n  }\n#endif\n}\n\nvoid setup() {\n  Serial.begin(115200);\n  delay(1000);  \/\/Take some time to open up the Serial Monitor\n\n  \/\/Increment boot number and print it every reboot\n  ++bootCount;\n  Serial.println(&quot;Boot number: &quot; + String(bootCount));\n\n  \/\/Print the wakeup reason for ESP32 and touchpad too\n  print_wakeup_reason();\n  print_wakeup_touchpad();\n\n#if CONFIG_IDF_TARGET_ESP32\n  \/\/Setup sleep wakeup on Touch Pad 3 + 7 (GPIO15 + GPIO 27)\n  touchSleepWakeUpEnable(T3, THRESHOLD);\n  touchSleepWakeUpEnable(T7, THRESHOLD);\n\n#else  \/\/ESP32-S2 + ESP32-S3\n  \/\/Setup sleep wakeup on Touch Pad 3 (GPIO3)\n  touchSleepWakeUpEnable(T3, THRESHOLD);\n\n#endif\n\n  \/\/Go to sleep now\n  Serial.println(&quot;Going to sleep now&quot;);\n  esp_deep_sleep_start();\n  Serial.println(&quot;This will never be printed&quot;);\n}\n\nvoid loop() {\n  \/\/This will never be reached\n}\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Learn-ESP32-eBook\/raw\/main\/Module_4\/4_3_touch_wake_up\/4_3_touch_wake_up.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Setting the Threshold<\/h3>\n\n\n\n<p>The first thing you need to do is setting a threshold value for the touch pins.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define THRESHOLD 40 \/\/ Greater the value, more the sensitivity<\/code><\/pre>\n\n\n\n<p>The values read by a touch pin decrease when you touch it. The threshold value means that the ESP32 will wake up when the value read on the touch pin is below 40. You can adjust that value depending on the desired sensitivity.<\/p>\n\n\n\n<p><strong>Important:<\/strong> however, if you\u2019re using an ESP32-S2 or ESP32-S3 model, things work a little<br>differently. That\u2019s why there\u2019s a different section in the code defining a different threshold for those boards. In this case, the lower the value, the more the sensitivity.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#if CONFIG_IDF_TARGET_ESP32\n#define THRESHOLD 40 \/\/ Greater the value, more the sensitivity\n#else \/\/ ESP32-S2 and ESP32-S3 + default for other chips (to be adjusted)\n#define THRESHOLD 5000 \/\/ Lower the value, more the sensitivity\n#endif<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Setting Touch Pins as a Wake-up Source<\/h3>\n\n\n\n<p>To set a touch pin as a wake-up source, you can use the <span class=\"rnthl rntliteral\">touchSleepWakeUpEnable()<\/span> function that accepts as arguments the touch pin and the threshold value that will wake up the board.<\/p>\n\n\n\n<p>In this example, it sets GPIO 15 (T3) and GPIO 27 (T7) as wake-up sources with the same threshold value.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#if CONFIG_IDF_TARGET_ESP32\n  \/\/ Setup sleep wakeup on Touch Pad 3 + 7 (GPIO15 + GPIO 27)\n  touchSleepWakeUpEnable(T3, THRESHOLD);\n  touchSleepWakeUpEnable(T7, THRESHOLD);<\/code><\/pre>\n\n\n\n<p>If you\u2019re using an ESP32-S2 or S3 model, the example just defines wake-up on GPIO 3 (T3). Note that the touch pin numbering might be different depending on the board model you\u2019re using.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#else \/\/ ESP32-S2 + ESP32-S3\n  \/\/ Setup sleep wakeup on Touch Pad 3 (GPIO3)\n  touchSleepWakeUpEnable(T3, THRESHOLD);<\/code><\/pre>\n\n\n\n<p>Finally, call the <span class=\"rnthl rntliteral\">esp_deep_sleep_start()<\/span> to put the ESP32 in deep sleep mode.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>esp_deep_sleep_start();<\/code><\/pre>\n\n\n\n<p>These were the general instructions to set up touch pins as a wake-up source. Now, let\u2019s take a look at the other sections of the code.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">setup()<\/h3>\n\n\n\n<p>When the ESP32 wakes up from sleep, it will run the code from the start until it finds the <span class=\"rnthl rntliteral\">esp_deep_sleep_start()<\/span> function.<\/p>\n\n\n\n<p>In this particular example, we have a control variable called <span class=\"rnthl rntliteral\">bootCount<\/span> that will be increased between each sleep cycle so that we have an idea of how many times the ESP32 woke up.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ Increment boot number and print it every reboot\n++bootCount;\nSerial.println(\"Boot number: \" + String(bootCount));<\/code><\/pre>\n\n\n\n<p>We also call the <span class=\"rnthl rntliteral\">print_wakeup_reason()<\/span> and <span class=\"rnthl rntliteral\">print_wakeup_touchpad()<\/span> functions defined earlier in the code to print the wake-up reason and the pin that caused the wake-up.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ Print the wakeup reason for ESP32 and touchpad too\nprint_wakeup_reason();\nprint_wakeup_touchpad();<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Wiring the Circuit<\/h3>\n\n\n\n<p>To test this example, wire a jumper wire to GPIO 15 and\/or GPIO 27, as shown in the schematic below.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"858\" height=\"349\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/Zero_Touch_Wake_Up_bb.png?resize=858%2C349&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Touch wake up Wiring the Circuit\" class=\"wp-image-81674\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/Zero_Touch_Wake_Up_bb.png?w=858&amp;quality=100&amp;strip=all&amp;ssl=1 858w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/Zero_Touch_Wake_Up_bb.png?resize=300%2C122&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/02\/Zero_Touch_Wake_Up_bb.png?resize=768%2C312&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 858px) 100vw, 858px\" \/><\/figure><\/div>\n\n\n<p>If you\u2019re using an ESP32-S2 or <a href=\"https:\/\/randomnerdtutorials.com\/esp32-s3-devkitc-pinout-guide\/\" title=\"\">ESP32-S3 model<\/a>, please check the location of your touch pins.<\/p>\n\n\n\n<p><strong>Parts Required:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/esp32-dev-board-wi-fi-bluetooth\/\" target=\"_blank\" rel=\"noreferrer noopener\">ESP32 development board<\/a>&nbsp;(read&nbsp;<a href=\"https:\/\/makeradvisor.com\/esp32-development-boards-review-comparison\/\" target=\"_blank\" rel=\"noreferrer noopener\">ESP32 development boards comparison<\/a>) <\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/jumper-wires-kit-120-pieces\/\" target=\"_blank\" rel=\"noreferrer noopener\">Jumper wires<\/a> <\/li>\n<\/ul>\n\n\n<p>You can use the preceding links or go directly to <a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\">MakerAdvisor.com\/tools<\/a> to find all the parts for your projects at the best price!<\/p><p style=\"text-align:center;\"><a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/10\/header-200.png?w=1200&#038;quality=100&#038;strip=all&#038;ssl=1\"><\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Testing the Example<\/h3>\n\n\n\n<p>Upload the code to your ESP32, and open the Serial Monitor at a baud rate of 115200.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"41\" height=\"39\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/serial-monitor-logo-arduino-ide-2.png?resize=41%2C39&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-148549\"\/><\/figure><\/div>\n\n\n<p>The ESP32 goes into deep sleep mode.<\/p>\n\n\n\n<p>You can wake it up by touching the wire connected to Touch Pin 3.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"421\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/10\/ESP32-Touch-Sensor-Pins-Arduino-IDE.jpg?resize=750%2C421&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Touch Sensor Pins Arduino IDE\" class=\"wp-image-163125\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/10\/ESP32-Touch-Sensor-Pins-Arduino-IDE.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/10\/ESP32-Touch-Sensor-Pins-Arduino-IDE.jpg?resize=300%2C168&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>When you touch the pin, the ESP32 displays on the Serial Monitor: the boot number, the wake-up cause, and which touch-sensitive GPIO caused the wake-up.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"694\" height=\"366\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/ESP32_testing_touch_wake_up.png?resize=694%2C366&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Testing ESP32 touch pins as a wake-up source Serial Monitor Demonstration\" class=\"wp-image-162959\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/ESP32_testing_touch_wake_up.png?w=694&amp;quality=100&amp;strip=all&amp;ssl=1 694w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/ESP32_testing_touch_wake_up.png?resize=300%2C158&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 694px) 100vw, 694px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>In this article, we\u2019ve shown you how to wake up the ESP32 using the touch-sensitive GPIOs. In summary:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>First, define the wake-up source by calling the <span class=\"rnthl rntliteral\">touchSleepWakeUpEnable()<\/span> function and pass as arguments the touch pin and the threshold value.<\/li>\n<\/ul>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Then, use the <span class=\"rnthl rntliteral\">esp_deep_sleep_start()<\/span> function to put the ESP32 in deep sleep mode.<\/li>\n<\/ul>\n\n\n\n<p>You can learn more about deep sleep with the ESP32 with our complete guide: <a rel=\"noreferrer noopener\" href=\"https:\/\/randomnerdtutorials.com\/esp32-deep-sleep-arduino-ide-wake-up-sources\/\" target=\"_blank\">ESP32 Deep Sleep with Arduino IDE and Wake Up Sources<\/a>.<\/p>\n\n\n\n<p>If you like ESP32, you may also like the following resources:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><a href=\"https:\/\/randomnerdtutorials.com\/learn-esp32-with-arduino-ide\/\">Learn ESP32 with Arduino IDE (course)<\/a><\/strong><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-web-server-with-bme280-mini-weather-station\/\">ESP32 Web Server with BME280 \u2013 Mini Weather Station<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-web-server-arduino-ide\/\">ESP32 Web Server with Arduino IDE \u2013 control outputs<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-dht11-dht22-temperature-humidity-web-server-arduino-ide\/\">ESP32 DHT11\/DHT22 Temperature Web Server<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/projects-esp32\/\" title=\"\">&gt;&gt; More Free ESP32 Tutorials and Guides &lt;&lt;<\/a><\/li>\n<\/ul>\n\n\n\n<p class=\"rntbox rntclgray\">This is an excerpt from our course: <a href=\"https:\/\/randomnerdtutorials.com\/learn-esp32-with-arduino-ide\/\">Learn ESP32 with Arduino IDE<\/a>. If you like ESP32 and you want to learn more, we recommend enrolling in&nbsp;<a href=\"https:\/\/randomnerdtutorials.com\/learn-esp32-with-arduino-ide\/\">Learn ESP32 with Arduino IDE course<\/a>.   <\/p>\n","protected":false},"excerpt":{"rendered":"<p>This guide shows how to wake up the ESP32 from deep sleep using the touch-sensitive pins. The ESP32 will be programmed using Arduino IDE. Updated 8 October 2024. The ESP32 &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"ESP32 Touch Wake Up from Deep Sleep\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/esp32-touch-wake-up-deep-sleep\/#more-83645\" aria-label=\"Read more about ESP32 Touch Wake Up from Deep Sleep\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":162961,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[276,281,277,299,230,264],"tags":[],"class_list":["post-83645","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp32","category-esp32-project","category-esp32-arduino-ide","category-0-esp32","category-guide","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/04\/ESP32-Deep-Sleep-Touch-Wake-Up.jpg?fit=1920%2C1080&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/83645","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=83645"}],"version-history":[{"count":8,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/83645\/revisions"}],"predecessor-version":[{"id":163136,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/83645\/revisions\/163136"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/162961"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=83645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=83645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=83645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}