deep sleep draws 4 mA. Why so much?

MikeMyhre
Posts: 54
Joined: Sat Nov 05, 2022 3:32 am

deep sleep draws 4 mA. Why so much?

Postby MikeMyhre » Wed Jul 03, 2024 2:19 am

I have a custom board that uses a ESP32-S3 WROOM module with IDF V5.2.1.
It has a rechargeable battery that runs the ESP32 module when the main power is not present.
It has a FET that turns off all peripherals when the main power is not present.
I have confirmed that the FET is really off.
Everything works as expected (goes to sleep, wakes up when power returns, etc.)
Am I missing anything in putting the device into deep sleep?

Code: Select all

#define SLEEPING_PIN	14
#define SLEEPING_PIN_MASK (1ULL << SLEEPING_PIN)

static RTC_DATA_ATTR struct timeval sleep_enter_time;

//********************* MAIN ******************************

void app_main(void)
{
	uint32_t strap = DPORT_REG_READ(GPIO_STRAP_REG);
	ESP_LOGI("STRAPPING","Strapping register: %08lX", strap);

	esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause();
	switch(cause) {
	case ESP_SLEEP_WAKEUP_GPIO:
		ESP_LOGI("wakeup","GPIO wakeup");
		break;
	case ESP_SLEEP_WAKEUP_EXT1:
		ESP_LOGI("wakeup","EXT1 Wakeup");
		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;
		ESP_LOGI("wakeup","We slept in deep sleep for %dms",sleep_time_ms);
		break;
	case ESP_SLEEP_WAKEUP_UNDEFINED:
		ESP_LOGI("wakeup","Undefined Wakeup");
		break;
	default:
		ESP_LOGI("wakeup","Unknown wakeup code: %d",(int)cause);
		break;
	}

	gpio_reset_pin(SLEEPING_PIN);
	gpio_set_direction(SLEEPING_PIN,GPIO_MODE_INPUT);
	esp_sleep_enable_ext1_wakeup(SLEEPING_PIN_MASK,ESP_EXT1_WAKEUP_ANY_LOW);
	//esp_sleep_enable_timer_wakeup(10000000);	// 10 second wakeup

	while(1) {
		int sleeping = gpio_get_level(SLEEPING_PIN);
		ESP_LOGI("sleeping","sleeping: %d",sleeping);
		if( sleeping ) {
			ESP_LOGI("sleeping","Going to sleep");
			vTaskDelay( pdMS_TO_TICKS(1000));


			struct timeval now;
			gettimeofday(&now, NULL);
			sleep_enter_time = now;
			esp_deep_sleep_start();
		}
		else {
			ESP_LOGI("sleeping","Not Sleeping");
		}
		vTaskDelay( pdMS_TO_TICKS(1000));
	}

boarchuz
Posts: 605
Joined: Tue Aug 21, 2018 5:28 am

Re: deep sleep draws 4 mA. Why so much?

Postby boarchuz » Wed Jul 03, 2024 4:55 am

Schematic?

MikeMyhre
Posts: 54
Joined: Sat Nov 05, 2022 3:32 am

Re: deep sleep draws 4 mA. Why so much?

Postby MikeMyhre » Wed Jul 03, 2024 2:23 pm

Relevant parts of schematic attached.
Attachments
esp32_schematic.pdf
(115.35 KiB) Downloaded 146 times

ESP_Sprite
Posts: 9727
Joined: Thu Nov 26, 2015 4:08 am

Re: deep sleep draws 4 mA. Why so much?

Postby ESP_Sprite » Thu Jul 04, 2024 2:00 am

On what rail are you measuring this current? Also, can you make sure any GPIO going to the peripherals are either undriven or low? If they're high, you can have leakage current through that.

MikeMyhre
Posts: 54
Joined: Sat Nov 05, 2022 3:32 am

Re: deep sleep draws 4 mA. Why so much?

Postby MikeMyhre » Thu Jul 04, 2024 2:16 am

I am measuring the current through the + terminal on the battery.
I added code to reset each pin, change it to an input and disable pullups.
No change in the current draw.

boarchuz
Posts: 605
Joined: Tue Aug 21, 2018 5:28 am

Re: deep sleep draws 4 mA. Why so much?

Postby boarchuz » Thu Jul 04, 2024 8:19 am

Is it worth revealing the rest of the schematic? I can see there's ethernet, audio, RGB, etc not shown.

Do you have a second identical board to confirm the behaviour is exactly the same? Have you disconnected your USB/programmer?

What's the voltage on battery +? 3V3_CORE? EN?

Can you confirm that you are definitely getting a DEEPSLEEP_WAKEUP reported in your serial monitor when V11-15 returns, and not some other reset reason (eg. POWERON)?

You might need to start strategically removing (or otherwise electrically isolating) components one-by-one until you find the culprit.

ESP_Sprite
Posts: 9727
Joined: Thu Nov 26, 2015 4:08 am

Re: deep sleep draws 4 mA. Why so much?

Postby ESP_Sprite » Thu Jul 04, 2024 9:22 am

One thing I'm side-eyeing here is that you have your buck converter being back-fed from the output while the input does not have power. The datasheet doesn't specify what to expect then; could be that it leaks some current that way.

MikeMyhre
Posts: 54
Joined: Sat Nov 05, 2022 3:32 am

Re: deep sleep draws 4 mA. Why so much?

Postby MikeMyhre » Fri Jul 05, 2024 7:54 pm

ESP_Sprite wrote:
Thu Jul 04, 2024 9:22 am
One thing I'm side-eyeing here is that you have your buck converter being back-fed from the output while the input does not have power. The datasheet doesn't specify what to expect then; could be that it leaks some current that way.
Yes. I thought of that too. I have ran a test where I manually disconnected that part of the circuit with no change in the current drawn in deep sleep.
I cut a PCB trace and put in a jumper so only R3, R1, R2, C3 and the ESP32 are on a node so I can measure current. I left the main supply running and put it into sleep mode. Now I get 500 uA current drawn (may be some leakage in the FET/ Q7 part of the circuit).
With all I/O reset and set as inputs, nothing is initialized after the reset (no uarts, spi, i2s, gpio).

While the numbers have improved by isolating just the ESP32-S3, they are still about 100x more than expected.

UPDATE: I just found that this PCB has R3 AND R4 installed. I removed R4 so I just has a pullup on that pin. Now my current is 16uA.
Much closer to what is expected.

Who is online

Users browsing this forum: Cimby1 and 93 guests