-->
Page 1 of 2

ESP WIFI OFF and ON

PostPosted: Tue Nov 24, 2015 4:18 pm
by danbicks
Guys,

Is there a way to turn off WIFI completely while still leaving the CPU active and running.
I have had a look through the ESP core library ESP8266WIfi.h there seems to be some attempt at implementing this although does not seem complete and command is unrecognized within WiFi.mode(WIFI_OFF)

The Idea is to be able to reduce current and use the CPU for other purposes, when needed WiFi will be turned on to upload data etc and then to resume CPU operations with WiFi switched off.

Has anyone managed to get similar functionality running, please let me know.

Cheers Dans

Re: ESP WIFI OFF and ON

PostPosted: Tue Nov 24, 2015 4:25 pm
by martinayotte
danbicks wrote:there seems to be some attempt at implementing this although does not seem complete and command is unrecognized within WiFi.mode(WIFI_OFF)

What do you mean by "not seem complete" and "unrecognized" ?
Which framework are you using ?

Re: ESP WIFI OFF and ON

PostPosted: Tue Nov 24, 2015 4:26 pm
by Barnabybear
Hi, the only way I've seen it done is on wake from deep sleep (but there is alot I haven't seen). Might be ok as a backup plan, should only cost you 500ms + any write then read from memory with data.

Re: ESP WIFI OFF and ON

PostPosted: Tue Nov 24, 2015 5:09 pm
by danbicks
Thanks @Barnabybear and Martin.

Looking through the ESP8266WiFi.h I can't see where the SDK call to turn off Wifi while still leaving the CPU active is. Martin have you verified this to be functional and operative?. If so what does the total CPU and RTC current drop down to without WifI transmitter and receiver active electrically?

Framework latest staging version.

The Only instance I can find is in the following routines, but I take it that the WiFi transmitter receiver hardware is till consuming current. Can you clarify this for me.

Cheers

Dans

Code: Select allvoid ESP8266WiFiClass::mode(WiFiMode m)
{
    if(wifi_get_opmode() == (uint8)m) {
        return;
    }

    if((m & WIFI_AP)) {
        _useApMode = true;
    } else {
        _useApMode = false;
    }

    if((m & WIFI_STA)) {
        _useClientMode = true;
    } else {
        _useClientMode = false;
    }

    _mode(m);
}



Code: Select allint ESP8266WiFiClass::disconnect(bool wifioff)
{
    struct station_config conf;
    *conf.ssid = 0;
    *conf.password = 0;
    ETS_UART_INTR_DISABLE();
    if (_persistent)
        wifi_station_set_config(&conf);
    else
        wifi_station_set_config_current(&conf);
    wifi_station_disconnect();
    ETS_UART_INTR_ENABLE();

    if(wifioff) {
        _useClientMode = false;

        if(_useApMode) {
            // turn on AP
            _mode(WIFI_AP);
        } else {
            // turn wifi off
            _mode(WIFI_OFF);
        }
    }

    return 0;
}