当前位置:网站首页>Understand esp32 sleep mode and its power consumption
Understand esp32 sleep mode and its power consumption
2022-07-01 06:37:00 【Morning breeze】
Translated by Chen Tuo 2022/05/30-2022/05/30
original text https://lastminuteengineers.com/esp32-sleep-modes-power-consumption/
without doubt ,ESP32 It's a lot of WiFi/MCU SOC A strong competitor of , Often beat it in performance and price . however , According to its state ,ESP32 It may be a relatively power consuming device .
When your Internet of things project is powered by a plug on the wall , You often don't care much about power consumption . But if you plan to use batteries to power your project , Every milliampere is important .
The solution here is to use ESP32 A sleep mode to reduce its power consumption . For projects that do not need to be active all the time , This is really a good strategy to greatly extend battery life .
What is? ESP32 Sleep mode ?
ESP32 Sleep mode is a power-saving state ,ESP32 You can enter this state when not in use .ESP32 The state of remains RAM in . When ESP32 When entering sleep mode , The power supply of any unwanted digital peripheral devices will be cut off , and RAM The received power is just enough to retain data .
ESP32 Inside the chip
In order to understand ESP32 How to save energy , We need to know what is inside the chip . The image below shows ESP32 Functional block diagram of the chip .
ESP32 The core of the chip is a dual core 32 Bit microprocessor , with 448 KB Of ROM、520 KB Of SRAM and 4MB Flash memory .
It also contains WiFi modular 、 Bluetooth module 、 Encryption Accelerator ( A coprocessor designed to perform cryptographic operations )、RTC Modules and many peripherals .
ESP32 Power mode
because ESP32 Advanced power management , It provides 5 Configurable power modes . According to the power requirements , The chip can switch between different power modes . Patterns include :
- Activity mode
- Modem sleep mode
- Light sleep mode
- Deep sleep mode
- Sleep mode
Each mode has its unique function and energy saving function . Let's take a look one by one .
ESP32 Activate mode
Normal mode is also called active mode . In this mode , All functions of the chip are active .
Because the active mode makes everything ( In especial WiFi modular 、 Processing core and Bluetooth module ) Always on , So the chip needs 240mA The above current can work . We also observed that , If used at the same time WiFi And Bluetooth , Sometimes high power peaks occur ( The maximum is 790mA).
If you look at ESP32 Data sheet , In case of RF operation , The power consumption in active power mode is as follows :

obviously , This is the most inefficient model , Will consume the most current . therefore , If we want to save electricity , We must disable them when not in use ( By using one of the other power modes ).
ESP32 Modem sleep
In modem sleep mode , Everything is active , And only WiFi、 Bluetooth and wireless communication are disabled .CPU It can also run , The clock can be configured .
In this mode , The chip consumes about... At low speed 3mA, Consumption at high speed 20mA.
In order to maintain WiFi/ Bluetooth connection is active ,CPU、Wi-Fi、 Bluetooth and wireless communication will wake up at predefined intervals . This is called associative sleep patterns .
During this sleep mode , Power mode switches between active mode and modem sleep mode .
ESP32 Only in order to Station Mode can enter the modem sleep mode only when it is connected to the router .ESP32 adopt DTIM The beacon mechanism keeps the connection with the router .
To save power ,ESP32 In two DTIM Between beacon intervals... Is disabled Wi-Fi modular , And automatically wake up before the next beacon arrives .
The sleep time is determined by the router DTIM Beacon interval determines , Usually it is 100ms To 1000ms.
What is? DTIM Beacon mechanism ?
DTIM It's English Delivery Traffic Indication Message abbreviation .
stay DTIM beacon (DTIM-Beacon) In mechanism , Access point (AP)/ The router sends beacon frames regularly . Each frame contains all the information about the network . It is used to announce the existence of wireless networks and synchronize all connected members .
ESP32 Light sleep
The working mode of light sleep is similar to modems Sleep works in a similar way . The chip also follows an associated sleep pattern .
The difference lies in , In light sleep mode , Digital peripherals 、 majority RAM and CPU All are clock gated .
What is clock gating ?
Clock gating is a technique to reduce dynamic power consumption .
It disables some circuits by turning off the clock pulse , In this way, the trigger in the circuit does not have to switch states . Switching states requires power consumption , If you don't switch , Power consumption will become zero .
In light sleep mode ,CPU Pause by turning off its clock , and RTC and ULP The coprocessor remains active . This results in lower power consumption than modem sleep mode ( about 0.8mA).
Before entering light sleep mode ,ESP32 Maintain its internal state , And resume operation after quitting sleep . It is called all RAM Retain .
esp_light_sleep_start() Function can be used to enter light sleep after configuring the wake-up source .
ESP32 Deep sleep
In deep sleep mode ,CPU、 Most of the RAM And all digital peripherals will be powered off . The only part of the chip that remains powered on is :RTC controller 、RTC Peripherals ( Include ULP Coprocessor ) and RTC Memory ( Slow and fast ).
The power consumption of the chip is about 0.15 mA( If ULP The coprocessor is powered ) to 10µA.
In deep sleep mode , Lord CPU power failure , and ULP The coprocessor measures the sensor according to the measured data of the sensor and wakes up the main system . This sleep pattern is called ULP Sensor monitoring mode .
except CPU outside , The main memory of the chip is also disabled . therefore , All contents stored in this memory will be erased , cannot access .
however ,RTC The memory remains powered on . therefore , Its contents are preserved during deep sleep , We can retrieve the chip after we wake it up . That's why , The chip is disabled Wi-Fi Before connecting data with Bluetooth , Will store it in RTC In the memory .
therefore , If you want to use data on reboot , Please define with RTC_DATA_ATTR Property to store it in RTC In the memory . for example ,RTC_DATA_ATTR int bootCount = 0;
In deep sleep mode , except RTC Outside the module , The power supply of the whole chip is cut off . therefore , Anything is not in RTC All data in the recovery memory will be lost , So the chip will restart by resetting . This means that the program is executed again from the beginning .
Tips
ESP32 Support running deep sleep wake-up stubs after deep sleep stub. This function runs immediately after the chip wakes up – Before any normal initialization , Boot loader code runs . After the wake-up stub runs , The chip can resume sleep or continue normal startup .
stub The official description of :
https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/deep-sleep-stub.html
Different from other sleep patterns , The system cannot automatically enter deep sleep mode .esp_deep_sleep_start() Function can be used to enter deep sleep immediately after the wake source is configured .
By default ,ESP32 It will automatically turn off the power of peripheral devices that are not needed by the wake-up source . But you can choose to close / What peripherals are kept . For more information , Please check out API file :
https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/
To learn about ESP32 More about deep sleep and its wake-up sources , Please visit the following tutorial .
https://lastminuteengineers.com/esp32-deep-sleep-wakeup-sources/
ESP32 Deep sleep experiment
Here is my experimental article 《ESP32 How is the deep sleep current lower than 10uA》
https://zhuanlan.zhihu.com/p/521640890
https://blog.csdn.net/chentuo2000/article/details/125033711?spm=1001.2014.3001.5502
ESP32 Sleep mode
Different from deep sleep mode , In sleep mode , The chip also disables internal 8MHz Oscillator and ULP Coprocessor .RTC The recovery memory has also been powered off , This means that we cannot keep any data in sleep mode .
There is only one on the slow clock RTC Timers and some RTC GPIO Out of active ( They are responsible for waking the chip from sleep mode ), All other functions are turned off .
This further reduces power consumption . The chip only consumes about... In sleep mode 2.5µA.

边栏推荐
- How to use SCI hub
- DSBridge
- [ITSM] what is ITSM and why does it department need ITSM
- 问题解决:OfficeException: failed to start and connect(一)
- C语言课设销售管理系统设计(大作业)
- [ManageEngine Zhuohao] use unified terminal management to help "Eurex group" digital transformation
- Database notes
- Resttemplate use
- Software engineering review
- Storage function learning notes
猜你喜欢
![[unity shader custom material panel part II]](/img/d1/8632ae680299a27b7431b2d6e03fd3.png)
[unity shader custom material panel part II]
![[wechat applet low code development] second, resolve the code composition of the applet in practice](/img/ab/28ab01db84b1437220e659118b2871.png)
[wechat applet low code development] second, resolve the code composition of the applet in practice

C语言课设职工信息管理系统(大作业)

Software engineering review

Application of IT service management (ITSM) in Higher Education

Async and await

Record MySQL troubleshooting caused by disk sector damage
![[enterprise data security] upgrade backup strategy to ensure enterprise data security](/img/59/e44c6533aa546e8854ef434aa64113.png)
[enterprise data security] upgrade backup strategy to ensure enterprise data security

Free trial of self-developed software noisecreater1.1

【微信小程序】如何搭积木式开发?
随机推荐
Resttemplate use
Software engineering review
启牛学堂合作的证券公司是哪家?开户安全吗?
Internet worm
[ITSM] what is ITSM and why does it department need ITSM
MySQL constraint learning notes
伪装请求头库: anti-useragent
产品学习(三)——需求列表
Database notes
TCL statements in SQL (transaction control statements)
mysql学习
Stored procedure learning notes
C#如何打印輸出原版數組
Router 6/ 以及和Router5 的区别
清除过期缓存条目后可用空间仍不足 - 请考虑增加缓存的最大空间
C语言课设工资管理系统(大作业)
2022 年江苏省职业院校技能大赛(中职) 网络搭建与应用赛项公开赛卷
[ManageEngine] terminal management system helps Huasheng securities' digital transformation
[unity shader custom material panel part II]
JSON module