Hardware

Monitoring Temperature and Humidity in the House

In our house, we sometimes have problems with mold in outer corners, so four months ago we built a series of inexpensive IoT sensors for monitoring temperature and humidity.

Our devices are made from just three components:

  • WeMos D1 Mini (lite) microcontroller
  • Si7021 temperature and humidity sensor
  • 3x AA Ni-MH rechargable batteries

Because we wanted to build around 10 sensors, we had to watch out a bit for the price tag on the components.  We ended up at around 9 € per device, with 50% of the cost beeing the batteries.

We chose the Si7021 sensor because judging from this excellent review of common temperature sensors, it was better than the commonly used DHT22 and came in 2nd place behind the more expensive BME280.

For the power supply of the devices it was clear that we were going to run them on rechargable battery using deep sleep.  Andreas Spiess made an excellent video about battery technologies for the ESP8266, where he compared different types of batteries with respect to their effective capacity.  Even though a Lipo cell was rated the best battery technology for the ESP8266, we went with Ni-MH cells because they are easier to work with.

The devices were assembled such that the sensor is directly attached to the WeMos board and the entire thing is wrapped to the battery pack.

The assembly does not look very nice, but the entire device is very tiny and only few wired are needed.

When the jumper between RST and D0 is connected, the software puts the device into deep sleep after every measurement.  In this mode, it draws approximately 0.075 mA compared to 74 mA during operation.  With three Ni-MH batteries of 2000 mAh, a sleep interval of 20 minutes and about 7 seconds of active time, we estimate about four months of operation without recharging.  For our purposes this is good enough.

For recording our measurements and tracking the sensors and other IoT devices, we created a MySQL database.  Each sensor is identified by its chip ID and connects to a mosquitto MQTT broker to report new measurements.  Node-RED, running on a Raspberry Pi listens to the MQTT messages and inserts new measurements into the MySQL database.

Devices communicate via MQTT. Logic is implemented as Node-RED flows and data is stored in MySQL.

The network of devices communicating via MQTT does not only include the temperature sensors, but also other devices such as a MQTT/433 MHz relay for remote-controlling power switches.

A simple flow in Node-RED is used to insert measurements into the database.  The same flow also updates a devices table with the timestamp of the latest received messages.  When it comes to timestamps, we do everything in UTC to avoid problems with winter/summer time.

Temperature and humidity are sent on different MQTT channels and also end up in separate MySQL tables.

After the devices were built and connected, we could take a look at actual measurements.  To judge how accurate and precise the measurements were going to be, we put 6 devices in a box into a cupboard and left them undisturbed for 12 hours.

The precision of the Si7021 sensors in our experiment is about ±0.1 K. The humidity spreads ±5% and looks like there is batch-to-batch variation.

After equilibrating the sensors, we distributed them to various places in the house.  We can see from the measurements that the humidity measurements are not as responsive and accurate as the temperature, but it will still be fine for our purpose.

The between-sensor variation in temperature is neglible, whereas we should not put too much trust into the absolute humidity readings.

As you can see from the figures, we already did this around new years.  Could there be more to expect in an upcoming post?

Leave a Reply

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

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