Section four, deep sleep in the ESP 32. In this section, we will learn the following topics. What are the sleep modes in the sparkfun ESP 32 thing implementing deep sleep in the sparkfun ESP 32 thing. Implementing external wakeup sources for deep sleep in the sparkfun ESP 32 thing. implementing an O led NTP clock with deep sleep using sparkfun ESP 32. Working with a USB coprocessor in the Arduino IDE II implementing ul Pico processor wakeup from deep sleep in the ESP 32.
Understanding that you will Pico process assembly code in the ESP 32. Deep Sleep power consumption in the sparkfun ESP 32 thing. Video. What are the sleep modes in this park? an ESP 32 thing. In this video, we will take a look at the different sleep modes in the ESP 32.
Have you ever wanted your IoT project to last on only batteries for almost three years? Wait, what? Three years? Yes, it might sound ridiculous. But this is possible with the ESP 32 deep sleep feature. There is no question that ESP 32 is a worthy competitor to many other Wi Fi enabled microcontrollers, in terms of both the price and the performance.
But depending on the application, the ESP 32 can suck in a lot of power. It usually pulls in about 75 milli amperes in normal operation, and hits about 250 milli amperes while transporting data over Wi Fi. When your IoT project is plugged into a power source, you tend not to care too much about power consumption. But if Power your project by batteries every milliampere counts. The solution here is to cut back ESP 32 power usage by leveraging the different power modes handled by the ESP 32 Advanced Power Management System. To understand how ESP 32 achieves power saving, we need to know what's inside the chip.
The following illustration shows a detailed functional block diagram of ESP 32 chip. for learning purposes, I will simplify this diagram like the following. It mainly consists of seven functional blocks, peripherals, Bluetooth module, Wi Fi module, radio, ESP 32 core and memory, cryptographic hardware accelerator RTC and RTC peripherals thanks to ESP 30 those Advanced Power Management. It offers five configurable power modes as per the power requirement. The chip can switch between different power modes. The modes are active mode, modern sleep mode, light sleep mode, deep sleep mode and hibernation mode.
Active mode is the normal mode in which all the functional gloves are active, irrespective of whether it's used or not. The chip requires more than 250 milli amperes current to operate. If you look at the ESP 32 data sheet, power consumption during active power mode is as follows. The active power mode is the most inefficient node and we'll drain the most current. In the model sleep mode. Everything is active except the Wi Fi, Bluetooth digital peripherals and radio.
In this mode, the chip consumes around three milli amperes to 20 milli amperes. But let's say we need to use the Wi Fi and Bluetooth at predefined intervals in such cases We use an association sleep pattern. During this sleep pattern, the power mode switches between the active mode and modern sleep mode. Next is the light sleep mode. the working of the light sleep mode is similar to that of modern sleep. The chip also follows Association sleep pattern.
The difference is that during lack sleep mode, digital peripherals, RAM and CPU are clock gated. So what is clock gating? clock gating is a technique for reducing dynamic power consumption. it disables potions of the secretary by powering off clock pulses, so that the flip flops in them do not have to switch states. As switching states consumes power, we're not being switched, the power consumption goes to zero. During light sleep mode, the CPU is paused by powering of its clock pulses while RTC and you will be coprocessor are kept active.
This results in less power consumption than in modern sleep mode, which is around 0.8 milli amperes. Before entering light sleep mode, ESP 32 preserves its internal state and resumed operation upon exit from the sleep. It is known as full ram retention. Now comes the deep sleep mode. in deep sleep mode, the CPU most of the RAM and all the digital peripherals are powered off. The only parts of the chip that remains powered on are RTC controller, RTC peripherals, including the ultra low power coprocessor and RTC memories.
If you will Pico processor is powered on the chip consumes around 0.15 milli amperes If not, it consumes up to 10 micro amperes. during sleep mode, the main CPU was powered down. While there you will be cool processor does sensor measurements and wakes up the main system based on the measured data from sensors. This sleep pattern is known as up sensor monitor pattern. Along with the CPU, the main memory of the chip is also disabled. So everything stored in that memory is wiped out and cannot be accessed.
However, the artisan memory is kept powered on, so its contents are preserved during deep sleep and can be retrieved after we wake the chip up. That's the reason the chip stores Wi Fi and Bluetooth connection data in RTC memory before disabling them. The most efficient sleep mode is hibernation mode. Unlike deep sleep mode, in hibernation mode, the chip disables internal eight megahertz oscillator and you will be coprocessor as well. Everything else is shut off except only one RTC timer and some art See GPIO s, they are responsible for waking up the chip from the hibernation mode. This reduces power consumption even further, the chip consumes only around 2.5 micro amperes in hibernation mode.
But the major drawback of this sleep mode is that as the RTC recovery memory is also disabled, there is no way to preserve any critical data, like Wi Fi and Bluetooth connection data during hibernation mode. Thus, this mode is rarely used. Summary In this video we have covered different sleep modes in the ESP 32. In the next video, we will go in depth about the deep sleep mode and learn how to implement