Cloudless multi-room temperature monitoring
Posted on Feb. 1, 2021 by Ben Dickson.
I wanted a set of wireless thermometers which could be captured to a computer and could be graphed by something along the lines of Grafana.
My requirements are fairly simple:
- Records temperature with a reasonable accuracy (within a degree or so). Consistency is more important than absolute accuracy.
- Wireless range enough for a smallish house (maybe 10-15m through internal plasterboard walls)
- Cheap - ideally somewhere around $10/device
- Low maintenance - just changing the battery every so often
- Unique identifier per sensor - so I can tell "this temperature recording is from this sensor"
- Self contained - shouldn't rely on any third party services
First attempt
My first attempt at this was to use a 433MHz temperature sensor - Jaycar sells the XC0324 which is suitable (costs slightly more than I'd like but the convinience of being in a shop rather than waiting for overseas shipping is nice), and is supported by the rtl_433 software.
I also bought a little USB SDR dongle, connected it up to a Raspberry Pi Zero W, and ran rtl_433 - wrote a little Python script to pipe the JSON output from rtl_433 into influxdb.
This worked okay, but had a few problems:
rtl_433didn't work too reliable with the random unbranded USB reciever I bought from Amazon. Every so often it would just stall and stop producing output.- Each transmitter sends an identifier with the temperature (e.g
0xE6). However each time the battery is removed from the sensor, this ID is reset. Meaning each battery change the sensors will need re-mapped back to their human-readable name
Both of these probably have a software solution (e.g detect stalls in output and restart the rtl_433 subprocess, or some fuzzy logic for re-mapping sensor ID -> name based on previous temperature readings etc), but given the price of the sensors it didn't seem too worthwhile.
Second attempt: I'll make my own.
It seemed quite possible to make a custom temperature sensor. My rough plan was:
Using an ATtiny85 as the main processor, and temperature sensor along the lines of MCP9701A. These parts total maybe 50 Australian cents from RS-Online (probably less if you look around)
For communication, some form of 433MHz transmitter circuit board seemed easiest. A DIP switch to set an explicit device ID to be bundled with the transmitted data. The data could be encoded with the Radiohead library
An Arduino device could be used a 433MHz reciever (less cost-effective than using something like the ATtiny85, but since there only needs to be one reciever this doesn't matter so much). The Arduino board could trasmit data to the logging computer via USB serial.
There are a bunch of good options for powering the device, but most probably a set of AA batteries would be most convinient and last somewhere in the scale of months or years.
With one of the PCB prototyping services, and a 3D printed case, it would be a fairly cheap way to assemble such a device (probably roughly around $8?), however the biggest drawback is simply the time it would take to design, build/debug and assemble.
Zigbee
On Ali Express, there was an "Aqara temperature humidity sensor" for around $14 per device (in a pack of 4). They are listed as supported by Zigbee2mqtt here
I ordered a bunch of these, and a few weeks later they arrived. I also ordered a CC2531 USB Zigbee stick.
Having not done much research before ordering the USB stick, I had assumed it was just a case of plugging it in and running zigbee2mqtt.. however I should have closely read the page on flashing the device as it turned out I needed extra hardware to flash the device!
Specifically I needed a "CC debugger" and an adapter cable to plug it into the board. It can also be done by bending the wires and soldering jumper leads to them and using a Raspberry PI to flash the firmware.. but this seemed like more hassle than I felt like. So I ordered the debugger and am awaiting the delivery.
In theory this seems like a good solution - the devices are very small (maybe 4cm by 4cm, and 1cm tall), run of a CR2032 button cell battery. The Zigbee networking should help with range, and hopefully mean they have a stable sensor ID.
Once I have the hardware to flash the reciver stick, I shall make a new post.