
The ESP8266 is a low-power microcontroller with integrated Wi-Fi and dual-mode Bluetooth capabilities. One of its key features is the ability to enter a deep sleep mode, significantly reducing power consumption by disabling the system clock to all peripherals except the RTC (real-time clock) module. While in deep sleep, the ESP8266 can be configured to wake up at specific intervals or through external events, such as a push button or sensor input. However, users have reported challenges in implementing certain wake-up scenarios, especially when combining timer-based and external wake-up methods. This paragraph introduces the topic of waking up the ESP8266 from deep sleep, highlighting its power-saving benefits and the various approaches for triggering a wake-up event, while also acknowledging some of the technical complexities involved.
Characteristics and Values of Waking up ESP8266 from Deep Sleep
| Characteristics | Values |
|---|---|
| Power Consumption | 20 µA |
| Maximum Sleep Time | 1 hour |
| Accuracy | 1-second accuracy over a period of 1 week |
| Wake-up Sources | Timer wake up, External wake up |
| RTC Usage | To keep track of time |
| RTC Power Consumption | 1 mA |
| ESP.deepSleep(uS) Function | To put ESP8266 into deep sleep for a set amount of time |
| Deep Sleep Cycle | 5 minutes |
| Deep Sleep Mode | Light sleep, Deep sleep |
Explore related products
What You'll Learn

Using a timer and external button
To wake up an ESP8266 from deep sleep using both a timer and an external button, you can try the following methods:
Connect GPIO 16 to the Reset Pin
Connect GPIO 16 to the reset pin to enable deep sleep functionality. Then, connect a button from the reset pin to GND. This allows you to reset the ESP8266 by pressing the button.
Use a Diode
Use a diode, instead of R or 0R, between GPIO16 and EN. This setup allows GPIO to pull EN low without affecting the other way around. Therefore, even if GPIO16 is output high when the button is pressed, there won't be any issues.
Attach an Interrupt Routine to GPIO 16
Attach an interrupt routine to GPIO 16. However, note that on the NodeMCU ESP-12E, interrupts cannot be attached to the D0/GPIO16 pin. This is because the pin is used to wake the device from deep sleep, and it needs to maintain a low level during this state.
Use a Separate Microcontroller
Use a separate, low-power microcontroller to handle the button presses and wake up the ESP8266. This approach might be overkill for a simple button press detection, but it can be useful if you want faster responses or have limited space inside the remote control.
Use a Timer Wake-Up with ESP8266
For this method, you need to connect the RST pin to GPIO 16, which is labelled as D0 on a NodeMCU board. This is a special pin with a WAKE feature. However, make sure to connect the pins only after uploading the code.
Use a Reed Sensor
If you're using the ESP8266 to detect when a mailbox is opened or closed, consider using a reed sensor. This setup can differentiate between the presence and absence of a magnet, allowing for more accurate detection.
Remember to consider the power requirements and sleep modes of your ESP8266 when implementing these methods.
Waking Up Your Arduino: Sleep Mode and Power Saving Tips
You may want to see also
Explore related products

Power consumption considerations
Deep sleep mode is an effective way to significantly reduce power consumption. In this mode, the system clock to all peripherals is disabled, except for the Real-Time Clock (RTC) module, which is used to keep track of time. The ESP8266 chip consumes approximately 20 µA in deep sleep mode. However, when used with a development board, such as NodeMCU, the current consumption can exceed 20 µA due to other onboard components.
To further optimize power efficiency, consider the following:
- External Wake-up vs. Timer-based Sleep: The ESP8266 can be woken up by external events or timers. If you require flexible wake-up intervals, consider using an external wake-up mechanism, such as a push button or sensor input. This allows the ESP8266 to remain in deep sleep until manually triggered.
- Accuracy and Drift: The ESP8266's internal RTC is not highly accurate, and drift can occur over time. If precise timing is required, consider using an external RTC module, such as the DS3231, which offers better accuracy. However, keep in mind that external RTC modules may consume more power, impacting the overall power efficiency of the system.
- Sleep Duration: ESP8266's deep sleep mode has a maximum sleep time of about 1 hour. If longer sleep durations are needed, consider implementing a mechanism to periodically wake the device to check the time and initiate the next sleep cycle. This can be done by using a transistor connected to GPIO to control the power supply to the RTC module.
- Power Management: To minimize power consumption, ensure that unnecessary peripherals are disabled or disconnected when not in use. This includes disabling Wi-Fi, as it consumes power even when the device is asleep. Additionally, consider using the WAKE_RF_DISABLED option to further reduce power consumption.
- Sleep Mode Selection: Depending on your application, light sleep mode may be an alternative. Light sleep allows certain peripherals to remain active, which can be advantageous if you need to continuously monitor sensors or external events. However, light sleep consumes more power than deep sleep.
By considering these power consumption considerations and selecting the appropriate sleep mode, wake-up mechanism, and power management strategies, you can optimize the power efficiency of your ESP8266-based project.
The Sleeping Lion: A Force to Be Reckoned With
You may want to see also
Explore related products

ESP.deepSleep(uS) function
The ESP.deepSleep(uS) function is used to put the ESP8266 into a deep sleep mode, during which it will not respond to any network traffic or perform any tasks. This can be useful for battery-operated devices to conserve power. The function takes a parameter uS, which specifies the duration of the deep sleep in microseconds.
To use the ESP.deepSleep(uS) function effectively, you need to specify the duration of the node's activity using the run_duration option. This determines how long the node should be active, checking sensor values, and reporting them. It is important to note that on the ESP8266, GPIO16 must be connected to the RST pin to ensure the device wakes up after deep sleep.
When using the ESP.deepSleep(uS) function, it is important to consider power consumption. The ESP8266 is designed to consume only around 20 µA in deep sleep mode. However, when using external modules like the DS3231, higher power consumption may occur due to the need to power on the module to trigger an alarm. This can impact the overall power efficiency of the system.
Additionally, the ESP8266's deep sleep functionality has certain limitations. It does not support sleep durations greater than approximately 3.5 hours. If longer sleep periods are required, a workaround is to set shorter sleep durations and wake up periodically to check the time. This approach, however, may introduce drift, resulting in inaccurate timing.
To address the limitations of the ESP.deepSleep(uS) function, you can explore alternative solutions. One option is to use an external RTC (Real Time Clock) module, which provides more accurate timing capabilities. Another solution is to combine a timer with an external push button. This allows the device to wake up at fixed intervals and also provides the flexibility for manual wake-up using the push button.
In summary, the ESP.deepSleep(uS) function is a valuable tool for power conservation in ESP8266 devices, allowing them to enter a low-power state for a specified duration. However, it is important to consider power consumption, limitations on sleep duration, and potential workarounds or alternative solutions to achieve more complex wake-up behaviours.
Sleep Soundly: Tips for Deeper, Uninterrupted Slumber
You may want to see also
Explore related products

Real-time controller (RTC)
The Real Time Clock (RTC) is a crucial component in the ESP8266 system, as it is the only component that remains active during deep sleep mode. This allows the ESP8266 to keep track of time even when the rest of the system is inactive.
To wake up the ESP8266 from deep sleep using the RTC, there are a few methods that can be employed:
Using an External RTC
One approach is to use an external RTC module, such as the DS3231, which has higher accuracy than the internal RTC of the ESP8266. By connecting the SQW pin of the DS3231 to the RST pin of the ESP8266 via a monostable circuit, you can set an alarm to wake up the ESP8266 at a specific time. However, this method consumes more power due to the current drawn by the DS3231 module.
Periodically Checking the External RTC
Another energy-efficient solution is to periodically wake up the ESP8266 from deep sleep to check the time on the external RTC. This involves setting shorter deep sleep periods as you approach the target wake time. For example, you can wake up the ESP8266 every minute in the last 10 minutes before the desired wake-up time. This method allows for more precise timekeeping while conserving power.
Using Timer and External Button
If you want more flexibility in waking up the ESP8266, you can combine a timer with an external push button. By connecting GPIO 16 to the reset pin, you can enable deep sleep functionality. Additionally, connecting a button from the reset pin to GND allows for manual reset and wake-up. This setup provides the option for the device to wake up at hourly intervals or when triggered by the external button.
It is important to note that the ESP8266 has limitations in terms of deep sleep duration and accuracy. The deep sleep period is typically limited to around 3.5 hours, and the internal RTC may not be able to maintain high accuracy over extended periods. Therefore, the choice of method depends on the specific requirements of your application, considering factors such as power consumption, timing accuracy, and flexibility.
Crystal Energy: Can It Awaken a Sleeping Person?
You may want to see also
Explore related products

Avoiding continuous resets
To avoid continuous resets when waking an ESP8266 from deep sleep, you can try a few different approaches.
One method is to use a proper GPIO interrupt, allowing you to ignore further resets until the device goes back into deep sleep. However, it is important to note that the ESP8266 does not support GPIO interrupt wake from deep sleep. As a workaround, you can use a resettable one-shot trigger that only issues one reset until you manually put it back to sleep. This can be achieved using a circuit that allows the interrupt to reset only after the deep sleep timer has been activated.
Another approach is to use a short timeout on your deep sleep function to enable the interrupt immediately. This can be done by connecting GPIO16 to the reset pin, which will make deep sleep work. Additionally, you can connect a button from the reset pin to GND, allowing you to reset the device by pressing the button.
If you want a software-based solution, you can try the following: before calling deepsleep, write the current millis() time to rtc memory. When the device wakes up, read the millis() again and subtract the data saved in rtc memory from this time. If the time difference is close to the set sleeptime, then the device woke up due to deepsleep ending. However, if there is a significant time difference, it indicates a hardware button reset.
It is also worth noting that the ESP8266 has different sleep modes, including modem sleep, light sleep, and deep sleep. Each mode has different power consumption characteristics, and understanding these can help in avoiding continuous resets. For example, in light sleep mode, the CPU is suspended and cannot respond to signals and interrupts from internal peripherals, requiring an external GPIO trigger to wake up.
Additionally, when using deep sleep, it is important to consider the trade-off between power savings and functionality. While deep sleep reduces power consumption, it also limits the capabilities of the device. Therefore, it is crucial to strike a balance between power management and ensuring the device can perform its intended functions effectively.
Waking Up a Dell Latitude: Sleep Mode Troubleshooting
You may want to see also
Frequently asked questions
The ESP8266 can be woken from deep sleep by using a timer or an external push button. The ESP.deepSleep(uS) function can be used to put the ESP8266 into deep sleep mode for a set amount of time. However, if you want to wake it up at a specific date and time, you can set an alarm for a specific time, and when the RST pin is pulled low, the ESP8266 will wake up.
To prevent continuous resets, you can use a proper GPIO interrupt to ignore further resets until the ESP8266 is put back to sleep programmatically. You can also use a circuit with a capacitor to allow only edge triggers, and the running code can check the input signal on GPIO4.
The ESP8266 should consume only 20 µA in deep sleep, but when used with a development board, it may consume more current due to other onboard components. When waking up the ESP8266, it is important to consider the power consumption of the RTC module, which is required to trigger the alarm.


























