学习NodeMCU的低功耗休眠
来源:互联网 发布:nginx动静分离原理 编辑:程序博客网 时间:2024/05/22 10:49
大多数IOT应用是电池供电的,在电池电量一定的情况下(体积、环境等限制),耗电量决定了产品的寿命,决定了产品是否实用。本文主要目的是学习关于NodeMCU的休眠机制。
NodeMCU的API
https://github.com/nodemcu/nodemcu-firmware/wiki/nodemcu_api_en#nodedsleep
node.dsleep()
Description
Enter deep sleep mode, wake up when timed out.
Syntax
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.
Parameters
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.
Returns
nil
Example
--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)
NodeMCU源代码
https://github.com/nodemcu/nodemcu-firmware/blob/fa7cf87832fc9905df98f9435c149d40f314dee8/app/modules/node.c
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;
}
https://github.com/nodemcu/nodemcu-firmware/blob/84a9ab35a8eb9b4ae2229bba7b2626c2a285818d/include/user_interface.h
bool system_deep_sleep_set_option(uint8option);
void system_deep_sleep(uint32time_in_us);
ESP8266 Specifications
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.
- 学习NodeMCU的低功耗休眠
- 低功耗蓝牙学习
- BMI160低功耗学习
- 如何让End Device进入低功耗状态,休眠时间是如何设定的?
- 低功耗的设置
- 低功耗蓝牙BLE学习篇:低功耗蓝牙以及GATT的概念
- 低功耗蓝牙(学习笔记)
- 低功耗蓝牙学习0524
- Zigbee低功耗—终端节点休眠实现
- 学习NodeMCU的GPIO
- 影响低功耗模式功耗的因素
- 低功耗板子测试功耗的方法
- MSP430的低功耗探讨
- 低功耗蓝牙的基础
- zstack低功耗的设置
- 低功耗的风格和
- CM3 STM32F的低功耗
- STM32L152的低功耗测试
- Google Protocol Buffer 的使用和原理
- wifidog client_list.c&.h分析
- redis eval命令
- XSS遇到后台登录限制或者HTTPONLY时
- Eclipse Java EE IDE for Web Developers 配置Tomcat
- 学习NodeMCU的低功耗休眠
- UIApplicationDelegate协议解读
- 二叉树线索化
- linux运维职业路线
- Oracle ORA-01033: ORACLE initialization or shutdown in progress 错误解决办法
- Binary Tree Maximum Path Sum
- 后海日记(1)
- ArcGIS教程:3D表面的基础知识(二)
- Android中Service类onStartCommand