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.
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.
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.
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.
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.
As you can see from the figures, we already did this around new years. Could there be more to expect in an upcoming post?