【Feedback】求助:关于LIGHT-SLEEP功耗

greatz.yu
Posts: 10
Joined: Sun Jul 10, 2016 10:36 pm

【Feedback】求助:关于LIGHT-SLEEP功耗

Postby greatz.yu » Tue Jul 12, 2016 4:09 pm

HI,乐鑫。
我们设计的一个产品计划使用贵公司的ESP8266EX,现在在测试功耗部分。
SDK都已经升级到了最新的RTOS1.4.2与NONOS1.5.4,测试了官方代码如下(只贴了RTOS部分,NONOS也测试了没有贴),发现电流不像0A文档7.1中所述1.2mA,实际远超该电流,测试电流波形如图所示(连接http://note.youdao.com/share/?id=b1e70554b0e7b4b79cb1dcfe983f0678&type=note#/),原因应该在于在处理完DTIM后经常性的没有能进入LIGHT-SLEEP而是进入了MODEM-SLEEP。NONOS与RTOS现象相同,所以想请问官方给的0A手册表格是用哪一个SDK测试的?
按照http://bbs.espressif.com/viewtopic.php?f=6&t=133&p=485&hilit=dtim#p485
viewtopic.php?f=7&t=171&p=637&hilit=dtim#p637
这边的说明应该是连续都是LIGHT-SLEEP电流。
迫切希望得到帮助!多谢!

Code: Select all

void fpm_wakup_cb_func1(void)
{
   wifi_fpm_close();
   wifi_set_opmode(STATION_MODE);
   wifi_set_sleep_type(LIGHT_SLEEP_T);
   {
      struct station_config *config = (struct station_config *)zalloc(sizeof(struct station_config));
      sprintf(config->ssid, "xxx");
      sprintf(config->password, "xxxx");

      /* need to sure that you are in station mode first,
       * otherwise it will be failed. */
      wifi_station_set_config(config);
      free(config);
   }
   wifi_station_connect();
   //wifi_set_sleep_type(LIGHT_SLEEP_T);
}

void user_init(void)
{
wifi_station_disconnect();
    wifi_set_opmode(NULL_MODE);
    wifi_fpm_set_sleep_type(LIGHT_SLEEP_T);
    wifi_fpm_open();
    wifi_fpm_set_wakeup_cb(fpm_wakup_cb_func1);
    wifi_fpm_do_sleep(10000*1000);
    }


Image
Image
Last edited by greatz.yu on Tue Jul 12, 2016 8:15 pm, edited 1 time in total.

ESP_Rubin
Posts: 222
Joined: Wed Jun 29, 2016 11:59 am

Re: 求助:关于LIGHT-SLEEP功耗

Postby ESP_Rubin » Tue Jul 12, 2016 4:46 pm

你好,
没有看到电流图片,麻烦帮忙传一下,谢谢!!

greatz.yu
Posts: 10
Joined: Sun Jul 10, 2016 10:36 pm

Re: 求助:关于LIGHT-SLEEP功耗

Postby greatz.yu » Tue Jul 12, 2016 5:05 pm

esp_rubin wrote:你好,
没有看到电流图片,麻烦帮忙传一下,谢谢!!

http://note.youdao.com/yws/public/redir ... type=false
示波器显示的黄色通道就是电流,通过测量串联入电路0.1欧姆测量电阻两端电压(增益200),即1V对应50mA;示波器图中一格表示25mA; :P

ESP_Rubin
Posts: 222
Joined: Wed Jun 29, 2016 11:59 am

Re: 求助:关于LIGHT-SLEEP功耗

Postby ESP_Rubin » Tue Jul 12, 2016 5:15 pm

你好,
你测得是我们的模组还是自己做的板子

greatz.yu
Posts: 10
Joined: Sun Jul 10, 2016 10:36 pm

Re: 求助:关于LIGHT-SLEEP功耗

Postby greatz.yu » Tue Jul 12, 2016 8:11 pm

esp_rubin wrote:你好,
你测得是我们的模组还是自己做的板子

模组,你们的WROM-01与安可信的模组都测试了,结果一样 :|
使用的编译环境是基于eclipse的ESP8266-DevKit-Beta-v2.1.0与2.0.9两个版本。

ESP_Rubin
Posts: 222
Joined: Wed Jun 29, 2016 11:59 am

Re: 求助:关于LIGHT-SLEEP功耗

Postby ESP_Rubin » Wed Jul 13, 2016 2:24 pm

试一下这段代码

Code: Select all

void fpm_wakup_cb_func1(void)
{
   wifi_fpm_close();
   wifi_set_opmode(STATION_MODE);
   //wifi_set_sleep_type(LIGHT_SLEEP_T);
   {
      struct station_config *config = (struct station_config *)zalloc(sizeof(struct station_config));
      sprintf(config->ssid, "xxx");
      sprintf(config->password, "xxxx");

      /* need to sure that you are in station mode first,
       * otherwise it will be failed. */
      wifi_station_set_config(config);
      free(config);
   }
   wifi_station_connect();
   sleeping();
   //wifi_set_sleep_type(LIGHT_SLEEP_T);
}

void sleeping(void)
{
   wifi_station_disconnect();
   if(wifi_set_opmode(NULL_MODE)){os_printf("Set Null Mode OK\n");}
   wifi_fpm_set_sleep_type(LIGHT_SLEEP_T);
   wifi_fpm_open();
   wifi_fpm_set_wakeup_cb(fpm_wakup_cb_func1);
   os_printf("SUP: %d \n",wifi_fpm_do_sleep(10*1000*1000));
}

void user_init(void)
{
   sleeping();
}

greatz.yu
Posts: 10
Joined: Sun Jul 10, 2016 10:36 pm

Re: 求助:关于LIGHT-SLEEP功耗

Postby greatz.yu » Wed Jul 13, 2016 5:10 pm

esp_rubin wrote:试一下这段代码

Code: Select all

void fpm_wakup_cb_func1(void)
{
   wifi_fpm_close();
   wifi_set_opmode(STATION_MODE);
   //wifi_set_sleep_type(LIGHT_SLEEP_T);
   {
      struct station_config *config = (struct station_config *)zalloc(sizeof(struct station_config));
      sprintf(config->ssid, "xxx");
      sprintf(config->password, "xxxx");

      /* need to sure that you are in station mode first,
       * otherwise it will be failed. */
      wifi_station_set_config(config);
      free(config);
   }
   wifi_station_connect();
   sleeping();
   //wifi_set_sleep_type(LIGHT_SLEEP_T);
}

void sleeping(void)
{
   wifi_station_disconnect();
   if(wifi_set_opmode(NULL_MODE)){os_printf("Set Null Mode OK\n");}
   wifi_fpm_set_sleep_type(LIGHT_SLEEP_T);
   wifi_fpm_open();
   wifi_fpm_set_wakeup_cb(fpm_wakup_cb_func1);
   os_printf("SUP: %d \n",wifi_fpm_do_sleep(10*1000*1000));
}

void user_init(void)
{
   sleeping();
}


非常感谢您的回复!
您这段程序是连续地使芯片断开连接强制进入睡眠啊,这样会使wifi断开连接。我是需要在连接上路由之后通过DTIM一直保持连接,我的程序前面部分强制睡眠只是为了检测芯片进入睡眠时的电流是多大,在睡眠10s以后作为station连接上路由之后需要保持连接,所以后面没有进入强制睡眠模式(因为进入强制睡眠需要做断开连接切换opmode)。
根据波形每八个DTIM会有一次75mA左右电流应该是在RF校准这可以理解;但接受完每个DTIM的包后经常性没能进入到light-sleep(此时cpu还有高优先级任务??),使得经常性有15-20mA的电流,这个就比较难理解了。。。
请问有测试保持连接时功耗的程序&SDK吗?

ESP_Rubin
Posts: 222
Joined: Wed Jun 29, 2016 11:59 am

Re: 【Feedback】求助:关于LIGHT-SLEEP功耗

Postby ESP_Rubin » Thu Jul 14, 2016 2:46 pm

你好,
你是想测试连接状态下的功耗,我这边试了一下您的代码和我自己的这段代码,AP设置DTIM为100ms,结果差不多是3.xmA(这个是我们目前已知的issue,会在新的SDK中fix该问题),应该是进入了light_sleep,您可以参考这段NONOS代码,使用您的代码,可能需要等一会,才会进入light_sleep模式

Code: Select all

#include "ets_sys.h"
#include "osapi.h"

#include "mem.h"
#include "user_interface.h"
#include "espconn.h"



LOCAL os_timer_t test_timer;

/******************************************************************************
 * FunctionName : user_esp_platform_check_ip
 * Description  : check whether get ip addr or not
 * Parameters   : none
 * Returns      : none
*******************************************************************************/
void ICACHE_FLASH_ATTR
user_esp_platform_check_ip(void)
{
    struct ip_info ipconfig;

   //disarm timer first
    os_timer_disarm(&test_timer);

   //get ip info of ESP8266 station
   wifi_station_set_hostname("rubin_8266_test");
    wifi_get_ip_info(STATION_IF, &ipconfig);

    if (wifi_station_get_connect_status() == STATION_GOT_IP && ipconfig.ip.addr != 0) {

      os_printf("got ip !!! \r\n");
   
   if(wifi_set_sleep_type(1))
      os_printf("sleep success\n");
   else
      
      os_printf("sleep fail\n");
    } else {
       
        if ((wifi_station_get_connect_status() == STATION_WRONG_PASSWORD ||
                wifi_station_get_connect_status() == STATION_NO_AP_FOUND ||
                wifi_station_get_connect_status() == STATION_CONNECT_FAIL)) {
               
         os_printf("connect fail !!! \r\n");
         
        } else {
       
           //re-arm timer to check ip
            os_timer_setfn(&test_timer, (os_timer_func_t *)user_esp_platform_check_ip, NULL);
            os_timer_arm(&test_timer, 100, 0);
        }
    }
}


/******************************************************************************
 * FunctionName : user_set_station_config
 * Description  : set the router info which ESP8266 station will connect to
 * Parameters   : none
 * Returns      : none
*******************************************************************************/
void ICACHE_FLASH_ATTR
user_set_station_config(void)
{
   // Wifi configuration
   char ssid[32] = "LB_LINK_V5";
   char password[64] = "";
   struct station_config stationConf;
   
   os_memset(stationConf.ssid, 0, 32);
   os_memset(stationConf.password, 0, 64);
   //need not mac address
   stationConf.bssid_set = 0;
   
   //Set ap settings
   os_memcpy(&stationConf.ssid, ssid, 32);
   os_memcpy(&stationConf.password, password, 64);
   wifi_station_set_config(&stationConf);

   //set a timer to check whether got ip from router succeed or not.
   os_timer_disarm(&test_timer);
    os_timer_setfn(&test_timer, (os_timer_func_t *)user_esp_platform_check_ip, NULL);
    os_timer_arm(&test_timer, 100, 0);

}


/******************************************************************************
 * FunctionName : user_init
 * Description  : entry of user application, init user function here
 * Parameters   : none
 * Returns      : none
*******************************************************************************/
void user_init(void)
{
    os_printf("SDK version:%s\n", system_get_sdk_version());
   
   //Set softAP + station mode
   wifi_set_opmode(STATION_MODE);

   // ESP8266 connect to router.
    user_set_station_config();

//   wifi_set_sleep_type(1);
}


greatz.yu
Posts: 10
Joined: Sun Jul 10, 2016 10:36 pm

Re: 【Feedback】求助:关于LIGHT-SLEEP功耗

Postby greatz.yu » Thu Jul 14, 2016 4:47 pm

esp_rubin wrote:你好,
你是想测试连接状态下的功耗,我这边试了一下您的代码和我自己的这段代码,AP设置DTIM为100ms,结果差不多是3.xmA(这个是我们目前已知的issue,会在新的SDK中fix该问题),应该是进入了light_sleep,您可以参考这段NONOS代码,使用您的代码,可能需要等一会,才会进入light_sleep模式

Code: Select all

#include "ets_sys.h"
#include "osapi.h"

#include "mem.h"
#include "user_interface.h"
#include "espconn.h"



LOCAL os_timer_t test_timer;

/******************************************************************************
 * FunctionName : user_esp_platform_check_ip
 * Description  : check whether get ip addr or not
 * Parameters   : none
 * Returns      : none
*******************************************************************************/
void ICACHE_FLASH_ATTR
user_esp_platform_check_ip(void)
{
    struct ip_info ipconfig;

   //disarm timer first
    os_timer_disarm(&test_timer);

   //get ip info of ESP8266 station
   wifi_station_set_hostname("rubin_8266_test");
    wifi_get_ip_info(STATION_IF, &ipconfig);

    if (wifi_station_get_connect_status() == STATION_GOT_IP && ipconfig.ip.addr != 0) {

      os_printf("got ip !!! \r\n");
   
   if(wifi_set_sleep_type(1))
      os_printf("sleep success\n");
   else
      
      os_printf("sleep fail\n");
    } else {
       
        if ((wifi_station_get_connect_status() == STATION_WRONG_PASSWORD ||
                wifi_station_get_connect_status() == STATION_NO_AP_FOUND ||
                wifi_station_get_connect_status() == STATION_CONNECT_FAIL)) {
               
         os_printf("connect fail !!! \r\n");
         
        } else {
       
           //re-arm timer to check ip
            os_timer_setfn(&test_timer, (os_timer_func_t *)user_esp_platform_check_ip, NULL);
            os_timer_arm(&test_timer, 100, 0);
        }
    }
}


/******************************************************************************
 * FunctionName : user_set_station_config
 * Description  : set the router info which ESP8266 station will connect to
 * Parameters   : none
 * Returns      : none
*******************************************************************************/
void ICACHE_FLASH_ATTR
user_set_station_config(void)
{
   // Wifi configuration
   char ssid[32] = "LB_LINK_V5";
   char password[64] = "";
   struct station_config stationConf;
   
   os_memset(stationConf.ssid, 0, 32);
   os_memset(stationConf.password, 0, 64);
   //need not mac address
   stationConf.bssid_set = 0;
   
   //Set ap settings
   os_memcpy(&stationConf.ssid, ssid, 32);
   os_memcpy(&stationConf.password, password, 64);
   wifi_station_set_config(&stationConf);

   //set a timer to check whether got ip from router succeed or not.
   os_timer_disarm(&test_timer);
    os_timer_setfn(&test_timer, (os_timer_func_t *)user_esp_platform_check_ip, NULL);
    os_timer_arm(&test_timer, 100, 0);

}


/******************************************************************************
 * FunctionName : user_init
 * Description  : entry of user application, init user function here
 * Parameters   : none
 * Returns      : none
*******************************************************************************/
void user_init(void)
{
    os_printf("SDK version:%s\n", system_get_sdk_version());
   
   //Set softAP + station mode
   wifi_set_opmode(STATION_MODE);

   // ESP8266 connect to router.
    user_set_station_config();

//   wifi_set_sleep_type(1);
}



非常感谢你的回复 :D ,对比你的与我的程序,发现我使用了默认的hostname。我增加更改hostname命令后使用NONOS功耗明显降下来了,基本能90%左右次数进入light-sleep。
但使用RTOS,有改善,但是还会有较大电流,还有之前的现象(我猜测不同SDK是使用了不同库,之间有较大区别?),还是说我缺少一些配置。。。
PS:能透露下下次的SDK的时间吗?下次会在RTOS中解决这个问题吗?
多谢!

ESP_Rubin
Posts: 222
Joined: Wed Jun 29, 2016 11:59 am

Re: 【Feedback】求助:关于LIGHT-SLEEP功耗

Postby ESP_Rubin » Thu Jul 14, 2016 5:43 pm

你好,
最新的SDK这周应该会release,你可以关注我们官网和BBS。
另外设置hostname应该不是睡不下去的原因,在我的代码中,去掉hostname设置,一样可以进入light-sleep,您可能需要再检查一下您的代码

Who is online

Users browsing this forum: No registered users and 16 guests