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
- 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.
- After 2 minutes of deep sleep it powers up the sensors.
- It does a reading of all the sensors (By acting as an I2C master on the bus) and stores the measurements in RAM.
- The AtTiny goes back to sleep
- After 1 hour (and 30 measurements) it wakes up the ESP and switches itself into I2C slave mode. It now waits for the ESP.
- The ESP fetches all measurements from the AtTiny and some statistics
- The ESP connects to WiFi and sends the raw data to the Python Server.
- It then tells the AtTiny it has finished and that it can safely delete the data.
- ESP goes to deep sleep.
- AtTiny restarts its cycle.