SDK 2.1 ligth sleep mode

Posts: 6
Joined: Mon Jan 15, 2018 6:34 pm

SDK 2.1 ligth sleep mode

Postby JulienInnovel » Mon Jan 15, 2018 6:43 pm


I'm using the new SDK 2.1 since this morning.
Until the new sdk (using the SDK 2.0), I was able to use the light sleep mode by doing this :

void fpm_wakup_cb(void)
wifi_fpm_close(); // disable force sleep function
wifi_set_opmode(STATION_MODE); // set station mode
wifi_station_connect(); // connect to AP
os_timer_arm(&s_Timer, TIMER_TIME_MS, 1);
os_printf("WakeUp !\n");

void ICACHE_FLASH_ATTR prepare_to_sleep(void)
int8_t err;

os_printf("Go to sleep mode...\n\n");
//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); // Set wakeup callback
UART_CheckOutputFinished(UART1, 1000000);
wifi_fpm_do_sleep(30 * 1000 * 1000);

Each time I call function prepare_to_sleep, the ESP enter sleep mode and wake up after 30s.
But, since the new SDK 2.1, it doesn't work...
Sometimes the wakeup is done juste after the sleep, like if sleep timeout is 1us, and sometimes no wakeup from sleep...

Maybe I do something wrong...

Thanks for your help,
Best regards

Her Majesty
Posts: 252
Joined: Mon Oct 27, 2014 11:09 am

Re: SDK 2.1 ligth sleep mode

Postby Her Majesty » Wed Jan 17, 2018 4:16 pm

What is the UART_CheckOutputFinished?
If it is a timer, the timer will stop the ESP to enter light sleep mode.

Posts: 6
Joined: Mon Jan 15, 2018 6:34 pm

Re: SDK 2.1 ligth sleep mode

Postby JulienInnovel » Thu Feb 08, 2018 9:12 pm


Here is the function :

Code: Select all

UART_CheckOutputFinished(uint8 uart_no, uint32 time_out_us)
    uint32 t_start = system_get_time();
    uint8 tx_fifo_len;
    uint32 tx_buff_len;
        tx_fifo_len =( (READ_PERI_REG(UART_STATUS(uart_no))>>UART_TXFIFO_CNT_S)&UART_TXFIFO_CNT);
            tx_buff_len = ((pTxBuffer->UartBuffSize)-(pTxBuffer->Space));
            tx_buff_len = 0;
        if( tx_fifo_len==0 && tx_buff_len==0){
            return TRUE;
        if( system_get_time() - t_start > time_out_us){
            return FALSE;
   WRITE_PERI_REG(0X60000914, 0X73);//WTD

Who is online

Users browsing this forum: No registered users and 3 guests