了解ESP32睡眠模式及其功耗

news/2025/1/18 13:34:21/文章来源:https://www.cnblogs.com/FBsharl/p/18678394

转载自:https://lastminuteengineers.com/esp32-sleep-modes-power-consumption/

Insight Into ESP32 Sleep Modes & Their Power Consumption

The ESP32 is undeniably a worthy competitor to many WiFi/MCU SoCs, outperforming them in both performance and price. However, depending on which mode it is in, the ESP32 can be a relatively power-hungry device.

When your IoT project is powered by an electrical outlet, power consumption is of little concern; however, if you plan to power your project with a battery, every mA counts.

The solution here is to take advantage of one of the ESP32’s sleep modes to reduce power consumption. This is an excellent strategy for significantly increasing the battery life of a project that does not need to be active all of the time.

What exactly is the ESP32 Sleep Mode?

The ESP32 sleep mode is a power-saving mode. When not in use, the ESP32 can enter this mode, storing all data in RAM. At this point, all unnecessary peripherals are disabled while the RAM receives enough power to retain its data.

Inside the ESP32 chip

Knowing what is inside the chip will help us better understand how the ESP32 manages power savings. The block diagram of the ESP32 chip is shown below.

Block Diagrams

The ESP32 chip contains a dual-core 32-bit microprocessor along with 448 KB of ROM, 520 KB of SRAM, and 4 MB of flash memory.

In addition, the chip contains a WiFi module, a Bluetooth module, a cryptographic accelerator (a co-processor designed specifically to perform cryptographic operations), an RTC module, and a number of peripherals.

ESP32 Power Modes

Thanks to the ESP32’s advanced power management, it offers five configurable power modes. According to the power requirement, the chip can switch between different power modes. These modes are:

    • Active Mode
    • Modem Sleep Mode
    • Light Sleep Mode
    • Deep Sleep Mode
    • Hibernation Mode

Each mode has distinct features and power-saving capabilities. Let’s take a look at them one by one.

ESP32 Active Mode

Normal mode is also referred to as Active Mode. In this mode, all peripherals of the chip remain active.

Since everything is always active in this mode (especially the WiFi module, processing core, and Bluetooth module), the chip consumes about 240 mA of power. It has also been observed that the chip draws more than 790 mA at times, particularly when both WiFi and Bluetooth are used simultaneously.

ESP32 Active Mode Functional Block Diagram

According to the ESP32 datasheet, the power consumption during RF operations in active mode is as follows:

Mode Power Consumption
Wi-Fi Tx packet 13dBm~21dBm 160~260mA
Wi-Fi/BT Tx packet 0dBm 120mA
Wi-Fi/BT Rx and listening 80~90mA

This mode, without a doubt, consumes the most current and is the least efficient. In order to save power, you must disable features that are not in use by switching to another power mode.

ESP32 Modem Sleep

In modem sleep mode, everything is active except for the WiFi, Bluetooth, and the radio. The CPU remains active, and the clock is configurable.

In this mode, the chip consumes approximately 3 mA at slow speed and 20 mA at high speed.

ESP32 Modem Sleep Functional Block Diagram

To keep the connection alive, Wi-Fi, Bluetooth, and the radio are woken up at predefined intervals. This is referred to as the Association Sleep Pattern.

During this sleep pattern, ESP32 switches between active mode and modem sleep mode.

To accomplish this, the ESP32 connects to the router in station mode using the DTIM beacon mechanism. The Wi-Fi module is disabled between two DTIM beacon intervals and then automatically enabled just before the next beacon arrives. This results in power conservation.

The sleeping time is determined by the router’s DTIM beacon interval time, which is typically 100 ms to 1000 ms.

What is the DTIM Beacon Mechanism?

DTIM stands for Delivery Traffic Indication Message.

DTIM-Beacon

In this mechanism, the access point (AP)/router broadcasts beacon frames periodically. Each frame contains network-related information. It is used to announce the presence of a wireless network as well as to synchronize all connected members.

ESP32 Light Sleep

Light sleep is similar to modem sleep in that the chip follows the Association Sleep Pattern. The only difference is that in light sleep mode, the CPU, most of the RAM, and digital peripherals are clock-gated.

What is Clock Gating?

Clock gating is a popular power management technique for reducing dynamic power dissipation by removing or ignoring the clock signal when the circuit is not in use.

Clock gating reduces power consumption by pruning the clock tree. Pruning the clock disables portions of the circuitry, preventing the flip-flops in them from switching states. Since switching states consumes power, when not switched, the power consumption drops to zero.

During light sleep mode, the CPU is paused by disabling its clock pulse. The RTC and ULP-coprocessor, on the other hand, remain active. This results in a lower power consumption than the modem sleep mode, which is around 0.8 mA.

ESP32 Light Sleep Functional Block Diagram

Before entering light sleep mode, the ESP32 stores its internal state in RAM and resumes operation upon waking from sleep. This is referred to as Full RAM Retention.

ESP32 Deep Sleep

In deep sleep mode, the CPUs, most of the RAM, and all digital peripherals are disabled. Only the following parts of the chip remain operational:

    • ULP Coprocessor
    • RTC Controller
    • RTC Peripherals
  • RTC fast and slow memory

In deep sleep mode, the chip consumes anywhere between 0.15 mA (when the ULP coprocessor is on) and 10 µA.

ESP32 Deep Sleep Functional Block Diagram

During deep sleep mode, the primary CPU is turned off, whereas the Ultra-Low-Power (ULP) Coprocessor can take sensor readings and wake up the CPU as needed. This sleep pattern is referred to as the ULP sensor-monitored pattern. This is useful for designing applications where the CPU needs to be woken up by an external event, a timer, or a combination of these events, while maintaining minimal power consumption.

Along with the CPU, the main memory of the chip is also disabled. As a result, everything stored in that memory is erased and cannot be accessed.

Because RTC memory is kept active, its contents are preserved even during deep sleep and can be retrieved once the chip is woken up. This is why the chip stores Wi-Fi and Bluetooth connection data in RTC memory before entering deep sleep.

If you want to use the data after a reboot, store it in RTC memory by defining a global variable with the RTC_DATA_ATTR attribute. For example, RTC_DATA_ATTR int myVar = 0;

When the chip wakes up from deep sleep, it performs a reset and begins program execution from the beginning.

When waking up from deep sleep, the ESP32 can run a deep sleep wake stub. It’s a piece of code that executes as soon as the chip wakes up, before any normal initialization, bootloader, or ESP-IDF code is executed. After executing the wake stub, the chip can either return to sleep or continue to start ESP-IDF normally.

If you’re interested in learning more about ESP32 Deep Sleep and its wake-up sources, please visit our in-depth tutorial below.

Tutorial For ESP32 Deep Sleep Wakeup Sources
ESP32 Deep Sleep & Its Wake-up Sources
When your IoT project is powered by a wall adapter, you don’t care too much about power consumption. But if you’re going to power your...

ESP32 Hibernation mode

Hibernate mode is very similar to deep sleep. The only difference is that in hibernation mode, the chip disables the internal 8 MHz oscillator as well as the ULP-coprocessor, leaving only one RTC timer (on slow clock) and a few RTC GPIOs to wake the chip up.

Because the RTC recovery memory is also turned off, we cannot save any data while in hibernation mode.

ESP32 Hibernation Mode Functional Block Diagram

As a result, the chip’s power consumption is reduced even further; in hibernation mode, it consumes only about 2.5 μA.

This mode is especially useful if you’re working on a project that doesn’t need to be active all the time.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/871228.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

某公交管理系统简易逻辑漏洞+SQL注入挖掘

某公交管理系统挖掘 SQL注入漏洞 前台通过给的账号密码,进去 按顺序依次点击1、2、3走一遍功能点,然后开启抓包点击4当点击上图的4步骤按钮时,会抓到图下数据包,将其转发到burp的重放模块构造以下注入poc,可见注入延时了五秒,用户输入的语句成功拼接到原有的SQL语句上执行…

记一次常规的网络安全渗透测试

前言 上个月根据领导安排,需要到本市一家电视台进行网络安全评估测试。通过对内外网进行渗透测试,网络和安全设备的使用和部署情况,以及网络安全规章流程出具安全评估报告。本文就是记录了这次安全评估测试中渗透测试部分的内容,而且客户这边刚刚做过了一次等保测评,算一下…

工具 | Hfish

0x00 简介 HFish是一款社区型免费蜜罐。 下载地址 HFish下载: HFish下载 0x01 功能说明支持多种蜜罐服务支持自定义Web蜜罐支持流量牵引支持端口扫描感知能力支持多种告警方式注:仅供安全研究与学习之用,若将工具做其他用途,由使用者承担全部法律及连带责任,作者及发布者不…

ida(持续更新)

如题前缀 说明sub_ 指令和子函数起点locret_ 返回指令loc_ 指令off_ 数据,包含偏移量seg_ 数据,包含段地址值asc_ 数据,ASCII字符串byte_ 数据,字节(或字节数组)word_ 数据,16位数据(或字数组)dword_ 数据,32位数据(或双字数组)qword_ 数据,64位数据(或4字数组)…

工具 | Hashcat

0x00 简介 Hashcat是一款强大的密码破解工具。 下载地址 Hashcat下载: Hashcat下载 0x01 功能说明直接破解组合攻击掩码暴力破解混合攻击联合攻击注:仅供安全研究与学习之用,若将工具做其他用途,由使用者承担全部法律及连带责任,作者及发布者不承担任何法律及连带责任。

深入理解主键和外键:数据库设计的基石

title: 深入理解主键和外键:数据库设计的基石 date: 2025/1/18 updated: 2025/1/18 author: cmdragon excerpt: 在现代信息系统中,数据的管理和存储是至关重要的。关系数据库作为一种广泛使用的数据存储方式,其设计的合理性直接影响到数据的完整性和系统的性能。在关系数据…

一次性讲清如何合理搭配一台组装电脑

今天这篇文章我就给大家一次性讲清,我们如何合理搭配组装一台电脑,新手小白建议收藏观看,希望对大家有所帮助。 1 .首先要知道组装一台电脑, 以下八大硬件缺一不可: 2. 认识【CPU】: CPU品牌: 目前市场主流消费级CPU只有英特尔与AMD。 英特尔CPU: intel的CPU分为i3、i5、i…

ADCP414、ADCP416四通道125MSPS速率ADC替代AD9653、AD9253,可提供ZZKK证明

ADCP416-125/105/80是一款4通道、16位、125/105/80MSPS模数转换器(ADC),内置片内采样保持电路,专门针对低成本、低功耗、小尺寸和易用性而设计。该产品的转换速率最高可达125MSPS,具有杰出的动态性能与低功耗特性,适合比较重视小封装尺寸的应用。ADCP416-125特性和优势 --电…

Linux下使用Git的FQS

Git连接问题报错场景解决办法一:关闭SSL验证git config --global http.sslVerify false

[护网必备]2018年-2024年HVV 6000+个漏洞 POC 合集分享

此份poc 集成了Zabbix、用友、通达、Wordpress、Thinkcmf、Weblogic、Tomcat等 下载链接: 链接: 6000+Poc下载

2025-01-18:施咒的最大总伤害。用go语言,一个魔法师掌握了多种不同的咒语,每个咒语对应一个伤害值,这些伤害值存储在数组 power 中,其中可能会有多个咒语具有相同的伤害值。 使用某个特定伤

2025-01-18:施咒的最大总伤害。用go语言,一个魔法师掌握了多种不同的咒语,每个咒语对应一个伤害值,这些伤害值存储在数组 power 中,其中可能会有多个咒语具有相同的伤害值。 使用某个特定伤害值为 power[i] 的咒语后,魔法师不能再使用伤害值为 power[i] - 2、power[i] - …

工具 | todesk最新版设备代码、连接密码读取工具,附下载链接

工具介绍: todesk最新版读取设备代码、连接密码 工具 下载链接: 下载链接: todesk最新版读取设备代码、连接密码 工具下载 使用说明 工具使用效果如图