Minimizing power consumption while connected to WiFi

edmund-huber
Posts: 15
Joined: Wed Apr 12, 2017 8:30 pm

Minimizing power consumption while connected to WiFi

Postby edmund-huber » Fri Jun 02, 2017 12:23 am

Hello, I've been trying to characterize, and minimize, the energy used by the ESP32. Particularly when it is "idle", and all it needs to be doing is maintaining a WiFi connection.

The datasheet claims that modem sleep should achieve 20 mA (at worst?). However, in my experiment I have found that current draw while modem sleep is enabled is ~80% at ~50 mA, ~20% at ~150 mA.

How did I measure this: I used a ~10 ohm piece of wire as a shunt resistor:

Image

This lets me graphically see what's happening over time. What you are looking at is powered off, then power up and connect to wifi, then modem sleep. Yes, it is upside down..

I got my numbers from what my power supply (Mastech HY3005D) was reporting as the current draw. I'll readily admit that what I'm doing to measure current isn't ideal, I'm just using what I have on hand.

I'm using the WROOM-32, powering through its 3v3/GND pins. No other sources of power (e.g. USB) are involved.

The code is extremely bare-bones, all it does is connect to an AP, and then enter modem sleep. Note, it doesn't use taskdelay to "sleep".

Question 1: How did the author of the datasheet measure 20 mA for modem sleep? What do the "Max speed", "Normal speed", "Slow speed" in the datasheet mean?

Question 2: the datasheet describes an "association sleep pattern" of switching between the "active", "modem sleep" and "light sleep" modes. Is this a feature of the chip - or the ROM - or implemented in ESP-IDF - and how do we access it? It sounds like "light sleep" in FreeRTOS is still not hammered out yet. Is there a timetable for this feature? This post by ESP_Angus seems to be mentioning this feature, or something like it.

Question 3: what exactly does modem sleep do? Does it leave the RX radio on but power off the TX radio? What does it do in response to DTIM beacons? In particular, I noticed after leaving the ESP32 on for a while, modem sleep seemed to be having some trouble doing much sleeping at all:

Image

What kinds of things cause a wakeup from modem sleep? How can I get this behavior under control?

edmund-huber
Posts: 15
Joined: Wed Apr 12, 2017 8:30 pm

Re: Minimizing power consumption while connected to WiFi

Postby edmund-huber » Sun Jun 04, 2017 4:15 am

Incidentally, I have found that modem sleep doesn't seem to ever kick in while the BT controller is on (BTDM mode). Will modem sleep be able to work when we have BLE -only mode available?

edmund-huber
Posts: 15
Joined: Wed Apr 12, 2017 8:30 pm

Re: Minimizing power consumption while connected to WiFi

Postby edmund-huber » Wed Jun 07, 2017 4:29 pm

Is there a chance we can have a discussion about this?

littlesky
Posts: 51
Joined: Fri Jun 09, 2017 7:49 am

Re: Minimizing power consumption while connected to WiFi

Postby littlesky » Fri Jun 09, 2017 9:17 am

Hi,

1. 20 mA for modem sleep is measured in test mode on the chip. "Max speed" means high CPU frequency. "Normal speed" means middle CPU frequency. "Slow speed" means low CPU frequency. CPU frequency can be changed during modem sleep in order to reduce current.

2. It is a feature in IDF. We can call API esp_wifi_set_ps() to switching between the "active", "modem sleep" and "light sleep" modes. But light sleep has not be implemented in the latest IDF and will be done in IDFv3.0.

3. Modem sleep means power off both of the TX and RX radio. It will power on radio before DTIM. What is the trouble? We just fixed some bugs of modem sleep recently.

Thanks

vardelean
Posts: 8
Joined: Sun Jun 04, 2017 8:07 pm

Re: Minimizing power consumption while connected to WiFi

Postby vardelean » Wed Aug 02, 2017 6:38 pm

I'm on the same boat, I want to be able to minimize power consumption while in SoftAP mode.

I'm assuming you are in SoftAP mode as well because you want to listen to commands, and this is why the esp_wifi_set_ps won't work: it only works in station mode.

More info on this: http://esp-idf.readthedocs.io/en/latest ... aving-mode

If you want to receive any data on a socket you must have the modem on, no way to go in sleep mode because you may miss incoming commands, unless you know exactly when it is time for the next incoming message.

Otherwise, the only way to reduce power consumption is to take the cpu clock down. I wonder if anyone tried to lower the CPU clock from 80MHz down to 40MHz. I could not find any info on this, the only clock rates accepted are 80, 160 and 240MHz.

Forcing the CPU down to 40MHz in an effort to reducing power consumption when not much is going on kind of makes sense to me. One could for instance bypass the PLL and use the external crystal directly on the bus, or just change the PLL divider so that it outputs 40MHz instead of 80Mhz... has anyone tried that?

You can also use just one CPU core, but you would only save about 4mA.

iwliwl
Posts: 4
Joined: Sat Dec 03, 2016 4:25 pm

Re: Minimizing power consumption while connected to WiFi

Postby iwliwl » Tue Sep 12, 2017 11:08 pm

Does all this mean you can't get much below 100 mA when connected to wifi?

Isn't that a lot, my old Iphone 4 last some days on battery connected to wifi ?

User avatar
hassan789
Posts: 156
Joined: Thu Jun 29, 2017 2:15 am

Re: Minimizing power consumption while connected to WiFi

Postby hassan789 » Thu Nov 23, 2017 1:35 am

A good article on how modem-sleep, light-sleep and DTIM will work (but its for esp8266). Looks like the esp8266 can get <1mA at DTIM 3 when idle.
https://www.espressif.com/sites/default ... s_en_0.pdf

Hopefully, we get light-sleep (aka tickless sleep) soon for ESP32 as well !!

Who is online

Users browsing this forum: Baidu [Spider] and 369 guests