ESP8266 on batteries for years – part 1

The ultra low power weather station

For some time I have been fascinated by the possibilities of the ESP8266, but I never really considered it good for a life on batteries. I got an idea of making an outdoor weather station that would send measured light level, temperature and humidity to my home automation server.

The ESP is a hungry beast when it’s doing WiFi. According to different sources on the internet it uses about 70 mA on average when WiFi is on! This would mean that I have to change batteries on my sensor quite some times every year.

I instead came up with the idea of a design using an AtTiny85 for doing frequent measurements and then once in a while to wake up the ESP beast to transmit it’s recorded data to the server.


Wanted specs
  • A solution where I only have to change batteries every 2 years
  • Device doing 1 measurement every 2 minutes of:
    • Temperature in degrees C
    • Humidity in %
    • Light level in Lux
  • Every 1 hour data is transmitted via WiFi  to a Python Server. If the server is unreachable, the measurements would be buffered up.
  • The server would store data in an Influx-db database.
  • User interface would be Grafana graphing on top.


First prototype

All software has been developed on my small test board:

The programming was done with a USBTinyIsp-clone for the AtTiny85 and a 3.3v generic rs232 converter. Both are shown in the picture.


Design decisions

My first thoughts was to only use an ESP in deep sleep mode most of the time. By waking it up with the radio disabled it takes about 16mA. The downside was that when you then needed the radio it needed to do a full re-calibration making it take 3 seconds just to connect. That is a long time and a lot of battery usage!

I spend some time experimenting getting the awake time down. By using static IP I can get the time down to 0.5 seconds. But about 10% of the times it takes 1.5 seconds. I haven’t been able to track down what causes this. Maybe WiFi collisions, because it seems less at night?

I settled on the AtTiny85 for doing most of the work. I let it turn on/off the sensers, getting measurements via I2C from sensors, wake up the ESP and act as an I2C slave for the ESP to fetch the data.



Before I started I did some calculations from the specs:

The spreadsheet can be downloaded here if your want to play with the numbers.

Two alkaline AA batteries should hold about 2000 mAh, which would be sufficient to run my sensor device 4 years according to my (best scenario) calculations. In real life probably only half. That will be shown when I have the final power measurements in the end of this series.



Here is a final example of the last days outdoor measurements presented in grafana:


In this series

I will go through the entire design process. All the way from the electronics to the source code of the AtTiny85 to the code for the ESP8266 and the python code for the server end.

  • Part 2: Electronics and schematics
  • Part 3: Source code for the two microcontrollers
  • Part 4: Source code for the python server
  • part 5: Real measurements of current consumptions.


32 thoughts to “ESP8266 on batteries for years – part 1”

  1. Hi Alex,

    Thank you for sharing your experience and knowledge here. Light measurement is ana uncommon (at least to me) and nice feature !
    I’m quite afraid this is a noobish/stupid question, but could you further explain what the ESP ” full re-calibration” is ?
    Does it occur only when you wake it up and deepsleep it back without WIFI activated ?

    1. If the ESP has been powered up with the radio off, then it needs to do a calibration (3 seconds) when the radio is switched back on. At least thats what my measurements showed.

      1. Hi Alex,

        You can wake-up the ESP8266 with the NO_CAL option to prevent it going through the radio re-calibration process.

  2. This looks quite interesting. Are you looking for collaborators? I recently purchased a small abandoned farm and want to instrument the greenhouses as I rebuild them.

    1. It would always be interesting to hear if it can be used in real life 🙂 Please keep me updated if you go ahead building these 🙂

    1. I am pretty sure that you could get a lower consumption with a LoRa module together with the AtTiny (and skipping the ESP8266). I avoided that solution because then I needed a “gateway receiver” to pass on the data to my server.

      1. Can I continue to torture you with my questions? I would like to read a pressure sensor for weighing a bee’s prey.

          1. If that’s the case my sketch could easily be changed to maybe take a measurement every hour and then send the results daily. In that way you can run for many years on batteries. I guess the weight of bees doesn’t change so fast. You could even eliminate the attiny if you need very infrequent measurements.

  3. Hi,
    If you control the ESP pin CHIP_EN, then the current consumption in sleep mode will be reduced, at least twice as compared to deep sleep.

    1. Hi Nikolz,

      I tried that and it uses very little current. The problem is that the next time it boots, it takes 3 seconds connection to my wifi instead of 0.5-1 second… All the saved energy is now lost in wifi connection.

  4. 2 vs 3 batteries:

    It’s the fact, that you can only get 40% of energy from 2*AA batteries. ESP works until 2.5V, so 1.25V is minimum. Here is graphic of discharge of popular batteries:

    Using 3*AA with MCP1700 2.8V regulator power be able to power your scheme until 1.15V. It means 60% of energy of 3*AA. Regulator current about 2uA (!). It’s about 4-5 times better!

  5. Thank you for these tutorials!

    Have you investigated using the other power modes of the ESP8266? You could turn on Wifi only when you need it, else just power it down. Without wifi it should be about 15 mA drain. Still more than the ATTiny, but it could simplify your circuit if you weren’t dependent on two MCUs?

    Static IP was a good tip, thanks!

    1. There are many ways to simplify my circuit, but most of them would sacrifice my first goal of not changing batteries every month 🙂

  6. hi
    i have one doubt regarding communication between attiny85 and esp8266.
    1.why not used software serial instead of i2c?

  7. Hej Alex
    Tak god artikel.
    Jeg vil gerne skrive til dig privat ?
    Jeg udvikler også mange ting bl.a med ESP8266.
    Har en dejlig lab men mangler social kontakt med ligesindede.
    Mvh Knud OZ7YV

  8. I’ve used an ESP8266 with the ESP-now protocol for fast transmit without needing the WPA/DHCP stuff. It takes about 200 ms after Arduino wakeup to send a message and go back to sleep. ESP-now is a bit similar to NRF24L01 in the sense that you can send a small amount of data (about 255 bytes IIRC). You will know if the other end actually received the data through an ACK mechanism. Addressing is based on knowing the MAC address and wifi channel of the receiver.

    You do also need an ESP-now receiver. This can be an ESP32 board, for example, receiving the ESP-now messages and bridging them to MQTT.

    We use this in the hackerspace as a low-power low-latency “music skip” button. See

Leave a Reply

Your email address will not be published. Required fields are marked *