Arduino icon indicating copy to clipboard operation
Arduino copied to clipboard

Command to disable WiFi to save power

Open probonopd opened this issue 11 years ago • 58 comments

There should be an easy command to save power by disabling the WiFi. Normally the ESP-01 consumes about 0.07A but it should be possible to bring power consumption significantly down to 0.01-0.02A by going to "Modem-Sleep" (as it is called by the manual). In "Modem-Sleep", CPU and other peripherals are still running, so the sketch should be able to continue running as usual.

schermafbeelding 202014-12-10 20om 2013 55 40

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

probonopd avatar Jun 21 '15 15:06 probonopd

This is not an issue, ask your question in relevant part of the forum : Forum

chadouming avatar Jun 21 '15 16:06 chadouming

I've just checked the SDK docs for wifi_set_sleep_type function and they have this note:

Note: Default to be Modem sleep.

So modem sleep is enabled by default.

igrr avatar Jun 21 '15 19:06 igrr

I am measuring 0.07A power consumption using a "Charger Doctor" like shown here, regardless of whether I am connected to WiFi or just running a blink sketch. Is that the best we can do?

charge

probonopd avatar Jun 21 '15 20:06 probonopd

Isn't that a 5V device???

On 21 June 2015 at 22:00, probonopd [email protected] wrote:

I am measuring 0.07A power consumption using a "Charger Doctor" like shown here, regardless of whether I am connected to WiFi or just running a blink sketch. Is that the best we can do?

[image: charge] https://cloud.githubusercontent.com/assets/2480569/8273162/e1c1d36a-1860-11e5-94e0-8f6f006d954f.png

— Reply to this email directly or view it on GitHub https://github.com/esp8266/Arduino/issues/460#issuecomment-113950284.

duncan-a avatar Jun 21 '15 23:06 duncan-a

Yes but I am using a voltage regulator to bring it down to 3.3V

probonopd avatar Jun 21 '15 23:06 probonopd

OK, so how much are the voltage regulator, power LED and other things 'wasting'?

Frankly I wouldn't rely on that being accurate anyway - is it's own display and electronics consumption having an effect?

Are you actually invoking the default Modem Sleep mode?

On 22 June 2015 at 01:28, probonopd [email protected] wrote:

Yes but I am using a voltage regulator to bring it down to 3.3V

— Reply to this email directly or view it on GitHub https://github.com/esp8266/Arduino/issues/460#issuecomment-113968548.

duncan-a avatar Jun 21 '15 23:06 duncan-a

Have a look at the sleep modes like WAKE_RF_DISABLED to disable WLAN after deep sleep. Probably it is possible to reenable with WAKE_RF_DEFAULT and another deepsleep.

// disable RF after deep-sleep wake up, just like modem sleep, there will be the smallest current.

Its not == modem sleep but you are right. There is no documentation about how to enable modem sleep without deepsleep.

cimba007 avatar Jun 22 '15 12:06 cimba007

One could go to ESP.deepSleep(1, WAKE_RF_DISABLED) and then immediately wake up, but that would require GPIO16 to be tied to RST to wake from deepSleep - on the ESP-01 there is no (easy) way to get to GPIO16 physically

probonopd avatar Jun 22 '15 18:06 probonopd

I'v been trying to do the same thing and have looked into the approach of going to sleep and immediately waking up. Trouble is is how do you stop doing it again, and again etc. I've thought about writing something to EEprom however rather than that is there something I can test to see if WiFi is on or off before going back to sleep?

iotmodules avatar Jul 13 '15 13:07 iotmodules

I have tried all the assorted ESP.DeepSleep modes and also tried using the blobs directly with wifi_set_sleep_type and system_deep_sleep_set_option and so far no matter what I do it awakens and draws 64mA or so ..

Does anyone have a confirmed way of obtaining the modem sleep current drain ?

stonemull avatar Aug 04 '15 07:08 stonemull

Turns out this is only an issue with the staging release and not with the stable release. My apologys.

stonemull avatar Aug 06 '15 14:08 stonemull

void loop() {extern "C" {
#include "user_interface.h"
}

#include <ESP8266WiFi.h>

const char* ssid = "****";
const char* pass = "****";


void setup() {
  WiFi.begin(ssid, pass);
  uint8_t i = 0;
  while (WiFi.status() != WL_CONNECTED && i++ < 10) delay(250);

  // put your setup code here, to run once:
  wifi_set_sleep_type(LIGHT_SLEEP_T);
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(10000);
}

Sketch consuming ~15mA (rapid spikes between 7-37 mA ) with using staging release. Got similar results without connecting to router. That means something use CPU at background. What it is? . :-1:

PS: Consumption I also include linear voltage regulator (which is smd 662K but that doesn't make huge differences.) .

EUA avatar Aug 25 '15 17:08 EUA

Is the call to wifi_set_sleep_type() enough to put the unit in light sleep mode?

croisez avatar Dec 14 '15 13:12 croisez

My understanding - though some confirmation needed through tests is: setting the mode (Modem-Sleep) sets how the wifi chip handles being on - it will switch off the wifii, and wait for a beacon interval, then switch on to receive it.

Calling WiFi.disconnect(); will switch off the wifi, reducing this power consumption - and I assume we can call WiFi.mode(WIFI_STA) then WiFi.connect() afterwards to get back going again. I believe passing ip parameters will make connect use less power, but am off to test this.

stevescot avatar Jan 04 '16 15:01 stevescot

and I believe light sleep still maintains wifi connection:

http://bbs.espressif.com/viewtopic.php?t=133

②:During Light-Sleep, 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 according to the 802.11 standard (U-APSD). E.g. in DTIM3, to maintain a sleep 300ms-wake 3ms cycle to receive AP’s Beacon packages, the current is about 0.9mA.

stevescot avatar Jan 04 '16 15:01 stevescot

so I am guessing if you enable Light-sleep, then wifi.disconnect() and delay(some long period) then you will get less power use.

stevescot avatar Jan 04 '16 15:01 stevescot

Yes I tried to find anything related to DTIM in this library but there is nothing ... try looking in SDK functions ...

shirish47 avatar Jan 04 '16 17:01 shirish47

latest git and Staging supports:

    WiFi.forceSleepBegin(uint32 sleepUs = 0);
    WiFi.forceSleepWake();

wit this functions the WiFi can be forced to sleep.

Links2004 avatar Jan 04 '16 19:01 Links2004

@Links2004 Thank you. Can this be used to disable WLAN entirely, altogether?

probonopd avatar Jan 04 '16 19:01 probonopd

it will force the chip to modem mode, at least that is what the SDK docs say ;) if you do some measurement like too see it :)

Links2004 avatar Jan 04 '16 20:01 Links2004