Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Sensor Series
      • 3D Printing
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
  • Guest Post Guidelines
  • Advertise
  • Subscribe

How to wake ESP32 from deep sleep using EXT1

By Nikhil Agnihotri March 4, 2025

In the previous project, we discussed how to wake ESP32 using EXT0. ESP32 supports five power modes: active, modem sleep, light sleep, deep sleep, and hibernation. For battery-powered or Internet-of-Things (IoT) applications, deep sleep mode is particularly useful.

In this mode, the ESP32 powers down most components, including the CPU, flash memory, Wi-Fi, Bluetooth, and peripherals. It “wakes up” in response to specific triggers such as a timer, touch, EXT0, EXT1, UART, or RTC. Deep sleep mode significantly conserves battery life and operates the controller only if needed.

There are two ways to wake ESP32 from deep sleep using external signals: EXT0 and EXT1. We already demonstrated how to use EXT0, which allows the board to wake up via an external signal on a specific RTC GPIO. However, EXT0 is limited to a single “wake-up” source.

In contrast, the EXT1 enables ESP32 to wake from multiple external sources and can even detect which GPIO triggered this. The board can then be programmed to execute different tasks based on the specific GPIO or external trigger source, such as a button press, sensor input, or any signal generating a defined falling or rising edge.

In this project, we’ll demonstrate how to wake the ESP32 from deep sleep using EXT1 and detect which GPIO triggered it. Based on the trigger source, the board will execute different tasks. Specifically, we will configure two external wake-up sources: GPIO36 and GPIO39.

  • If the GPIO36 triggers ESP32 to wake, the LED will blink twice.
  • If the GPIO39 triggers ESP32 to wake, the LED will blink five times.

While this example uses LED blinking for demonstration purposes, any task can be executed based on the external trigger. Additionally, specific console messages will be printed to the serial port for each trigger event.

Using EXT1

EXT1 lets ESP32 to wake up using multiple RTC GPIOs. While EXT0 uses the RTC input/output to trigger waking, EXT1 uses the RTC controller instead. As a result, RTC peripherals and RTC memories need not be powered during the deep sleep.

EXT1 also allows for multiple “wake-up” sources with different logic. Similar to EXT0, EXT1 only uses the RTC GPIOs. The available RTC GPIOs vary slightly between ESP32 chip revisions as follows:

  • ESP32-S3: GPIOs 0-21
  • ESP32: GPIOs 0, 2, 4, 12-15, 25-27, 32-39
  • ESP32-S2: GPIOs 0-21

To configure EXT1 on ESP32, the esp_sleep_enable_ext1_wakeup_io() function must be called. It has this prototype:

esp_sleep_enable_ext1_wakeup_io(bitmask, mode);

Where…

bitmask: this 64-bit integer represents the GPIO pins used to wake ESP32. Each bit within the bitmask corresponds to an RTC GPIO pin. If a bit is set (1), that pin is enabled for wake-up. If a bit is clear (0), that pin is disabled for the wake-up. Typically, bitwise operations like OR (|), AND (&), and bit shifts (<<) are used to create the bitmask.

mode: specifies the logic that triggers the wake-up. There are two possible modes:

  • ESP_SLEEP_WAKEUP_ANY_HIGH: ESP32 will wake if any of the enabled GPIOs (those with a ‘1’ in the bitmask) are HIGH. This is an “OR” condition.
  • ESP_SLEEP_WAKEUP_ALL_LOW: ESP32 will wake only if all of the enabled GPIOs (those with a ‘1’ in the bitmask) are LOW simultaneously. This is an “AND” condition.

For ESP32-S2, ESP32-S3, ESP32-C6, or ESP32-H2, the available modes are following.

  • ESP_EXT1_WAKEUP_ANY_LOW: ESP32 will wake if any of the enabled GPIOs (those with a ‘1’ in the bitmask) are LOW.
  • ESP_EXT1_WAKEUP_ANY_HIGH: ESP32 will wake if any of the enabled GPIOs (those with a ‘1’ in the bitmask) are HIGH.

Like with EXT0, EXT1 can also use the RTC fast memory for data storage during deep sleep. This allows for storing data that must be preserved across sleep cycles and is extremely useful for keeping track of how many times ESP32 has woken up, storing sensor readings, and more.

To store a variable in RTC memory, use the RTC_DATA_ATTR attribute. For example:

RTC_DATA_ATTR int bootCount = 0;

This declaration tells the compiler to place the bootCount variable into RTC memory. The value of the bootCount is retained even when ESP32 is in deep sleep. However, it’s important to note that the RTC memory is typically erased when ESP32 is powered down or reset.

Using EXT1 

Now, let’s implement EXT1 to wake the ESP32. In this project, we’ll configure ESP32 so it detects a rising wake-up signal from two push buttons connected to the GPIO36 and GPIO39. Upon waking, the ESP32 will perform the following tasks before re-entering deep sleep:

  1. Update and display the boot count.
  2. Identify and print the wake-up source (EXT1).
  3. If GPIO36 triggered the wake-up, blink the LED twice and print specific messages to the serial port.
  4. If GPIO39 triggered the wake-up, blink the LED five times and print specific messages to the serial port.
  5. After completing the designated tasks, re-enter deep sleep mode.

Components

  1. ESP32 x1
  2. Push button x2
  3. LED x1
  4. 10K resistors x3
  5. Breadboard x1
  6. Jumper wires
  7. MicroUSB cable to connect ESP32 with your computer

Circuit connections

Begin by interfacing an LED with ESP32’s GPIO23. Connect an LED’s cathode to ESP32’s GPIO and its anode to the ground. You’ll note, it’s impossible to interface the LED to GPIO34, GPIO35, GPIO36, or GPIO39 as these pins cannot be configured as digital output on ESP32.

So, we’ve interfaced an LED with ESP32’s GPIO23. Next, interface two pushbuttons, one at the GPIO36 and the other at the GPIO39 with an external pull-up. The circuit diagram is below.

The sketch

After making circuit connections, upload the following sketch to ESP32.

You may also like:


  • How to capture images using ESP32-CAM and an SD card

  • The top IoT projects for enhancing everyday life

  • How ESP32 boards can communicate without a router or the…

  • How to troubleshoot common ESP32-CAM problems

  • How to manage data on ESP32 for IoT projects

  • How to build a portable WiFi repeater using ESP32 or…

  • How to send SMS alerts from ESP32 without a GSM…

Filed Under: Electronic Projects, Video
Tagged With: electronicproject, ESP32, ext0, ext1, led, sleepmode, video, wakeup
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

Submit a Guest Post

submit a guest post

EE TECH TOOLBOX

“ee
Tech Toolbox: Power Efficiency
Discover proven strategies for power conversion, wide bandgap devices, and motor control — balancing performance, cost, and sustainability across industrial, automotive, and IoT systems.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions.

  • Looking for FEMM expert. Need help to assess my model.
  • PCB layout impact on RF path impedance
  • Op-Amp oscillating
  • rechargeable battery and simple alkaline battery in one single product
  • Impedance Matching Under Low Modal Significance.

RSS Electro-Tech-Online.com Discussions

  • WTB: "The Theory Of Servicing AM, FM, And FM Receivers" by Clarence R. Green and Robert M. Bourque
  • Anyone In The US Ordered From AliExpress Recently?
  • Calculation of A Class amplifier
  • strange laptop problem
  • restarting this Christmas project

Featured Tutorials

Real Time Hardware Filter Design

  • Practical implementation of bandpass and band reject filters
    Practical implementation of bandpass and band reject filters
  • Practical application of hardware filters with real-life examples
    Practical application of hardware filters with real-life examples
  • A filter design example
    A filter design example
  • Types of filter responses
    Types of filter responses
  • What are the two types of hardware filters?
    What are the two types of hardware filters?
  • What are hardware filters and their types?
    What are hardware filters and their types?
More Tutorials >

Recent Articles

  • Stackpole introduces compact jumpers for high-current circuit routing
  • Ironwood Electronics launches near-device-footprint SMT elastomer socket for BGA264
  • Amphenol RF releases P67 FAKRA plugs for 6 GHz RF transmission
  • Microchip releases platform to deliver real-time specifications for AI assistants
  • GigaDevices introduces 32-bit MCUs with integrated DSP and FPU support

EE ENGINEERING TRAINING DAYS

engineering
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Sensor Series
      • 3D Printing
      • AI
      • ARDUINO Compatible Coding
      • Audio Electronics
      • Battery Management
      • Beginners Electronics Series
      • Brainwave
      • Digital electronics (DE)
      • Electric Vehicles
      • EMI/EMC/RFI
      • EVs
      • Hardware Filters
      • IoT tutorials
      • LoRa/LoRaWAN
      • Power Tutorials
      • Protocol
      • Python
      • RPI Python Programming
      • Sensors
      • USB
      • Thermal management
      • Verilog
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
  • Guest Post Guidelines
  • Advertise
  • Subscribe