1

Is there a way to put an ESP8266 into a sort of "sleep" mode where it draws less power than usual, and then wakes up on a pin going high? I've tried doing this with delay, which still draws 20 mA, and with the deepsleep function that comes with the esp library, which can't sleep for short periods of time to watch for the pin going high. I'm building a watch, and power draw is of great concern to me. Is there possibly a way I could build or code this differently to make it more power efficient? Basically it works like this, but the full code (at it's current state) can be found here.

void loop() {
    delay(1);
    // check for power signal stuff
    if(digitalRead(0)) {
        // execute data fetching 'n stuff
    }
}
6
  • With this many code level attempts you have, it would be nice to see, what is your current efforts on code sample level. In short: show yer codez.
    – mico
    Commented Mar 4, 2017 at 7:21
  • Just connect the RST pin to the button, to "wake" up the ESP8266. You need to connect the other side of the button to Vcc.
    – Gerben
    Commented Mar 4, 2017 at 12:31
  • In that case @Gerben how much power does it take to call WiFi.begin('stuff')
    – Carrot M
    Commented Mar 4, 2017 at 21:41
  • Added a link to a gist @mico
    – Carrot M
    Commented Mar 4, 2017 at 21:42
  • 1
    GPIO16 is the only hardware interrupt pin available in deep sleep, and your MCU will reboot when it's triggered.
    – dandavis
    Commented Mar 5, 2017 at 3:19

2 Answers 2

2

Without seeing the code and optimizing it I can tell you the following:

ESP8266 has three ways to save power:

  1. Modem sleep - only wlan modem shutdown, connection kept open
  2. Light sleep - less cpu usage, fast recovery
  3. Deep sleep - suspend all, close wifi too, slow recovery

http://bbs.espressif.com/viewtopic.php?t=133

0

ESP8266 does have deep sleep mode. The link to http://bbs.espressif.com/viewtopic.php?t=133 posted earlier sums it up pretty well, despite being old.

However, a few things that are different from Arduino or should be considered if you're building a battery-operated device:

  • when the MCU wakes up from deep sleep, the entire application is restarted. Yes, beginning from the setup() function - just as if it was reset. You cannot put it to the deep sleep and then resume from the same place keeping all variables etc. You can only detect that the device was woken up from the sleep by reading a flag in the setup() function.

  • check your board. If you're not using bare ESP8266, but some development board such as NodeMCU or WittyCloud, it usually has number of other circuits powered on even when the MCU is sleeping. Particularly, USB-UART bridge and maybe power LED.

  • check your power source. Again, if you're using a development board, very likely it has an inefficient LDO voltage regulator. Even when MCU is powered down, the LDO can still use a few mA just to power itself (quiescent current). There are special low quiescent current regulators exist, very useful for battery-operated application.

  • finally, I see your code refers some OLED display. Just to be sure - is it powered down or excluded from the measurement? OLED doesn't need a lot of energy, but will drain a battery in a few days.

Personally, I do have experience creating a battery-operated device on ESP8266, which wakes up every few minutes, connects to wifi and sends some data. An old 700mAh Lithium battery is enough to run it for approximately a month. And I managed to get the sleep power to about 40 microAmps. Still a few times more than the chip itself needs, but good enough for me.

2
  • Only a month? I roughly estimate for your case 250 mAs per wake-up, plus the 40 uA standby. To use 250 mAs per wake-up I guess you are using DHCP? static IP reduce the connection time to about 250 ms (multiplied by 200 mA is 50 mAs) and should extend the battery a lot (or... your battery is way lower than 600 mA I assumed).
    – FarO
    Commented Aug 31, 2017 at 14:26
  • 1
    I use static IP, so it's not a problem. But there is also a sensor that needs to be initialized and used. Also establishing the network connecting and sending data takes some time. So the awake time for each wake up is 2-3 seconds (every 5 minutes). It probably doesn't use full 250mA all that time, but twice less on average, which, over 5 minutes, gives average consumption of 0.9mA. Or 650mAh in 30 days. Seems pretty accurate.
    – astax
    Commented Sep 1, 2017 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.