The current season is known for the fact that it is a little bit colder outside and it gets colder inside the house or apartment.
Every year it is a challenge to find the right setting for the heating so that it is not too warm or too cold. It is even more difficult if there is no thermometer available 🙈.
Instead of buying a thermometer - or a weather station like Netatmo as a Christmas present 😛, I thought I would build a small weather station myself. This should not only measure the temperature, but also the air pressure, humidity and air quality.
Later I might add an outdoor component.
Here I would like to document my steps towards this, perhaps someone would like to realize a project of this kind.
I call this project Atmo. It’s based on a small Arduino-based weather station equipped with sensors.
The sensors are read out periodically and the data is transmitted centrally and stored in a database. These can then be visualised.
The MQTT protocol is used for the transmission. MQTT is optimal for this application, as only a small amount of data is transmitted efficiently. I use the MQTT-Broker “Mosquitto”.
To get the data from the MQTT-Broker into the database there is the Atmo-Bridge. This is a small Python script which waits for incoming messages from the weather station (subscribed) and stores the data in the InfluxDB.
The InfluxDB is an OpenSource Timeseries database, which can store the data points optimally. Additionally Grafana can be used with the InfluxDB to visualize the sensor data.
I decided to use the Adafruit ESP32 Huzzah Feather as a basis, because this board has already integrated an ESP Wifi. Additionally it has Bluetooth for later use.
The sensors are then connected via the SPI or I2C interfaces.
- Integrated 802.11b/g/n HT40 Wi-Fi transceiver, baseband, stack and LWIP
- Integrated dual mode Bluetooth (classic and BLE)
- 3 x SPI
- 2 x I2C
A connection for a LiPo battery is also provided if the station is to be supplied by a battery. However, there is still potential for optimization here, so that as little power as possible is consumed.
Finding suitable sensors was not easy. The common temperature and humidity sensors e.g. DHT22 or DHT11 are not very accurate.
While searching for an air quality (TVOC) or CO2 sensor I found the BME680 from Bosch.
This chip has a temperature, air pressure, humidity and air quality sensor. Compared to the other VOC sensors, it does not calculate C02 or VOC values. Instead, it uses the measured values of the gas sensor to calculate the IAQ (Indoor Air Quality). It indicates how much of the air contains impurities (e.g. organic, gases or chemicals).
I would like to have the pure C02 value, but I have not found any other chip that can measure so many values at once. Compared to other chips, the BME680 is one of the best, and therefore probably more expensive than the others. The price of the BME680 is reasonable despite the many features inside. In most cases it beats any sensor combination in price. Unfortunately the chip is not open source and Bosch is not very open about the algorithms to evaluate the sensor. Therefore it will certainly not be easy to determine the correct and calibrated values.
The accuracy of the sensors can be taken from the Bosch data sheet.
- Humidity (%) ±3
- Pressure (kPa) ±0.12
- Temperature (°C) ±1.0
For my project I use the BME680 on the breakoutboard from Adafruit.
Additionally I use the sensor TSL2591 for the light intensity (Lux) to determine the daylight. Not that important, but I wanted to use an additional sensor.
Compared to low-cost CdS cells, this sensor is more precise, allows exact lux calculations and can be configured for different gain/timing ranges to detect light ranges from 188 uLux up to 88,000 lux.
Build & Wire
The pinouts from the Feather Board are well documented on Adafruit:
The BME680 is connected via SPI and therefore soldered to the corresponding pins:
- 3v and Gnd to 3v and Gnd on the feather board.
- SCK on the BME680 to SCK on the feather board (pin 5)
- CS on pin 16 on the Feather Board. (CS1 Pin, can also be used with CS2)
- SDO to MI(SO) (pin 19)
- SDI to MO(SI) (pin 18)
The TSL2591 can only do I2C and is soldered to the appropriate pins:
- Vin and GND, to 3v and Gnd on the feather board.
- SCL - I2C clock pin - to SCL on the feather board (pin 22)
- SDA - I2C data pin - to SDA on the FEather Board (Pin 23)
I am quite satisfied with the result. I am fascinated how compact the whole thing is. I used slightly longer cables, especially the BME680 chip is not too close to the feather board, so that the waste heat of the board does not affect the temperature measurement. I’m still addressing this issue during programming, because the values still need to be calibrated.
Top, now the base station is ready for the next step - getting this thing running :)