ESP8266 on batteries for years – part 2

Build materials

ESP8266 12E Modules: 2$ at aliexpress

TSL2561 Breakout board: 1$ at aliexpress

SI7021 Breakout board: 2$ at aliexpress

AtTiny85 DIP mcu: 1.3$ at aliexpress

Here you can find the main components for my device. I only link to the search and show the picture of my device, because products/companies comes and goes. If you don’t want the hazzle of soldering the ESP directly you can buy it with a breakout board like this.



Here are the schematics of the weather sensor:

Fritzing diagram can be downloaded from: github here.

The ESP and ATtiny are connected on the same I2C bus as the light sensor and the temperature/humidity sensor. I didn’t add pull-up resistors because they are already present on the breakout boards of the sensors.

The two sensors are powered by output pin PB4 on the AtTiny. This gives an extra possibility to save some power when the AtTiny is sleeping.

All measurements are buffered up in the AtTiny and when it wants it can wake up the ESP by pulling PB1 low for some milliseconds.

There are two programming connectors:

  • One for the ESP. To start programming: 1) Remove “PGM protect” jumper. 2) Pull PGM low. Power up. And program with a RS232 converter connected to TX/RX. Stop pulling PGM low.
  • One for the AtTiny. To start programming: connect SPI pins ( Reset, Mosi, Miso, SCK and GND) to the programmer. I am using a TinyUsbIsp.

The “PGM protect” jumper should always be on in normal operation. Only during programming of the ESP it should be removed, so that the AtTiny doesn’t disturb the programming.


Lifecycle of the device

  1. The AtTiny deep sleeps and wakes up every second to see if it should do a measurement. If not, it goes immediately back to sleep to save power.
  2. After 2 minutes of deep sleep it powers up the sensors.
  3. It does a reading of all the sensors (By acting as an I2C master on the bus) and stores the measurements in RAM.
  4. The AtTiny goes back to sleep
  5. After 1 hour (and 30 measurements) it wakes up the ESP and switches itself into I2C slave mode. It now waits for the ESP.
  6. The ESP fetches all measurements from the AtTiny and some statistics
  7. The ESP connects to WiFi and sends the raw data to the Python Server.
  8. It then tells the AtTiny it has finished and that it can safely delete the data.
  9. ESP goes to deep sleep.
  10. AtTiny restarts its cycle.

13 thoughts to “ESP8266 on batteries for years – part 2”

  1. Check out the SI7021 datasheet. Every time you power it up it burns a lot of power to calibrate it. Power it continuously as it will sleep automatically after the I2C commands and it burs quite little power.

    1. I can see it takes about 4ma for a total amount of 10ms. This is very little out of the 17.4 mAh per year that the attiny+sensors use. But yes – there might be space for a tiny optimization.

  2. This is some great information you are sharing. Thank you.

    I have a quick question about your schematic. As I was checking it out I noticed that on the ATTiny, pin 3 goes to power, pin 8 is going to CH_PD. I am assuming this is just a simple error, but wanted to make sure what your intention was there.

    1. Pin 8 of the attiny is going to vcc to give it power
      ch_pd on the esp is pulled high throught a 10k resistor to enable it.
      pin3 (PB4) on the attiny is used to power the two sensors. quite intentionally 🙂

  3. Why ESP not self-waked every 2 mins for reading sensors directly without powering up wifi part? Single chip solution may be better and easier ?

  4. Hi, thanks very much for these web pages they’re very interesting and helpful!

    Why do you connect the TSL2561 and SI7021 to both the attiny and the esp8266? Was that used for testing purposes?


    1. The at tiny works as a master and fetches data from the TSL2561 and SI7021 most of the time. When the ESP wakes up it fetches data from the attiny via the same i2c bus…. So all devices needs to be on the same bus.

  5. Hi Alex, very usefull post, thanks
    I was wondering if it is possible to add a tipping bucket rain sensor and wind speed sensor. Both generate pulses when measuring. Maybe add interrupts to attiny to wake up while sleeping, count and go back to sleep
    What do you think?

Leave a Reply

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