-->
Page 1 of 2

Programmatically powering on and off the Wifi radio?

PostPosted: Sat Apr 11, 2015 1:47 pm
by torntrousers
From a bit of googling i read that calling system_deep_sleep_set_option(4) will:

"disable RF after deep sleep wake up, just like modem sleep, there will be the smallest current."
http://www.mikrocontroller.net/attachme ... v0.9.5.pdf

I gave that i try and found that on wake up an ESP-12 then uses about 12.6 milliamps, compared to the about 74 milliamps with system_deep_sleep_set_option(0).

But of course Wifi doesn't work now as its powered off. Is there any way of programmatically powering it back on without just doing another deep sleep using option 0?

Re: Programmatically powering on and off the Wifi radio?

PostPosted: Sat Apr 11, 2015 3:20 pm
by gerardwr
There is an SDK call setting the sleeptype.

The code below shows some examples of the SDK call, and compiles and runs, but I have not tested the results.

Code: Select allSerial.println("[SDK direct] MODEM_SLEEP"); wifi_set_sleep_type(MODEM_SLEEP_T);
Serial.println("[SDK direct] LIGHT_SLEEP"); wifi_set_sleep_type(LIGHT_SLEEP_T);
Serial.println("[SDK direct] NONE_SLEEP"); wifi_set_sleep_type(NONE_SLEEP_T);


Let us know if you have any kind of success.

Re: Programmatically powering on and off the Wifi radio?

PostPosted: Sat May 30, 2015 10:48 am
by StarkJohan
Any further info on this? Would be nice to be able to start the radio without another deep sleep or shutting it down when not needed to save precious juice.

Re: Programmatically powering on and off the Wifi radio?

PostPosted: Wed Jun 10, 2015 11:19 pm
by zoidicus
StarkJohan wrote:...Would be nice to be able to start the radio without another deep sleep....
Agreed. I've had some pretty good luck with deep sleep so far, storing my program state in RTC memory for the nap, but I just cannot figure out how to re-enable the modem without performing another sleep with different options. Simply calling
Code: Select allwifi_set_sleep_type(0);
(which does return 1) before initializing WiFi doesn't work.