大多数IOT应用是电池供电的,在电池电量一定的情况下(体积、环境等限制),耗电量决定了产品的寿命,决定了产品是否实用。本文主要目的是学习关于NodeMCU的休眠机制。
https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en#nodedsleep
Enter deep sleep mode, wake up when timed out.
node.dsleep(us, option)
Note: This function can only be used in thecondition that esp8266 PIN32(RST) and PIN8(XPD_DCDC aka GPIO16) areconnected together. Using sleep(0) will set no wake up timer, connecta GPIO to pin RST, the chip will wake up by a falling-edge
on pinRST.
option=0, init data byte 108 is valuable;
option>0,init data byte 108 is valueless.
More details as follows:
0,RF_CAL or not after deep-sleep wake up, depends on init data byte108.
1, RF_CAL after deep-sleep wake up, there will belargecurrent.
2, no RF_CAL after deep-sleep wake up, there will only besmall current.
4, disable RF after deep-sleep wake up, just likemodem sleep, there will be the smallest current.
us
: number(Integer) or nil,sleep time in micro second. If us = 0, it will sleep forever. If us= nil, will not set sleep time.
option
: number(Integer) or nil.If option = nil, it will use last alive setting as default option.
nil
--do nothing node.dsleep() --sleep μs node.dsleep(1000000) --set sleep option, then sleep μs node.dsleep(1000000, 4) --set sleep option only node.dsleep(nil,4)
static int node_deepsleep( lua_State* L)
{
s32 us, option;
//us = luaL_checkinteger( L, 1 );
// Set deleep option, skip if nil
if ( lua_isnumber(L, 2) )
{
option = lua_tointeger(L, 2);
if ( option < 0 || option >4)
return luaL_error( L, "wrongarg range" );
else
deep_sleep_set_option( option);
}
// Set deleep time, skip if nil
if ( lua_isnumber(L, 1) )
{
us = lua_tointeger(L, 1);
// if ( us <= 0 )
if ( us < 0 )
return luaL_error( L, "wrongarg range" );
else
system_deep_sleep( us );
}
return 0;
}
bool system_deep_sleep_set_option(uint8option);
void system_deep_sleep(uint32time_in_us);
http://www.seeedstudio.com/document/pdf/ESP8266%20Specifications%28Chinese%29.pdf
10电源管理
芯片可以调成以下状态:
关闭(OFF):CHIP_PD 管脚处于低功率状态。RTC失效。所有寄存器被清空。
深度 睡眠 ( DEEP_SLEEP ) : RTC开着,芯片的其他部分都是关着的。RTC内部recovery memory 可保存基本的WiFi 连接信息。
睡眠(SLEEP):只有RTC 在运行。晶体振荡器停止。任何部位唤醒(MAC、主机、RTC计时器、外部中Sleep断)将使唤醒整个芯片。
唤醒(WAKEUP):在这种状态下,系统从睡眠状态下转为起动(PWR)状态。晶体振荡器和PLL 均转为使能状态。
开启状态(ON):高速时钟可以运行,并发送至各个被时钟控制寄存器使能的模块。各个模块,包括CPU 在内,执行较低电平的时钟门控。系统运作时,可以通过WAITI 指令关闭CPU 内部时钟。
The following data are based on a 3.3V power supply, ambienttemperature 25C and use the internal regulator measured. [1] Allmeasurements are made in the absence of the SAW filter, the antennainterface is completed. [2] all transmit data based on 90% dutycycle, continuous transmission mode in the measured.
Mode |
Min |
Typical |
Max |
Units |
---|---|---|---|---|
802.11b, CCK 1Mbps, POUT=+19.5dBm |
215 |
mA |
||
802.11b, CCK 11Mbps, POUT=+18.5dBm |
197 |
mA |
||
802.11g, OFDM 54Mbps, POUT=+16dBm |
145 |
mA |
||
802.11n, MCS7, POUT =+14dBm |
135 |
mA |
||
802.11b, packet size of 1024 bytes, -80dBm |
60 |
mA |
||
802.11b, packet size of 1024 bytes, -70dBm |
60 |
mA |
||
802.11b, packet size of 1024 bytes, -65dBm |
62 |
mA |
||
Standby |
0.9 |
uA |
||
Deep sleep |
10 |
mA |
||
Saving mode DTIM 1 |
1.2 |
mA |
||
Saving mode DTIM 3 |
0.86 |
mA |
||
Shutdown |
0.5 |
uA |
https://nurdspace.nl/ESP8266#Technical_Overview
Low Power ESP8266 – Sleeping at 78 micro Amps
http://blog.csdn.net/coolwaterld/article/details/45365749
ESP8266 in deep sleep
http://blog.csdn.net/coolwaterld/article/details/45365841
Building a battery powered WiFi IoT Sensor with ESP8266, MS-5611(GY-63), nodemcu and MQTT
http://blog.csdn.net/coolwaterld/article/details/45366003
Designing An Ultra Low Power Sensor Solution With ESP8266
https://github.com/EspressifSystems/low_power_voltage_measurement/wiki
https://github.com/EspressifSystems/low_power_voltage_measurement
This is a project for ESP8266 for low power sensor applications.The chip powers on once every 1 minute to measure it‘s own powersupply, and sends the data to the server, once every 20 minutes. Ofcourse, you can configure the chip to do other things such asmeasuring temperature or humidity, etc. The project is now based onEspressif‘s SDK version 1.0.1b. More details about the project can befound in the Wiki.
原文地址:http://blog.csdn.net/coolwaterld/article/details/45366701