Battery and listening on wi-Fi

berpast
Posts: 4
Joined: Mon Feb 06, 2017 11:26 am

Battery and listening on wi-Fi

Postby berpast » Mon Feb 06, 2017 12:51 pm

I have two contrasting requirements:
1) Save on battery usage
2) Listen over Wi-Fi for commands coming from the cloud (I use MQTT to communicate with my platform)

I would like to receive the commands as soon as possible, but still save on battery usage as much as possible.

Is there any low power mode that still keeps Wi-Fi active?
In case it is necessary to power off Wi-Fi to enter in low power mode, is it necessary (or simply better) to disconnect the connection? Or is it possible to keep it open to save the connection energy when it is time to transmit/receive?

I'm mainly looking for guidelines on handling this type of scenario. If anyone has experience in this area, his suggestion will be more than welcome.

lakid74
Posts: 10
Joined: Mon Nov 16, 2015 8:53 pm

Re: Battery and listening on wi-Fi

Postby lakid74 » Tue Feb 07, 2017 10:53 am

From what I know (and that's not much :D ) this will be a challenge. WiFi is very power hungry (hundreds of mA when transmitting, ten's of mA when just connected), this is why things like LoRA, 6LoWPAN and zigbee exist.
A few options..
1. Look into QoS settings in MQTT, QoS 1 and above allow commands to be queued so that when a node wakes up, it can get a bunch of commands delivered to it. Can you sleep for minutes and then wake up to get waiting commands ?
2. Another option may be to use an nrf24l01+ or similar as an always on radio (but even then, power will be a problem) and then only fire up the wifi when needed.
3. Solar or other energy harvesting may work but you'll need big batteries to survive overnight and cloudy days.

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Battery and listening on wi-Fi

Postby ESP_Angus » Wed Feb 08, 2017 12:16 am

At the moment, when the ESP32 goes into deep sleep (for lowest power consumption) the WiFi connection is completely lost. On wakeup the connection is reestablished.

This may not be as bad as it sounds, if you can sleep most of the time and wake up periodically to poll for new information then overall power consumption can be still very low, depending on polling frequency. This is a problem if you need low latency responses to WiFi requests, however. The tradeoff is battery capacity vs latency requirements vs battery life.

There is a feature being worked on for ESP32 to stay connected to WiFi during deep sleep, waking up just to maintain the connection as necessary. This should allow lower latency and lower overall power consumption (although not as low as disconnecting entirely.) Unfortunately I don't have an ETA for this feature.

berpast
Posts: 4
Joined: Mon Feb 06, 2017 11:26 am

Re: Battery and listening on wi-Fi

Postby berpast » Thu Feb 16, 2017 10:46 pm

I started measuring the current used by my ESP32. In menuconfig I enabled both WiFi and bluethoot, but anyhow I'm running a simple program like:

void app_main(void)
{
while (true) {
ESP_LOGI("Log", "Log\n");
vTaskDelay(5000 / portTICK_PERIOD_MS);
}
}

This program continuously consumes about 130mA. My understanding was that using vTaskDelay, the CPU entered light sleep mode. Is it correct? Otherwise how can I enter light sleep mode?

I tried also adding a call to:

esp_wifi_set_ps(WIFI_PS_MODEM);

in order to enter modem sleep, but the chip complains that no WiFi init has occurred (which is true in my small program). So I assume that if I do not init wifi, even if it is enabled in the menuconfig, still the modem is turned off. Am I correct?

Why the ESP32 is thus consuming so much power?

ftscreations
Posts: 1
Joined: Tue Jan 23, 2018 6:15 pm

Re: Battery and listening on wi-Fi

Postby ftscreations » Tue Jan 23, 2018 6:22 pm

I have a similar requirement. I will be using the ESP32 to log data every 10 minutes and then a user will come by to download the data via wifi periodically (once a week to once a month). A deep sleep mode that could wake up when the user comes by would be ideal.

Currently, I'm around 110mA and have 2000mAh battery capacity + a 5V, 250mAh solar cell but I know there's a lot of wasted power by broadcasting wifi in the middle of the woods..at least until Apple releases an iPhone for birds.

Any suggestions on how to best reduce power consumption would be greatly appreciated.

woofy!
Posts: 21
Joined: Tue Oct 03, 2017 12:02 pm

Re: Battery and listening on wi-Fi

Postby woofy! » Wed Jan 24, 2018 1:28 pm

ftscreations wrote:I have a similar requirement. I will be using the ESP32 to log data every 10 minutes and then a user will come by to download the data via wifi periodically (once a week to once a month). A deep sleep mode that could wake up when the user comes by would be ideal.

Currently, I'm around 110mA and have 2000mAh battery capacity + a 5V, 250mAh solar cell but I know there's a lot of wasted power by broadcasting wifi in the middle of the woods..at least until Apple releases an iPhone for birds.

Any suggestions on how to best reduce power consumption would be greatly appreciated.
Only start up the wifi after a reset button press, not on wake up from sleep. Use the wake up reason to determine if its a reset. Make the reset button available to the data collector and he can press reset, download the data and done. You don't need to power up the wifi all the time, just when needed.

If you wake up from sleep, just do your sensor logging and back to sleep. The ESP32 will only use 40mA ish without wifi and will only need to be awake for a very short time.

User avatar
Vader_Mester
Posts: 300
Joined: Tue Dec 05, 2017 8:28 pm
Location: Hungary
Contact:

Re: Battery and listening on wi-Fi

Postby Vader_Mester » Wed Jan 24, 2018 2:12 pm

The only thing you can do now is to get your calculator, and calculate the optimum result.

Here I can simplify this with and example.

Let's say, your battery is about 800mAh capacity.
This means that it is capable of supplying 800mA for about an hour, discharging down to about 3,7V (Considering a Lithium battery).
(After this discharging the battery more would kill the battery).

So, if the ESP consumes 120mA while active...
If you wake it up every 10 sec, and it runs for about 5sec before it goes to sleep, then, you have a usage cycle of 1/3 (33%).
This means that the avarage consumption is 120mA*0,33= 40mA (not counting for the sleep current, and other losses in the circuit).
If you devide it with your battery capacity: 800/40= 16 (hours).
So with this rate your battery would probaly last about 16 hours.
As you can see, if you can lower the stay-on time of the ESP, and increase the sleep time, you can get decent results.
For example if you can sleep for 20seconds (runtime is still 5sec), you get a 20% on time.
With this your battery will last 33h.

(Side note: I know it sounds stupid, but if you are using it indoors, then good news is that a small solar panel can work with artifical light, so you just stick one on the wall, get a buck-boost circuit to convert the low voltage of the panel to higher voltage and you can get a few mA-s out of it, maybe enough to keep the ESP alive or charge battery while ESP is off.
Just do some number crunching :)

Code: Select all

task_t coffeeTask()
{
	while(atWork){
		if(!xStreamBufferIsEmpty(mug)){
			coffeeDrink(mug);
		} else {
			xTaskCreate(sBrew, "brew", 9000, &mug, 1, NULL);
			xSemaphoreTake(sCoffeeRdy, portMAX_DELAY);
		}
	}
	vTaskDelete(NULL);
}

lalit_jharbade
Posts: 1
Joined: Fri Feb 02, 2018 12:53 pm

Re: Battery and listening on wi-Fi

Postby lalit_jharbade » Fri Feb 02, 2018 1:06 pm

Hey guys,
I think this might help you. In this documentation it is clearly mentioned that(for ESP8266 doc)
During Light-sleep mode, the CPU may be suspended in applications like Wi-Fi switch. Without data transmission, the Wi-Fi Modem circuit can be turned off and CPU suspended to save power consumption according to the 802.11 standards (U-APSD). E.g. in DTIM3, maintaining a sleep of 300 ms with a wakeup of 3ms to receive AP’s Beacon packages at interval requires about 0.9 mA current.
. I think this should be fine even if you want immediate response in case of switch or something else. I guess this would cause maximum delay of 0.5 to 1 sec. I hope this is related to what you are looking for.
Docs. https://www.espressif.com/en/support/do ... d%5B%5D=14

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 200 guests