espressif / arduino-esp32

Arduino core for the ESP32
GNU Lesser General Public License v2.1
13.52k stars 7.39k forks source link

Deep-Sleep needs WiFi switched OFF for low current consumption #1113

Closed rudi48 closed 5 years ago

rudi48 commented 6 years ago

Hardware:

Board: WEMOS LoLin32
Core Installation/update date: Jun 8 2016 IDE name: Arduino 1.8.5 MacOS
Flash Frequency: 80Mhz Upload Speed: 115200

Description:

Unfortunately it is not explained that for deep-sleep with about 150 uA mentioned current consumption you need to switch OFF WiFi before, if it was in use. If you do not do that the current consumption is about 1600 uA - about 10 time what has been told.

All documentation I found to that topic did not tell about current consumption.

I propose to mention it on all documentation, where the 150 uA are mentioned.

You can save in the case of an internal GPIO pull-down input another 50 uA, with an external 120 KOhm resistor.

Regards, Rudolf

Sketch:

#include <esp_wifi.h>
...
  esp_wifi_stop();  
  esp_deep_sleep_start(); // 0.25 mA sleep current (battery)

References:

esp32_technical_reference_manual_en.pdf version 2.9 - does not tell about wifi_stop

esp32_datasheet_en.pdf version 2.1 - does not tell about wifi_stop Table 4: Power Consumption by Power Modes Deep-sleep The ULP co-processor is powered on. 150 μA

esp32_eco_and_workarounds_for_bugs_in_esp32_en.pdf verion 1.4 - does not tell about wifi_stop

esp32_hardware_design_guidelines_en.pdf version 2.1 - does not tell about wifi_stop

esp-wroom-32d_esp32-wroom-32u_datasheet_en.pdf version 1.0 - does not tell about wifi_stop Table 7: Power Consumption by Power Modes Deep-sleep The ULP co-processor is powered on. 150 μA

https://dl.espressif.com/doc/esp-idf/latest/ Search for "deep" shows 11 Search Results Search for "wifi-stop" shows 1 Search Result - does not tell about power saving

https://github.com/espressif/esp-idf/blob/master/docs/api-reference/system/sleep_modes.rst n deep sleep mode, wireless peripherals are powered down. Before entering sleep mode, applications must disable WiFi and BT using appropriate calls ( esp_bluedroid_disable, esp_bt_controller_disable, esp_wifi_stop). Note: but it does not tell about "current consumption".

https://github.com/espressif/esp-idf/blob/master/components/esp32/include/esp_sleep.h

beegee-tokyo commented 6 years ago

Added to the Wiki with credits to you. Thank you for sharing your findings.

brianaagaard commented 6 years ago

For what it is worth, I I just ran into the same problem in the latest release with high power consumption in deep sleep mode (~1.5 mA) after having used the wifi. However, I only saw it when I use: esp_sleep_enable_ext0_wakeup(GPIO_NUM_14,1); and disabling wifi before sleep didn't help. If I only use timer sleep or switch to waking on ext1, then the current consumption in deep sleep mode is back down to ~70 μA on my board. I am now using ext1 sleep which works fine, but this seems like a framework bug.

mikey60 commented 5 years ago

@brianaagaard, I had the exact same issue with esp_sleep_enable_ext0_wakeup after having used the WiFi. I am using version 1.0.1 of arduino-esp32. Even after executing WiFi.disconnect() and WiFi.mode(WIFI_OFF) before executing esp_deep_sleep_start() I saw ~1.3 mA in the deep sleep mode. Thanks to your post I changed to esp_sleep_enable_ext1_wakeup and now my deep sleep current is ~8 uA.

arnaudmz commented 5 years ago

Same here. Even with esp_sleep_enable_ext1_wakeup, you can go back to ~1.3 mA if you enable the PERIPH RTC (with ESP_ERROR_CHECK(esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON));). I had to add an external Resistor as a pullup.

MadDogMayCry0 commented 5 years ago

@rudi48

#include "driver/adc.h"

befor going to deep sleep


adc_power_off();
rudi48 commented 5 years ago

@Stasikiii Tank you for the hint. Did you measure the power consumtion before and at sleep?

MadDogMayCry0 commented 5 years ago

@rudi48 Yep :) Without adc_power_off - 1,3mA With - 7uA (RTC SLOW/FAST MEM IS ON) Chip is ESP32-PICO-D4 (revision 1) on TTGO MICRO 32 (without any usb_ttl convertors on a board) If you wanna save low consumption with a LIPO battery, then use HT7833 as a LDO regulator, you become just + 4uA in deep sleep mode. So, it's a best set for LOW Power LiPO projects. But Lifepo4 even better :) Datasheet https://www.holtek.com.tw/documents/10179/82844a36-1633-498c-a6e3-4d99f2d0f6d7

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 5 years ago

This stale issue has been automatically closed. Thank you for your contributions.

our30K commented 4 years ago

using Arduino's wifi turn on methods leads to ADC somehow start consuming power. so when turn off the wifi, it should turn off the ADC too. to save power.

our30K commented 4 years ago

this is how I turn off wifi after wifi scan.

WiFi.mode(WIFI_OFF);
  esp_wifi_stop();
  adc_power_off();

with or without adc_power_off(), there is about 1+mA power consumption difference. I believe somehow when just use ext1 as wakeup source to sleep, ADC will be turnoff automatically when sleep, but if use ext0 as wakeup source, ADC don't get automatically turned off when enter deep sleep

ligantx commented 3 years ago

i run numerous tests (like 40 tests with multimeter) with the following lines:

//for arduino core
#include "esp_wifi.h"
#include "driver/adc.h"

//do many stuff
WiFi.mode(WIFI_MODE_NULL);
//comment one or both following lines and measure deep sleep current
esp_wifi_stop(); //you must do esp_wifi_start() the next time you'll need wifi or esp32 will crash
adc_power_off();

Summarized, I found that esp_wifi_stop() didnt make any difference, but adc_power_off, made deep_sleep current ~1-2mA less when wifi was used before the deep sleep. In all scenarios, if you dont use wifi there wasnt any difference. The only strange thing is that when i run a no wifi task after code upload and then deep sleep i had much lower current, compared to if i run a wifi task and then deep sleep, and after that a no wifi task and deep sleep..

e-tinkers commented 3 years ago

adc_power_off() is deprecated. Use adc_power_release() instead.

Gabriel-Gardin commented 1 year ago

adc_power_release() does not decrease the power usage during deep sleep.

mars000 commented 1 year ago

You can save in the case of an internal GPIO pull-down input another 50 uA, with an external 120 KOhm resistor.

hello - very useful. Can you explain your statement "you can save in the case of internal GPIO pull-down input another 50uA". Are you suggested using pinMode(xx, INPUT_PULLDOWN) using more power when in deep sleep and therefore using an extenral resistor will save this power ?