-->
Page 1 of 2

esp8266 Low Power mode - modem sleep

PostPosted: Fri Jan 08, 2016 4:01 am
by Stevescot
The attached sketch shows a simple example of modem sleep,
it will sleep for 20 seconds then wake for 15, and loop.

this requires the staging version in boards manager:
http://arduino.esp8266.com/staging/pack ... index.json

Re: esp8266 Low Power mode - modem sleep

PostPosted: Sat Jan 16, 2016 11:18 am
by Freecanadian
The description sounds interesting, but I could not find an attached sketch.

Can you please re-post the sketch?

Thx.

Re: esp8266 Low Power mode - modem sleep

PostPosted: Sat Jan 16, 2016 11:49 am
by WereCatf
Modem-sleep is enabled by default already when you're running a sketch as STA-mode (not in AP or STA+AP!), but it'll keep waking the WiFi up whenever it needs to. You can manually force the WiFi to sleep for however long you want by basically doing the following:
Code: Select all// Insert whatever code here to turn off all your web-servers and clients and whatnot
WiFi.disconnect();
WiFi.forceSleepBegin();
delay(1); //For some reason the modem won't go to sleep unless you do a delay(non-zero-number) -- no delay, no sleep and delay(0), no sleep


And then wake the WiFi up:
Code: Select allWiFi.forceSleepEnd();
delay(1);
//Insert code to connect to WiFi, start your servers or clients or whatever

Re: esp8266 Low Power mode - modem sleep

PostPosted: Sat Jan 16, 2016 4:08 pm
by Mihi
Check this github discussion: https://github.com/esp8266/Arduino/issues/1381

I used it in my ESP8266 with DHT22 IoT client project: http://homecircuits.eu/blog/esp8266-temperature-iot-logger/