首页 > 其他分享 >了解ESP32睡眠模式及其功耗

了解ESP32睡眠模式及其功耗

时间:2025-01-18 13:32:22浏览次数:1  
标签:睡眠 RTC power 功耗 ESP32 sleep mode chip

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

Insight Into ESP32 Sleep Modes & Their Power Consumption

  Tutorial - ESP32 Sleep Modes - Modem Sleep, Light Sleep, Deep Sleep, Hibernation & 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.

标签:睡眠,RTC,power,功耗,ESP32,sleep,mode,chip
From: https://www.cnblogs.com/FBsharl/p/18678394

相关文章

  • Arduino 平台下 ESP32-P4 MP3音频文件播放
    ESP32-P4开发板arduino平台下从SD_MMC读取MP3文件播实验程序,初步验证成功。开发板使用斑梨电子JC1060P470_P4,板载ES8311音频解码器和四线SD卡模块。ES8311在Arduino下驱动使用了github上某国外猿的驱动代码,并搭配ESP32-AudioI2S库I2Saudio示例实现。原来想直接使用psch......
  • AI 加持下的 arduino ESP32S3 GT30L32S4W 汉字显示
    AI加持下的arduinoESP32S3GT30L32S4W汉字显示程序小白,手上一块中景园1.54寸ST7789显示屏,自带GT30L32S4W汉字字库显示芯片,因为不知道怎么在arduino平台下使用硬字库一直闲置着。在网上翻阅了大量资料针对arduino平台下使用此类硬字库芯片的代码例程没有找到。......
  • 【ESP 乐鑫相关】ESP32-S3启动流程
    转载自:https://blog.itpub.net/70040860/viewspace-3053923/ESP32-S3启动流程    本文将会介绍ESP32-S3从上电到运行app_main函数中间所经历的步骤(即启动流程)。从宏观上,该启动流程可分为如下3个步骤。    ①:一级引导程序,它被固化在ESP32-S3内部的ROM中,它会从flas......
  • juju与电脑bug斗争_睡眠过热处理
    juju与电脑bug斗争_睡眠过热处理事情源于本ju在看完b站视频后,将电脑盖下来,过了一会儿,发现电脑在悄悄发热,耗了很多电,且无法正常开机,只能强制重启。遂决定解决这个问题。(更详细的内容可以参考这篇文章“S0现代待机”的烦恼+解决方案)本文只介绍本ju是怎么在我的小破笔记本上操......
  • 专为高性能计算和低功耗应用设计的MPF100T-1FCVG484E MPF100TL-FCSG325E MPF100TL-FCV
    ‌PolarFireFPGA是Microchip推出的一款高性能、低功耗的FPGA产品系列,特别适用于各种需要高性能计算和低功耗的应用场景‌。这些器件包括MPF100T-1FCVG484EMPF100TL-FCG484EMPF100TL-FCG484IMPF100TL-FCSG325EMPF100TL-FCVG484EMPF100TL-FCVG484IFPGA-现场可编程门阵列......
  • Windows 蓝牙驱动开发-BLE低功耗
    蓝牙的版本为1.0~5.2版本,蓝牙1.0~3.0都是经典蓝牙(rfcomm)。而蓝牙4.0开始就是包括蓝牙BLE了。蓝牙4.0的蓝牙芯片都是双模的,既包括经典蓝牙也包括低能耗蓝牙。经典蓝牙和蓝牙BLE完全是两个东西,只是它们在底层上有一些相似的地方。蓝牙BLE相比于经典蓝牙的优点是搜索、连接的速......
  • ESP-IDF esp32添加自己的组件
    esp32添加自己的组件:1.按键盘的F1,或者点击菜单view-CommandPalette都可以,选择EDP-IDF:CreaterNewESP-IDFComponent,输入组件名称(比如说esp_pwmout),确定2.看到已经新建了该组件,修改对应.h文件#ifndef__ESP_PWMOUT_H__#define__ESP_PWMOUT_H__voidsetup_pwm(void);......
  • 《ESP32-S3使用指南—IDF版 V1.6》第二章 常用的C语言知识点
    第二章常用的C语言知识点1)实验平台:正点原子DNESP32S3开发板2)章节摘自【正点原子】ESP32-S3使用指南—IDF版V1.63)购买链接:https://detail.tmall.com/item.htm?&id=7684993426594)全套实验源码+手册+视频下载地址:http://www.openedv.com/docs/boards/esp32/ATK-DNESP32S3.html......
  • ESP32模拟IIC,0.96英寸OLED(四针),改编自江科大/江协。
    #喜欢的宝子可以copy。#本文采用ArduinoIDE开发,用到了多文件形式。点击这里可以创建文件。下面直接分享代码和效果图。效果图0.96OLED.ino #include"OLED.h"voidsetup(){OLED_Init();OLED_ShowString(1,1,"sugkug");}intcnt=0;voidloop()......
  • 基于ESP32-S3单片机的OTA升级
    文章目录前言1.ESP32的OTA升级是什么?2.OTA升级的主要步骤3.优点4.ESP32进行OTA升级的机制5.OTA升级整体过程总结系列文章基于ESP32-S3单片机的OTA升级之移植官方代码(一)基于ESP32-S3单片机的OTA升级之巴法云平台(二)基于ESP32-S3单片机的OTA升级之整理官方工......