Minimizing ESP8266 Battery Drain

[Alex Jensen] wanted to build a battery-powered weather station, using an ESP8266 breakout board to connect to WiFi. However, [Alex]’s research revealed that the ESP chip uses around 70mA per hour when the radio is on — meaning that he’d have to change batteries a lot more than he wanted to. He really wanted a low power rig such that he’d only have to change batteries every 2 years on a pair of AAs.

The two considerations would be, how often does the ESP get powered up for data transmissions — and how often the weather station’s ATtiny85 takes sensor readings. Waking up the ESP from sleep mode takes about 16mA — plus, once awake it takes about 3 seconds to reconnect, precious time at 70mA. However, by using a static IP address he was able to pare that down to half a second, with one more second to do the actual data transmission. In addition to the hourly WiFi connection, the Tiny85 must be powered, though its relatively modest 1.5mA per hour doesn’t amount to much, even with the chip awake for 36 hours during the year. All told, the various components came to around 500 mAh per year, so using a pair of AA batteries should keep the rig going for years.

We’re intrigued by stories of hackers eking out every last drop of power to make their projects work. We’ve posted about ESPs low-power mode before, and what can be more low-power than a watch running off a coin cell?

49 thoughts on “Minimizing ESP8266 Battery Drain

    1. In my case I used and ATTiny85 because the only way to wake the ESP from deep sleep (most power savings) was to use a watchdog timer, or reset the ESP (I also needed PINs to remain HIGH when the MCU was sleeping, the ESP sets all PINs to LOW when it’s asleep). Because I was monitoring the state of doors, and needed to know as soon as they opened, a watchdog would not work. So, I used the ATTIny to monitor the doors and reset the ESP (so it would send an email) when necessary. All told, my setup, ESP, ATTIny, and charge controller only draws 0.4mA when everything is sleeping (the ATTIny sleeps most of the time as well)

      1. The esp can do that itself. Just have the door on a switch that powers up the esp. The esp then latches the power on (with a relay for example) until the transmission is complete. At that point, it releases the relay, powering off. I use this method for a ”zero power when idle” mailbox for monitor.

        1. @macemoneta – Mine is being used on a mailbox as well, but I have two doors (delivery/retrieve), and I need to detect which door opened to act accordingly. More critical, I need to keep LEDs on when the MCU is sleeping, the ESP sets the PINs to LOW when sleeping, whereas the ATTiny keeps them in the state they were set before sleeping.

          I thought about using some combination of relays but given that a ATtiny85 is a buck (or less), I felt it was the economical (both in terms of monetary and complexity cost) route. I use a solar panel to charge the battery so I want the draw to be as low as possible, I don’t need it to be zero.

    1. The original article is correct. It’s Hackaday who got the units wrong. Just drop the “per hour” and change “Waking up the ESP from sleep mode takes about 16mA” to “Running with the radio disabled takes about 16mA”.

    2. It’s an acelleration, 70mA per hour is 0.070 coulomb / sec / hour. It just has really weird units and is complete jibberish. But if the author reads these comments they are likely to learn something and not make the same mistake again.

      1. You’d hope they learn, but sadly, it indicates a heck of a lot of missing understanding, not just this example. If you purport to teach, it’s best if you know stuff yourself. Rate times time = amount, and that’s very basic to more than just electricity. Perhaps they’d be interested in my quick course on how that applies to finance?

  1. Um, you *can* enable/disable RF completely on-the-fly on the ESP8266, just set the correct bits when issuing deep-sleep — no need for an ATTiny at all. I mean, like, disable RF, and every 5 minutes wake up, take your readings, go back to sleep, and on the 12th wake-up turn RF back on, do your WiFi-stuff, and rinse and repeat.

  2. Great stuff Alex!

    I’ve been doing the same with the ESP32 (deep sleep 300 secs, wake, read sensors, WiFi + https to ThingSpeak, repeat).

    I’ve tested an ESP32 at under 7uA(!) in deep sleep, with just the wakeup timer running – that is about 30 years asleep on three AAs. It also has a ‘ULP’, which is a simple third core for low power operations (e.g. checking I2C sensors).

    A lot depends on the dev board you use (if any) – the inexpensive 3.3V LDO regulators used on some boards can waste a lot of current. One dev board I’ve got uses 0.8mA when in deeps sleep, so plan on replacing the LDO with a footprint compatible part if low poor is important.

    1. On battery powered stuff you just don’t use a regulator. Ever.

      I have bunch of Arduino-based sensors running at my house (with 433Mhz radio) and they run few years with two AAA batteries, sending every 15 minutes.

        1. Given the cost and still fairly high self discharge of the allegedly “low self discharge NiMH”, it’s better to use a good, branded Li-ion cell…also, you get higher voltage then 2 nikel-based AAs in a similarly sized but lighter package.

      1. > …with two AAA batteries
        Of how many cells are the two batteries made? (battery = array of same things)
        And of which chemistry? (primary dry cells? rechargeable accumulators?)

  3. My approach was a bit different – I use the deep sleep for ESP (just uA of consumption over that time period), wake it every 6 minutes and report. And re-charge from a tiny solar panel. Works for 1/2 year in very shady conditions so far ;)

  4. It is not a problem at all that a HaD article shows an external solution for power management of a uC-dev-board (ESP) by means of another uC (tiny84): this is simply a modular approach as opposed to an all integrated (ESP-only) solution. Both are viable.
    The important part is that the commenters are friendly and do provide pointers to other solutions!

  5. When going for several years of battery life a big part of your batterie’s capacity is normally eaten up by self-discharge. In addition, normal AA batteries don’t like cold temperatures. Lithium AA batteries like this one (http://data.energizer.com/pdfs/l91.pdf) may be a perfect fit here as they have a very low self-discharge and work well between -40 and +60 degC.

    1. Makes you wonder, at what point does it become better to use a good slice of foam insulation and periodically dump some power into a resistor to keep the cold at bay? You only need to keep the batteries warm, so no need to have the entire project in insulation.

  6. The Attiny can do better too, btw. there are sleep modes that consume in the nA range, but I have to admit, I haven’t tried that with time critical stuff, where the timer need to be running. Might talking out of my behind here, but hey, it’s the comment section ;) there are still some neat tricks to learn.

  7. I just can’t read this article. In every place, it’s unclear if you talk about instantaneous power consumption [mA] or used energy [mAh]. Even then Watts and Joules would be better. I can live with Amperes because the voltage of ~3.3V is clear from the context.

    You can (ab)-use the google calculator if you want to check your units. If the resulting unit is wrong (f.e. inches :P ) you can use the keyword “to” to convert the result into another unit.
    Exampe: Type in
    3.3V * 15(10^-6)A * 5min
    the result is 0.01485 joules. But joules are so ah uh difficult. Change the entry to
    3.3V * 15(10^-6)A * 5min to Wh
    and the result becomes
    4.12500 × 10-6 watt hours
    which is quite readable

    1. Hey, at least both posts weren’t written by the same guy…

      But I do wonder about avoiding duplicate posts. Like, is there a system in place for making sure a project is only covered once, or do he writers literally have to search the site with the same interface we have before writing?

      1. We have all sorts of safety interlocks, but they’re all fallible. Tipsters will tip us multiple times, links will change, etc. You’d be surprised at all the failure modes.

        In the end, it falls on the humans turning the cranks in the vast Hackaday machine. Writers should check for dupes before writing. Editors should read everything (and have perfect recall as well).

        We don’t like dupes either. We catch maybe 4x as many behind the scenes that don’t make it out. Still, maybe ten’ish per year slip through, out of roughly 3,650 posts.

        So we’re not doing too bad, but we can always do better. Y’all definitely keep us on our toes — if you’ve ever wondered if Linus was right about many eyes making all bugs shallow…

      1. You are incorrect. 70 mA per hour will keep you going only for an hour if you have 70 mA stored. If you want to keep going for a day, you’ll need 24*70 mA. Trust me, I’m a professional electrologist.

Leave a Reply to electrobobCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.