update tools to disable RF during flash booting.
-----------------------------------------------------------------
We make some improvement for the sleep mode under sdkv0.9.5,especially for light-sleep and deep sleep.
1.light-sleep: we fixed some bugs in the previous version so that the light sleep current performs much better in station mode.
Functioning:
Light-sleep works in station mode and already connected to a AP.In light-sleep mode , the chip would shut down the rf module as well as the cpu for sometime(tens or hundreds of milliseconds).It depends, the lower system will judge whether the chip is idle and can be set into light-sleep mode automatically. Two kinds of factors would decide the light-sleep schedule.a)whether the system task is idle in the following period.b)the AP beacon interval. As a station device , the beacon is totally decided by the AP and esp8266 chip would be self-adaptive to match the beacon so that it can keep the connection alive,receive the wifi packets and stay a low power mode.
APIs:
a)bool wifi_set_sleep_type(LIGHT_SLEEP_T) : To enable the light-sleep function, not get into light-sleep mode directly, but just enable the function and let the system decide when it can sleep.
b).void gpio_pin_wakeup_enable(uint32 i, GPIO_INT_TYPE intr_state) : (parm i is the gpio number) To enable the wake-up-by-gpio function.In this situation, interrupt mode can just be set to GPIO_PIN_INTR_LOLEVEL, GPIO_PIN_INTR_HILEVEL.That means for gpio,only level interrupt can wake up the chip.Since the cpu will shut down , so the chip would not response to the uart or spi data, we can wake it up via gpio first.
Sometimes the current ranges because the chip has to response to the AP's management packets to obey the protocol.
We tested the working current of light-sleep under dtim3,the average current should be 1.5mA(the max sample points is 512,so the current is (1.682*512+0.5*88)/600=1.5mA):
2.deep-sleep: We add some wake-up-mode options for deep-sleep.
Application and Usage:
In some power-sensitive situation, like battery powered system, we can still reduce the power consumption during the wake-up procedure. For example , for a sensor device , we don't need to connect to ap and send data every time. We can just read the sensor data and save to the rtc memory and upload them once we get a dozen of data.So that we don't need the rf module enabled( only power on the cpu part) until we want to upload data.
APIs:
bool system_deep_sleep_set_option(uint8 option): Call this API before deep-sleep to set the following wake-up mode.
option==0: disable rf calibration for a certain number of times , according to the 108th byte of esp_init_data_default.bin.
For example , if the 108th byte is set to 8, the chip will only do these rf operation once out of every 8 wake-up procedures.
The power consumption is 44.77mA * 280ms(Note that X-axis is scaled)
option==1: do rf calibration during wake-up.Power consumption is larger.
70mA * 440ms(Note that X-axis is scaled)
option==2: not do rf calibration during wake-up.
option==4: disable rf when the chip wake up. This provides a better current performance.
The power consumption is 23mA * 250ms(Note that X-axis is scaled):
Moreover,we can still find some ways to reduce the wake-up current by the following steps.
Step1:
Add this function before getting into deep-sleep to set the next wake-up mode.
deep_sleep_set_option(uint8 option)
option == 4; disable rf during next wake-up
option == 1; normal mode
The sample code:
Code: Select all
//Sample code with RTC memory:
//===============================================
#define DATA_NUM 5
#define RTC_CNT_ADDR 120
#define DSLEEP_TIME 5000000
void user_init(void)
{
os_printf("SDK version:%s\n", system_get_sdk_version());
uint32 rtc_cnt;
system_rtc_mem_read(RTC_CNT_ADDR, &rtc_cnt, 4);
os_printf(" rtc_cnt : %d \n\r",rtc_cnt);
if(rtc_cnt>=DATA_NUM){
rtc_cnt = 0;
system_rtc_mem_write(RTC_CNT_ADDR,&rtc_cnt, 4);
deep_sleep_set_option(1); // normal mode for next wake-up to upload data
//read sensor data and record in rtc memory
system_deep_sleep(DSLEEP_TIME);
}else if(rtc_cnt==0){
rtc_cnt+=1;
system_rtc_mem_write(RTC_CNT_ADDR,&rtc_cnt, 4);
deep_sleep_set_option(4);
//normal mode, add upload-data function and deepsleep
}else{
rtc_cnt+=1;
system_rtc_mem_write(RTC_CNT_ADDR,&rtc_cnt, 4);
deep_sleep_set_option(4); //disable rf for the next wake-up
//read sensor data and record in rtc memory
system_deep_sleep(DSLEEP_TIME);
}
}
//===============================================
Step2:
Replace the "Makefile" in the sdk root path(esp_iot_sdk_v0.9.5/Makefile ) with the attached Makefile.
Add the "add_disable_rf_cmd.py" to esp_iot_sdk_v0.9.5/tools
Step3:
Compile...gen_misc.sh
The script would generate a binary file named eagle.flash_disable_rf.bin or user1.xxx.old_disable_rf.bin(for upgrade version).
The final power consumption is 14.7mA * 250ms(Note that X-axis is scaled):
We will release a sample sensor application later.