-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Command to disable WiFi to save power #460
Comments
This is not an issue, ask your question in relevant part of the forum : Forum |
I've just checked the SDK docs for
So modem sleep is enabled by default. |
Isn't that a 5V device??? On 21 June 2015 at 22:00, probonopd notifications@github.com wrote:
|
Yes but I am using a voltage regulator to bring it down to 3.3V |
OK, so how much are the voltage regulator, power LED and other things Frankly I wouldn't rely on that being accurate anyway - is it's own display Are you actually invoking the default Modem Sleep mode? On 22 June 2015 at 01:28, probonopd notifications@github.com wrote:
|
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. |
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 |
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? |
I have tried all the assorted ESP.DeepSleep modes and also tried using the blobs directly with Does anyone have a confirmed way of obtaining the modem sleep current drain ? |
Turns out this is only an issue with the staging release and not with the stable release. My apologys. |
Sketch consuming ~15mA (rapid spikes between 7-37 mA ) with using staging release. PS: Consumption I also include linear voltage regulator (which is smd 662K but that doesn't make huge differences.) . |
Is the call to wifi_set_sleep_type() enough to put the unit in light sleep mode? |
My understanding - though some confirmation needed through tests is: 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. |
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). |
so I am guessing if you enable Light-sleep, then wifi.disconnect() and delay(some long period) then you will get less power use. |
Yes I tried to find anything related to DTIM in this library but there is nothing ... try looking in SDK functions ... |
latest git and Staging supports: WiFi.forceSleepBegin(uint32 sleepUs = 0);
WiFi.forceSleepWake(); wit this functions the WiFi can be forced to sleep. |
@Links2004 Thank you. Can this be used to disable WLAN entirely, altogether? |
it will force the chip to modem mode, at least that is what the SDK docs say ;) |
using cheap multimeter, my sketch reads 70mA on what is idle with WiFi.forceSleepBegin(2000000) - I had 2 seconds of 20mA :) - so it definitely makes a difference... |
oh, and I have no voltage regulator, running straight off a 3.7V Li-ion battery. |
fyi i'm using these functions, and the staging release - Links2004 i see you commited these changes? - Thanks!! where wakeUp is called when I want to reconnect, (note without calling delay after forceSleep - I still get 70mA, and the code continues to run immediately.) void wakeUp() void goToSleep(unsigned int ms) Light sleep doesn't seem to do anything, gpio_pin_wakeup_enable(uint32 i, GPIO_INT_TYPE intr_state) I can't get that to compile - |
forceSleepBegin will only disable the WiFi not the "cpu core", |
70mA is not good, 20mA is what we should be looking for in Modem-Sleep (see the first post in this thread). |
EUA - could you try calling WiFi.forceSleepBegin(26843455) after setting Light sleep mode - that should put the chip into true light-sleep and will require a pin interrupt to wake it, that should hopefully reduce the power to 0.5mA Links2004 - thanks for your help - I'm guessing from my results that my wifi chip is not going to sleep between beacon intervals as it only drops to 20mA (modem sleep) when I force sleep - I thought that would happen normally when the wifi chip is waiting between beacon intervals. |
ps. I should have said - I get 70mA when I haven't called delay() but have forced sleep. - but when I call delay() after having forced sleep - I get 20mA, so modem sleep is working with this code, i'm guessing delay does yield. - I'm going to try Light-Sleep with interrupt tonight. |
note: |
Thanks for that Links2004 - To clarify - when I call delay(2000) - I only get 2 seconds of 20mA - then it returns to 70mA, as soon as my sketch continues, so it seems that only when the chip is idle, not doing any CPU processing, does the sleep actually make a difference to the power use? |
Sorry forced modem sleep works. Still trying on light sleep. |
I've been playing with the forced sleep modes but not been able to get forced light sleep to work yet either. Using the 2.1.0-rc1 code and a skecth based on the 1.5.1 SDK Guide example on page 91 (http://bbs.espressif.com/download/file.php?id=1044) but it doesn't seem to make any difference between calling wifi_fpm_set_sleep_type with MODEM_SLEEP_T or LIGHT_SLEEP_T and it always just does a modem sleep and so uses 15mA.
|
FYI - here's an arduino sketch you can use on an UNO to get power usage at 20ms resolution: output looks like this: Internal 1.1V reference |
incase the text file doesn't work: //Capture full defintion data
|
Maybe I am doing something wrong, but this sketch doesn't seem to save any power for me. Can someone please verify power consumption with without the
|
I tested the power consumtion with the following simple code: `void setup() { // initialize digital pin 13 as an output. digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) This is all without actively using the WiFi connection. If I do a similar thing with an existing WiFi connection of the HelloServer example: yield(); This example does not work, also without the WiFi.begin command. And sometimes, the whole ESP chip is screwed up and only creates dumps. Reset does not help. I have to run another sketch with the command ESP.deepSleep(10000000, WAKE_RF_DEFAULT); in it. Then, the chip is usable again. |
it is just a guess. I read something about station and ap mode. |
yes in AP mode there is no auto |
Hi @stevescot, regarding your sketch and circuit to mesure the current usage of ESP8266, it is correct to power the ESP8266 on through GND and VIN using a 3.7V battery? Shouldn't it be through GND 3V3? Also, how would I could do the wiring using the 5V ou the 3v3 output from UNO to power the ESP? Thank you! |
The code I posted in #644 seems to work for me using AP mode. |
antelder wrote:
I have tried for a day to launch LightSLEEP on ESP and have concluded that if I specified time of sleep (wifi_fpm_do_sleep(TIME<0xFFFFFFF)) then MCU doesnt suspend as it would be in LIGHT_SLEEP, but if I specified sleep time as 0xFFFFFFF then MCU suspend. |
I stumbled across this thread because I didn't want to use the normal RST to XPD trick to put my Thing Dev board to sleep. I cobbled together a working sketch based on this thread. Works well for me. Unit runs at ~70mA with WiFi on, then sleeps at 14.7mA for 6 seconds, then goes back to 70mA (connects to WiFi), then goes to sleep, repeat... #include <ESP8266WiFi.h>
#include "credentials.h" //Contains WiFi SSID and password
const int sleepTime = 6; //Power down WiFi for 6 seconds
void setup()
{
Serial.begin(115200);
}
void loop()
{
WiFi.begin(ssid, pass); //Connect to local Wifi
Serial.println();
Serial.print("Connecting to WiFi");
while(WiFi.status() != WL_CONNECTED)
{
Serial.print(".");
delay(500);
}
Serial.println("WiFi Connected!");
//Do your thing.
//Time to let the WiFi go to sleep!
Serial.println("Sleeping...");
WiFi.disconnect();
WiFi.mode(WIFI_OFF);
WiFi.forceSleepBegin(sleepTime * 1000000L); //In uS. Must be same length as your delay
delay(sleepTime * 1000); //Hang out at 15mA for 6 seconds
WiFi.mode(WIFI_STA);
Serial.println("Awake!");
} Thing Dev Board is powered with 3.7V LiPo into the onboard 3.3V regulator. Power LED disabled. I'm happy to have gotten the ESP8266 into Modem-Sleep. Let me know if it works for you or if there are ways to simplify it even more. |
Modem sleep with its 15mA is to much for me. Our device is supplied by 2500mAh battery and have to work for a week performing some additional power opertions, so I need Light sleep to lower consumption for at least to 1..3mA. At the moment I can provide Light sleep but only in a case:
but in such a case device cannot be awaken after some time, and if I try to specifiy time, e.g. I just want to understand if it is possible to bring ESP MCU to sleep (not Modem or Deep but Light) having a possibility to wakeup by internal timer |
@ukrsms - You can put the ESP into deep sleep (80uA) with the
Pros to deep sleep:
Cons to deep sleep:
|
Thank you, @nseidle, but I need to keep RAM and MCU ready to start immediately after external Interrupt occurred, so DeepSleep is not the solution |
@nseidle just a remark about
In fact if you reset the board not via RST but via CH_PD this is avoided. If i remember correctly this is how it is officially suggested by Esspresif. I do not know how it happened that most of the dev boards nowadays connected RST to GPIO16 (it may be as well be that i missed some potential problem). I am using this in my boards since several months and it works. |
Ah, makes sense.
Have you tested this? If not be cautious with statement of facts. I ask because Espressif is notorious for their poor documentation. Most recent datasheet for ESP8266 I could find is here. From datasheet:
So I think, and have tested (with our hardware) that to exit deep sleep GPIO16 (aka XPD_DCDC) needs to be connected to EXT_RSTB (aka RST). I like your idea of using the CHIP_PU chip enable pin but I'm not sure what the behavior will be when you enter deep sleep and then use XPD to then pull CHIP_PU high again. If you can test this I'd love to hear what you find. |
@nseidle While the device is in deepsleep it is possible to trigger CHIP_PU down (connected to Serial RTS) and then UP and the device reboots. I also use this quite often, as my device goes to sleep after a minute of operation and does no longer accept serial commands. So i just set RTS to LOW and then HIGH and the device reboots. The RTC memory is also cleared in this case (which doesn't happen always when calling ESP.reset() (or.reboot() forgot the exact name)) |
…tion the first state loop after reset. Following esp8266/Arduino#460 to try to reduce power consumption when not using wifi by calling forceSleepBegin, forceSleepWake
Hi dear friends, |
Dear @ufukv, you realize that this might be the wrong forum for your question. STM32F051R8 is a completely different hardware and software from what is discussed here. |
Current API has most of the sleep functionality. Only one that's a bit unclear is light sleep, which is tracked elsewhere. |
The module "AT + GSLP = <time>" enters deep sleep. But I do not want you to
wake up after a certain period of time. I want you to wake up sleeping when
I press the button. Is this possible ?
2017-10-20 17:22 GMT+03:00 Develo <notifications@github.com>:
… Current API has most of the sleep functionality. Only one that's a bit
unclear is light sleep, which is tracked elsewhere.
Closing.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#460 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AVgIjUxNzLNS-6YjC37COkV8itrisZGsks5suKyUgaJpZM4FIVNp>
.
|
Yes, remove connection between GPIO16 and RESET and wake-up by pulling RESET. This has been discussed in the forum so please do some search on esp8266.com forum... |
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.
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: