Need help for Light sleep mode[Done]

rupak426
Posts: 23
Joined: Fri Apr 15, 2016 2:16 am

Need help for Light sleep mode[Done]

Postby rupak426 » Tue Jun 14, 2016 1:38 am

Hi,

I am trying to make use of light sleep for my ESP-8266-01 with the help of below code:

Serial.println("Wifi_off_timerfunc called to disable wifi");
wifi_station_disconnect();
wifi_set_opmode(NULL_MODE);
wifi_fpm_set_sleep_type(LIGHT_SLEEP_T);
Serial.println("set the sleep as LIGHT SLEEP");
wifi_fpm_open();
os_timer_disarm(&on_timer);
os_timer_setfn(&on_timer, (os_timer_func_t *)fpm_wakup_cb_func1, NULL);

In the normal mode, I measured the current and its showing 70~80mA.
But when I am measuring the current output after " LIGHT SLEEP (5th line from top)", still the measure current is 70~80mA.
can you let me know if I am missing something while invoking the "LIGHT sleep".
Also can you let me know is there any API to modify the Beacon interval & DTIM interval.

thanks,
Rupak

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: Need help for Light sleep mode

Postby ESP_Faye » Tue Jun 14, 2016 9:49 am

Hi,

What is the version of your SDK ?

Please have a try with the ESP8266_NONOS_SDK_V1.5.4, we solved the problem about light sleep.

rupak426
Posts: 23
Joined: Fri Apr 15, 2016 2:16 am

Re: Need help for Light sleep mode

Postby rupak426 » Tue Jun 14, 2016 4:34 pm

Hi,

I am using SDK version as ESP8266_NONOS_SDK_V1.5.4_16_05_20.

thanks,
Rupak

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: Need help for Light sleep mode

Postby ESP_Faye » Tue Jun 14, 2016 5:03 pm

Hi,

timer will prevent the chip from entering light sleep, please do NOT use timer for light sleep.
Sorry for the inconvenience, we will add it in the documentation.
You can use it as the sample code below.

Code: Select all

#define FPM_SLEEP_MAX_TIME  0xFFFFFFF

void fpm_wakup_cb_func1(void)
{
   wifi_fpm_close();      // disable force sleep function
   wifi_set_opmode(STATION_MODE);         // set station mode
   wifi_station_connect();            // connect to AP
}

#ifndef SLEEP_MAX
// Wakeup till time out.
void user_func(...)

   wifi_station_disconnect();
   wifi_set_opmode(NULL_MODE);         // set WiFi mode to null mode.
   wifi_fpm_set_sleep_type(LIGHT_SLEEP_T); // light sleep
   wifi_fpm_open();               // enable force sleep
   wifi_fpm_set_wakeup_cb(fpm_wakup_cb_func1); // Set wakeup callback
   wifi_fpm_do_sleep(50*1000);     
}
#else

// Or wake up by GPIO
void user_func(...)

   wifi_station_disconnect();
   wifi_set_opmode(NULL_MODE); // set WiFi mode to null mode.
   wifi_fpm_set_sleep_type(LIGHT_SLEEP_T);    // light sleep
   wifi_fpm_open();               // enable force sleep

   PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U,3);
   gpio_pin_wakeup_enable(13, GPIO_PIN_INTR_LOLEVEL);

   wifi_fpm_set_wakeup_cb(fpm_wakup_cb_func1);   // Set wakeup callback
   wifi_fpm_do_sleep(FPM_SLEEP_MAX_TIME);       
   ...
}
#endif

rupak426
Posts: 23
Joined: Fri Apr 15, 2016 2:16 am

Re: Need help for Light sleep mode

Postby rupak426 » Tue Jun 14, 2016 5:22 pm

Thanks for the quick response. I will verify the same after removing the timer from sleep function.

one more query:
can you let me know is there any API to modify the Beacon interval & DTIM interval?

thanks,
Rupak

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: Need help for Light sleep mode

Postby ESP_Faye » Wed Jun 15, 2016 10:05 am

Hi,

Code: Select all

struct softap_config {
    uint8 ssid[32];
    uint8 password[64];
    uint8 ssid_len;   // Note: Recommend to set it according to your ssid
    uint8 channel;   // Note: support 1 ~ 13
    AUTH_MODE authmode;   // Note: Don't support AUTH_WEP in softAP mode.
    uint8 ssid_hidden;   // Note: default 0
    uint8 max_connection;   // Note: default 4, max 4
    uint16 beacon_interval;   // Note: support 100 ~ 60000 ms, default 100
};

bool wifi_softap_set_config(struct softap_config *config);


Thanks for your interest in ESP8266 !

Mdb
Posts: 10
Joined: Mon Oct 17, 2016 3:29 pm

Re: Need help for Light sleep mode[Done]

Postby Mdb » Tue Nov 08, 2016 7:16 pm

Sorry for intervening on this topic but it appears the right place for pointing out some aspects.
I manage to get the forced light sleep following the code provided here.
Two questions :
- you use fpm APIs, is the automatic way to enter light sleep still valid under RTOS SDK ?
- you disconnect the station before forcing the sleep state, light sleep is made to avoid this, i mean, i want let Espressif sleeps WITHOUT loosing the connection to the router ( another espressif acting as TCP Server through AT Binaries), or without the need to reconnect to the router ( it takes time..)

Did I miss something ?

I use the last SDK 1.4.2 ( patched )

Auto - Solved : Using the right API : wifi_set_sleep_type().
This way i see what expected, low current between beacons if no other task are running.

roc2
Posts: 12
Joined: Tue Oct 25, 2016 3:57 pm

Re: Need help for Light sleep mode[Done]

Postby roc2 » Sat Nov 19, 2016 4:41 pm

I have the same trouble with you.In light sleeps' forcing mode ,I do not expect ESP8266 to reconnect after wakeup.According to my test,it wastes 500ms to reconnnect.
We hope that Espressss' enginner can give us suggestion.

Who is online

Users browsing this forum: No registered users and 3 guests