Power hungry in deep sleep

Hi, I use nano esp32 in a relatively simple project, take sensor reading, update over WiFi Arduino cloud with results and go deep sleep.
In this mode I'd be expecting something <1mA while I'm taking readings about 9mA in deep sleep...
Have you guys measured it??

It will do what you want if you design it correctly and program it accordingly. Post both your code and an annotated schematic showing how you wired it, include all power, ground and power sources. There are several Nano ESP32s post a link to the one you have.

I have been experimenting using a stock from the box (except removed power LED) Nano ESP32 with low power modes. In light sleep I've gotten the 3.3V current, measured at SJ1, as low as 1.27mA. This is about 3x higher than I would expect based on data sheet typical current for the SoC and memory. See Light sleep post

In deep sleep mode the situation is even worse. The lowest 3.3V current I've achieved is 1.78mA. Yes, 0.5 mA higher than in light sleep, and over 100x higher than expected for deep sleep based on data sheet typical currents. The deep sleep current started even higher until I noticed that the pins connected to the external SPI FLASH were all floating in deep-sleep. After many unsuccessful attempts to get the SPI lines to hold high in deep sleep via software, I bit the bullet and added 6x external 10k pull-up resistors to the SPI FLASH pins on the Nano board. This reduced the deep sleep current to 1.78mA.

Has anyone achieved reasonably low power consumption in either light or deep sleep using the Nano ESP32 board ?

FWIW - I've reported this issue to Arduino, They say they will investigate, but meanwhile suggested posting to this forum.

It is not possible to address the question until you clearly explain how the board is wired and powered.

1 Like

The board is a stock from the box Arduino Nano ESP32 board as I explained. The only modification is that I removed the power LED (DL3) as I explained. The board isn't "wired" to anything other than external 5V power. The 3.3V current (not the 5V current) is being measured at SJ1 as I also explained. Obviously the ESP32-S3R8 IC (embedded inide the uBlox Nora W106-10B module) is wired on the PCB per the schematic provided by Arduino for the board.

Take a stock Arduino Nano ESP32 board, remove DL3, cut jumper SJ1 and insert an ammeter (e.g. Fluke 87 DMM) in series with the two pads of SJ1. Power it from 5V, either through the USB-C connector or by applying 5V from a bench supply at the VIN pin. Run one of the deep sleep example sketches and observe the 3.3V current on the DMM once the board enters deep sleep.

The current I observed was 2-3mA until I added the 6x 10k pull-up resistors to the external SPI FLASH pins - as I mentioned in the post. Then the current dropped to 1.78mA as I explained. My contention is that the deep sleep current should be much lower - less than 100uA. I'd like to know if others observe the same or not.

Thank you. Look up the quiescent current draw of the voltage regulator.

1 Like

The only voltage regulator on the Nano board is U2, a switching regulator that makes 3.3V from VIN.
Since I am measuring the 3.3V current at SJ1, which is after (downstream) of the regulator, current consumed by the regulator is if no relevance.

I decided to have a look at the 3.3V current in deep sleep using an o-scope.

  • Prior to entering deep sleep, code is executing a delay function. The 3.3V current is 30 - 50 mA.
  • Upon entry to deep sleep, the current rapidly drops to very near zero (<< 1 mA).
  • For a period of 600-800 mS after deep sleep entry, current pulses 17 mA in amplitude & 10-15 uS in duration at a frequency of 1-1.2 kHZ are observed.
  • After 600-800mS (varies with each run) the frequency of the pulses increases to 18-20kHz. The amplitude and duration of the current pules remain unchanged.
  • The current pulses continue at 18-20 kHz until exit from deep sleep.

I'm not sure what to make of this. Does anyone know if it is normal to see current spikes like this in deep sleep? It looks like the CPU is coming out of deep sleep periodically (current spikes to 17mA) and then re-entering, but yet the sleep timer of 1.0s seems to be functioning correctly and the board resets upon exit from deep sleep as is expected.

Here is the code...

/* Simple Deep Sleep Test for the Ardunino Nano ESP32 board */
/* This sketch uses ESP32 GPIO pin numbering as opposed to Arduino pin numbering */
/* Set Tools->Pin Numbering: "By GPIO number (legacy)" in Arduino IDE before compiling */ 

/* Function to initialize all available GPIOs as inputs with either pullup or pulldown resistors */
void initGPIO()
{
  pinMode(0, INPUT_PULLUP); // External green LED with pull-up
  pinMode(1, INPUT_PULLDOWN);
  pinMode(2, INPUT_PULLDOWN);
  pinMode(3, INPUT_PULLDOWN);
  pinMode(4, INPUT_PULLDOWN);
  pinMode(5, INPUT_PULLDOWN);
  pinMode(6, INPUT_PULLDOWN);
  pinMode(7, INPUT_PULLDOWN);
  pinMode(8, INPUT_PULLDOWN);
  pinMode(9, INPUT_PULLDOWN);
  pinMode(10, INPUT_PULLDOWN);
  pinMode(11, INPUT_PULLDOWN);
  pinMode(12, INPUT_PULLDOWN);
  pinMode(13, INPUT_PULLDOWN);
  pinMode(14, INPUT_PULLDOWN); // For unknown reasons, GPIO14 floats at a half-level if configured as input with pullup, so configure with pulldown.
  // GPIO15 & GPIO16 are connected to 32kHz xtal on Nano board, we'll skip configuring them for now.
  // pinMode(15, INPUT_PULLDOWN);
  // pinMode(16, INPUT_PULLDOWN);
  pinMode(17, INPUT_PULLDOWN); 
  pinMode(18, INPUT_PULLDOWN); 
  pinMode(19, INPUT_PULLDOWN); // USB_DN
  pinMode(20, INPUT_PULLUP); // USB_DP
  pinMode(21, INPUT_PULLDOWN); 
  // GPIO22 through GPIO25 are not present on ESP32-S3R8 SoC, so we'll skip configuring them.
  // GPIO26 through GPIO37 used as octal SPI interface to internal SPI PSRAM on ESP32-S3R8 SoC and external SPI FLASH on Nano ESP32 board, so we'll skip configuring them.
  pinMode(38, INPUT_PULLDOWN);
  pinMode(39, INPUT_PULLDOWN);
  pinMode(40, INPUT_PULLDOWN);
  pinMode(41, INPUT_PULLDOWN);
  pinMode(42, INPUT_PULLDOWN);
  pinMode(43, INPUT_PULLDOWN);
  pinMode(44, INPUT_PULLDOWN);
  pinMode(45, INPUT_PULLUP); // External blue LED with pull-up
  pinMode(46, INPUT_PULLUP); // External red LED with pull-up
  pinMode(47, INPUT_PULLDOWN);
  pinMode(48, INPUT_PULLDOWN); // External NFET gate for yellow LED drive with pull-down.
}

void setup() 
{
  initGPIO();  //Initialize all availabe GPIO as input with pull-up
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN,1);
  delay(1000);
  digitalWrite(LED_BUILTIN,0);
  esp_sleep_enable_timer_wakeup(1000000); //Sleep for 1.0s
  esp_deep_sleep_start(); //enter deep sleep.
  // Shouldn't ever get past this line because exit from deep sleep after 1s is basically same as a reset
}

void loop() 
{ 
  digitalWrite(LED_BUILTIN,1); //Flash the built-in LED if we ever get here.  Shouldn't happen.
  delay(250);
  digitalWrite(LED_BUILTIN,0);
  delay(250);
}

Arduino code runs by default in core 1. Is core 0 running RTOS and handling WiFI?

I have no clue. I am using a stock Arduino Nano ESP32 board running the code I showed in a sketch compiled in the Arduino IDE and loaded on the board by the Arduino IDE. Does the Arduino environment include an RTOS running in core 0 by default? I am a total novice on how all this works. Could you point me to some documentation explaining about the RTOS and where it runs?

Indeed it does, not so much Arduino as it's in the chip already..

esp32/api-reference/system/freertos
and here's their core..
arduino-esp32

good luck.. ~q

OK - wow. A lot for me to learn about here...thanks for the links.
I'm fairly convinced from the current consumption trace that some code in the RTOS or arduino-ESP32 continues to run after my code has called esp_deep_sleep_start(). Why won't the system shut down both cores fully when I call deep sleep?

What is the best way to set about debugging a deep sleep problem like this?

I assume I'll need to use a debugging tool connected via JTAG to get visibility to the RTOS or Core 0 processes??? But how to stop execution in the problem code - when the current consumption spikes up? The duty cycle of the current spikes are so low. The spikes up in current only last for a few uS out of hundreds or thousands of uS where nothing appears to be happening in the SoC based on the current draw.

Thanks again for the pointers.

You're welcome and yes, allot to consume I know..
Haven't used sleep modes, so probably won't be much help..
have you seen this example from the core link..
examples/DeepSleep/TimerWakeUp
give that a go and see what the draw is also read the big ole comment in there, it seems to mention ways of shutting down even more..

good luck.. ~q

That is enough to check, for example, whether WiFi or Bluetooth communications are requested by some other running program, and is probably driven by a timer interrupt.

The only way to know for sure is to look into what else is loaded into the ESP32, along with your test code. Studying the relevant Arduino core would be useful, and you might post an inquiry to the Arduino design team.

I assume I'll need to use a debugging tool

Nano ESP32 debugging tutorial, a work in progress, for sure.

I have measured the nano ESP32 current during deep sleep and am also getting much higher current than expected, about 2.6mA after some initial stabilization. Here is the code I am using to put the board to sleep.

#define uS_TO_S_FACTOR 1000000 
#define TIME_TO_SLEEP  20       
void setup(){
  esp_sleep_enable_timer_wakeup(TIME_TO_SLEEP * uS_TO_S_FACTOR);}
void loop(){
  esp_deep_sleep_start();}

This is a stock Arduino nano ESP32 with power LED removed and no other connections except for +5V applied to Vin. The current is measured using a 1 Ohm shunt connected between the +5V power supply and the Vin pin of the board.

Here is the current when the board enters deep sleep at time=0 seconds:

It looks like the board initially enters nearly deep sleep starting with Isupply of about 120uA and then gradually increasing to about 350uA followed by a step to 1.0mA and finally another step to about 2.6mA the rest of the time.

Anyone have ideas why the board current does not remain low during the whole 20 seconds of deep sleep duration (even if not achieving the expected <20uA during deep sleep)?

My results using same arduino setup, same code and SDM3065X as DMM are nearly the same.
Strange behaviour...

Im hearing this from a lot of people specifically with the Nano ESP32 vs. a ESP32 devKit xxx…now im not saying these are exact comparisons of esp32-s3’s but…... It has to be some weird quiescent current of one of the external components on the board / wifi radio not fully shutting down on the chip??

Someone will eventually find the culprit but you may need to investigate yourself for now??

Just seeing this post...

In deep-sleep mode, both cores are shut down, as well as the RF communication.
I would guess that the only remaining potential "culprit" would be the ULC (ultra low-power coprocessor). See p. 305+ of https://www.espressif.com/sites/default/files/documentation/esp32-s3_technical_reference_manual_en.pdf for more details.

I am interested in lowering the consumption in deep sleep mode as well, could you find any solution since February?