当前位置:网站首页>How the esp32 deep sleep current is lower than 10uA
How the esp32 deep sleep current is lower than 10uA
2022-07-01 06:43:00 【Morning breeze】
Chen Tuo 2022/05/26-2022/05/29
1. summary
This article is based on official routines , experiment ESP32 Modules in Deep-sleep Implementation of ultra low power consumption in mode .
1.1 Deep sleep Deep-sleep
Official documents :
https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/api-reference/system/sleep_modes.html
ESP32 have Light-sleep and Deep-sleep Two sleep saving modes .
stay Light-sleep In mode , Digital peripherals 、CPU、 And for the most part RAM All use clock gating , At the same time, the power supply voltage decreases . After exiting this mode , Digital peripherals 、CPU and RAM Resume operation , The internal state remains unchanged .
stay Deep-sleep In mode ,CPU、 Most of the RAM、 And all by the clock APB_CLK All the digital peripherals driven will be powered off . The part of the chip that continues to be in the power supply state only includes :
- RTC controller
- RTC peripherals
- ULP Coprocessor
- RTC High speed memory
- RTC Low speed memory
Light-sleep and Deep-sleep There are multiple wake-up sources in this mode . These wake-up sources can also be combined , At this time, any wake-up source can trigger wake-up .
[APB_CLK(APB The clock )]
ESP32 Of CPU Master clock CPU_CLK The main frequency can reach 160MHz, Too high for external devices , Can't be used directly , Frequency division required .ESP32 A variety of clock options with different frequencies are provided , It can be configured flexibly CPU, peripherals , as well as RTC Working frequency of , To meet different power consumption and performance requirements .
Peripheral clocks include APB_CLK,REF_TICK,LEDC_SCLK,APLL_CLK and PLL_D2_CLK.
1.2 Power consumption of different modes


1.3 The awakening source of this experiment
To test the minimum current consumption , This experiment does not use touch to wake up 、ULP Wake up and GPIO Wake up the , Only use the timer to wake up . Other ways to wake up , Future articles will cover .
1.4 Official routine domestic mirror
The main content of this article comes from the official routine Deep Sleep Example
https://gitee.com/EspressifSystems/esp-idf/tree/master/examples/system/deep_sleep

![]()
1.5 Test circuit board
The following are common in the market ESP32 The development board cannot be used in this experiment because of its peripheral circuit .

The circuit schematic diagram of this development board is attached at the back of this paper .
In order to reduce the influence of additional circuit on measurement , We need to make a test circuit board by ourselves . Production methods :1 individual ESP32-S The module is welded on a base plate , Add 2 Button (RESET and IO0),2 Buttons each with 1 individual 10k The pull-up resistance of , As shown on the right side of the figure below .
use 2 A current meter measures the current . High current 2 Two meter heads shall be connected in parallel, otherwise uA The internal resistance of the meter is too large to move , In addition, I can type a watch . Remove it when the current is low mA Header .
Cheap and effective measurement methods :

Burn program and view serial port LOG I need one more USB To serial port downloader :

2. development environment
《 Use Lexin domestic Gitee Image building ESP32 development environment 》
https://zhuanlan.zhihu.com/p/348106034
https://blog.csdn.net/chentuo2000/article/details/113424934?spm=1001.2014.3001.5501
3. Build the project
This example demonstrates how to use esp_sleep.h API Enter deep sleep mode , Then wake up from the timer source .
Timer is a kind of RTC Timer , Programmable to trigger wakeup after a preset time . This example will every 20 Seconds triggers a wake-up .
- Copy official routine
Copy the official example project to ESP-IDF Beyond development tools :
cd ~/esp
cp -r esp-idf/examples/system/deep_sleep/ ~/esp/esp32_deep_sleep
- Project tree
cd esp32_deep_sleep

4. Build the project
- Refresh esp-idf Environmental Science
get_idf
- Set the target chip
idf.py set-target esp32
- Configuration items
idf.py menuconfig
1) Set up Flash The memory size is 4MB

2) To test the minimum current consumption , Wake up without touch 、ULP Wake up and GPIO Wake up the

3) choice Skip image validatin when exiting deep sleep

Use this option , It allows you to reduce the boot time of the boot loader when you wake up from deep sleep . The boot loader stores the address of the running partition in rtc In the memory , And use it when you wake up . This example allows you to skip all image checks and speed up boot .
preservation , sign out .
- Compile the project
idf.py build
- Burn project
see USB Serial port COM slogan :
![]()
burning :
idf.py -p /dev/ttyS3 -b 115200 flash
Write operation ( You can send the above command before or after ):
1) Hold down IO0 Button
2) Press down RST Button , Let go again
3) Release IO0 Button
If not, power on again and try again .
- Enable monitor
idf.py monitor -p /dev/ttyS3
(Ctrl+] You can exit the monitor program )
First run

Subsequent operation

- Wake up current ( parallel connection mA surface )

- deep sleep electric current ( To break off mA surface )

deep sleep The current is 66uA, Distance from... In the manual 20uA The difference is too far .
5. Reduce deep-sleep electric current
- Main reference
https://electronics.stackexchange.com/questions/530151/esp32-wroom32-consuming-77-%c2%b5a-much-too-high-in-deep-sleep
- Modify the program
stay deep_sleep_example_main.c Of app_main Add the following statement at the beginning of the function :
void app_main(void)
{
gpio_reset_pin(GPIO_NUM_0);
gpio_reset_pin(GPIO_NUM_2);
gpio_reset_pin(GPIO_NUM_4);
gpio_reset_pin(GPIO_NUM_12);
gpio_reset_pin(GPIO_NUM_13);
gpio_reset_pin(GPIO_NUM_14);
gpio_reset_pin(GPIO_NUM_15);
gpio_reset_pin(GPIO_NUM_25);
gpio_reset_pin(GPIO_NUM_26);
gpio_reset_pin(GPIO_NUM_27);
gpio_reset_pin(GPIO_NUM_32);
gpio_reset_pin(GPIO_NUM_33);
gpio_reset_pin(GPIO_NUM_34);
gpio_reset_pin(GPIO_NUM_35);
gpio_reset_pin(GPIO_NUM_36);
gpio_reset_pin(GPIO_NUM_37);
gpio_reset_pin(GPIO_NUM_38);
gpio_reset_pin(GPIO_NUM_39);explain :
gpio_reset_pin Function will gpio The pin is reset to the default state ( choice gpio function , Enable pull-up and disable input and output ).

recompile 、 burning 、 perform .
- Wake up current ( parallel connection mA surface )

- deep sleep electric current ( To break off mA surface )

The current is less than 10uA.
6. Add one LED As gpio The load of
6.1 add to gpio load
- Add load to the power supply ( Fill with electricity sink current)
GPIO_NUM_2,GPIO_NUM_4 and GPIO_NUM_15 These pins add a load to ground ( Pull the current source current) It will increase the deep sleep current to 60uA above . Connect as shown in the attached circuit diagram LED1 You can't , To put LED The positive pole of is connected to 3.3v On the power supply ,LED The negative pole of the is grounded GPIO Pin , That is, the current filling connection method , In this way, the sleep current can be reduced .
- Be careful not to use GPIO_NUM_2
Use current filling connection GPIO2 It will affect firmware burning .
- We use GPIO4 Connect LED
6.2 Modify the program
stay deep_sleep_example_main.c The statements with changes in are as follows , Please check the original code .
#define GPIO_OUTPUT_IO_LED 4 // LED Connect to gpio Pin 4
void led_init(void)
{
gpio_pad_select_gpio(GPIO_OUTPUT_IO_LED);
gpio_set_direction(GPIO_OUTPUT_IO_LED, GPIO_MODE_OUTPUT); // Set the GPIO as a push/pull output
}
void led_on(void) {
gpio_set_level(GPIO_OUTPUT_IO_LED, 0);
}
void led_off(void) {
gpio_set_level(GPIO_OUTPUT_IO_LED, 1);
}
void app_main(void)
{
// After making the following settings, the current changes from 63uA Down to 3uA
gpio_reset_pin(GPIO_NUM_0);
gpio_reset_pin(GPIO_NUM_2);
gpio_reset_pin(GPIO_NUM_4);
gpio_reset_pin(GPIO_NUM_12);
gpio_reset_pin(GPIO_NUM_13);
gpio_reset_pin(GPIO_NUM_14);
gpio_reset_pin(GPIO_NUM_15);
gpio_reset_pin(GPIO_NUM_25);
gpio_reset_pin(GPIO_NUM_26);
gpio_reset_pin(GPIO_NUM_27);
gpio_reset_pin(GPIO_NUM_32);
gpio_reset_pin(GPIO_NUM_33);
gpio_reset_pin(GPIO_NUM_34);
gpio_reset_pin(GPIO_NUM_35);
gpio_reset_pin(GPIO_NUM_36);
gpio_reset_pin(GPIO_NUM_37);
gpio_reset_pin(GPIO_NUM_38);
gpio_reset_pin(GPIO_NUM_39);
led_init();
led_off();
struct timeval now;
gettimeofday(&now, NULL);
int sleep_time_ms = (now.tv_sec - sleep_enter_time.tv_sec) * 1000 + (now.tv_usec - sleep_enter_time.tv_usec) / 1000;
switch (esp_sleep_get_wakeup_cause()) {
#ifdef CONFIG_EXAMPLE_EXT1_WAKEUP
case ESP_SLEEP_WAKEUP_EXT1: {
uint64_t wakeup_pin_mask = esp_sleep_get_ext1_wakeup_status();
if (wakeup_pin_mask != 0) {
int pin = __builtin_ffsll(wakeup_pin_mask) - 1;
printf("Wake up from GPIO %d\n", pin);
} else {
printf("Wake up from GPIO\n");
}
break;
}
#endif // CONFIG_EXAMPLE_EXT1_WAKEUP
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
case ESP_SLEEP_WAKEUP_GPIO: {
uint64_t wakeup_pin_mask = esp_sleep_get_gpio_wakeup_status();
if (wakeup_pin_mask != 0) {
int pin = __builtin_ffsll(wakeup_pin_mask) - 1;
printf("Wake up from GPIO %d\n", pin);
} else {
printf("Wake up from GPIO\n");
}
break;
}
#endif //SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
case ESP_SLEEP_WAKEUP_TIMER: {
printf("Wake up from timer. Time spent in deep sleep: %dms\n", sleep_time_ms);
//led_init();
led_on();
vTaskDelay(150 / portTICK_RATE_MS); // Time delay 150ms
led_off();
break;
}
#ifdef CONFIG_EXAMPLE_TOUCH_WAKEUP6.3 test result
deep sleep The current is the same as before , Less than 10uA.
attach :ESP32 Development board circuit schematic diagram

Reference documents
- https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32/api-reference/system/sleep_modes.html?highlight=apb_clk
- https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/sleep_modes.html#wakeup-sources
- https://lastminuteengineers.com/esp32-sleep-modes-power-consumption/
边栏推荐
- C language course set up student elective course system (big homework)
- 三说 拷贝构造之禁用
- 3. Disabling copy construction
- 数据库对象:视图学习记录
- [wechat applet] view container and basic content components
- [unity shader custom material panel part I]
- Idea easy to use plug-in summary!!!
- SQL learning notes 2
- 2022 Jiangsu Vocational College skills competition (secondary vocational school) network construction and application open competition volume
- Problem: officeexception: failed to start and connect (III)
猜你喜欢

Problem: officeexception: failed to start and connect (II)

Solve the problem that the class defined in meta-inf.services cannot be read

谷粒商城-环境(p1-p27)

Jena default inference query based on OWL

C language course is provided with employee information management system (large operation)

Mongodb: I. what is mongodb? Advantages and disadvantages of mongodb
![[unity shader stroke effect _ case sharing first]](/img/bd/5cd1bef24e6b6378854114c2c05bd9.png)
[unity shader stroke effect _ case sharing first]

Embedded system

Idea easy to use plug-in summary!!!

了解ESP32睡眠模式及其功耗
随机推荐
[wechat applet] to solve button, input and image components
基金定投是高风险产品吗?
嵌入式系统
Esp32 esp-idf GPIO key interrupt response
Problem solving: officeexception: failed to start and connect (I)
数据库对象:视图学习记录
Resttemplate use
What is a port scanning tool? What is the use of port scanning tools
H5 web page determines whether an app is installed. If it is installed, it will jump to the summary of the scheme to download if it is not installed
问题:OfficeException: failed to start and connect(二)
Find the original array for the inverse logarithm
谷粒商城-环境(p1-p27)
Idea easy to use plug-in summary!!!
The code generator has eliminated the styling of xxxx js as it exceeds the max of 500kb
常用快捷键
Software engineering review
SQL statement
根据输入画有向图
Internet worm
Several ways of gson's @jsonadapter annotation