Low Power ESP8266 – Sleeping at 78 micro Amps

http://tim.jagenberg.info/2015/01/18/low-power-esp8266/

I recently bumped into NodeMCU firmware for the ESP8266. It’s an Lua interpreter, making tinkering with IoT ideas really simple. Just flash the firmware onto the ESP8266 and connect via serial console. You can start prototyping right away using the interactive Lua interpreter. You can easily persist your ideas on a simple flash file system.

print(wifi.sta.getip())
--nil
wifi.setmode(wifi.STATION)
wifi.sta.config("SSID","password")
print(wifi.sta.getip())
--192.168.13.101

For convenient development, there is ESPlorer, a basic IDE for Lua on the NodeMCU. It allows you to develop the Lua scripts locally and then save them to the MCU via serial protocol.
ESPlorer

To make developing with the ESP-01 module easier, I created a basic development board. It provides easier access to the individual pins, has jumpers for flashing mode (GPIO00) and enable (CH_PD), offers a button for reset, and also integrates a socket for astep-down power supply.
ESP8266 (ESP-01) dev board top-viewESP8266 (ESP-01) dev board side-view
ESP8266 (ESP-01) dev board front-viewESP8266 Development Board

Although NodeMCU provides access to the deep-sleep mode of the ESP8266

node.dsleep(microSecs);

this is not available straight away on the ESP-01 module, as the ‘post-sleep-reset-pin’XPD_DCDC (8) of the MCU is not connected to the reset pin. I solved this by manually soldering a single wire of a stranded cable between the reset pin of the module and the XPD_DCDC (8) pin of the MCU (bottom right corner of the mcu in the first photo). On top of this, I also removed the red power LED by simply prying it off with a tiny screw driver.
With these two modifications, the module is able to make use of the deep-sleep mode and successfully resets and restarts after waking.

During deep sleep the module now uses just 78 microAmps! On two normal AA batteries with 2600mAh, that’s good for well over 3 years!

Update 2015-04-12:

Due to frequent questions about the Fritzing file or schematics, I uploaded the Fritzing file:
ESP-01_ESP8266_Board.fzz
(if the file extension gets mixed up, apply .fzz manually)

### ESP8266 Deep Sleep Tutorial and Configuration Deep sleep mode is an essential feature for reducing power consumption on the ESP8266 microcontroller. This allows devices to operate efficiently over extended periods with minimal energy usage. #### Enabling Deep Sleep Mode To enable deep sleep, one must configure specific parameters before invoking the `esp_deep_sleep_start()` function. The duration of sleep can be set using various wakeup sources such as GPIO pins or timer interrupts[^1]. ```c #include "esp_sleep.h" void enter_deep_sleep(uint64_t time_in_us){ // Set up any necessary wake conditions here esp_deep_sleep_enable_timer_wakeup(time_in_us); Serial.println("Going into deep sleep."); delay(10); // Allow some time for serial output to complete. esp_deep_sleep_start(); // Enter deep-sleep mode. } ``` The above code snippet demonstrates how to put the ESP8266 into a timed deep sleep state where it wakes after a specified period defined by `time_in_us`. #### Wakeup Sources Wakeup from deep sleep can occur through several mechanisms including timers, touch pads, external RTC IOs, ULP coprocessor programs, etc.. For example: - **Timer:** Automatically wakes up the device after a certain amount of elapsed real-time clock (RTC) cycles. - **GPIO Pin Change:** Configures selected GPIOs so that changes in their logic levels trigger awakening events. For configuring these options programmatically within Arduino IDE environment: ```cpp // Enable waking up via pin change interrupt on GPIO number 'pin' esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON); const gpio_num_t wakeup_pin = GPIO_NUM_0; gpio_set_direction(wakeup_pin, GPIO_MODE_INPUT); gpio_pullup_en(wakeup_pin); esp_sleep_enable_ext0_wakeup(GPIO_NUM_0, LOW); ``` This setup ensures that when the designated GPIO transitions low, the system resumes operation immediately following its last known context prior to entering deep sleep. #### Saving Data Across Cycles Since RAM contents are lost during deep sleep unless special measures like retention SRAM areas are utilized, applications requiring persistent memory should store critical data externally either in flash storage or EEPROM-like interfaces provided by libraries such as Preferences API available under PlatformIO framework. #### Important Considerations When implementing deep sleep functionality: - Ensure all peripherals not needed while sleeping have been properly powered down. - Be aware that UART communication may fail once deep sleep begins since most I/O lines go inactive. - Plan accordingly regarding what happens upon reawakening; often this involves resetting parts of your application's state machine back to initial states ready for another cycle.
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值