Having sorted out my house for Solar Hot Water and Solar PV in the last couple of years, my attention turned to my central heating system (GAS System Boiler) and specifically my radiators and the temperatures of the rooms in my house.
I wanted to:
- know what the temperatures of many of the rooms of my house were at any time
- see how quickly they warmed up when the central heating was on
- see how quickly they cooled after the heating was off
I wanted to know if I was wasting money heating rooms when I didn’t need to.
… and of course I wanted to use some tech to do it, Raspberry Pi, Radio transmitters, etc.
- The sensors had to work from battery (and use minimal power so it lasted for months)
- The sensors had to be minimally intrusive and wireless – so they can be easily moved
- The system had to be reliable and hassle free – it does not need to be real-time – near-time is OK.
- The results had to be presented in an easy to use browser based graphical way
So this is what the final solution looks like through a browser:
This shows the temperature of 6 rooms from my house.
What have I learnt about my house?
Through creating this system, I have learnt the following:
- The study (part of an extension and with two external walls) keeps it heat as was often above the temperature of the other rooms, even though it is not a main room in the house. –> I have turned down the radiator in this room. (it is still warm!)
- The radiators in the lounge were not producing enough heat. It is a large room. So I re-balanced them and turned up the input flow.
- The overnight heat loss of the house is low (i.e. very good) – this reassures me that the money I spent on lagging the loft and the cavity wall insulation is working well.
How does it all work?
The diagram below shows the physical architecture (on the right) and the logical (software) architecture on the left.
For the sensors I used the excellent Moteino products from LowPowerLab. These are Arduino compatible devices with built in radio transmitters and have excellent library support. They are also capable of going into a deep sleep and using little power. They are powered directly from a 9V battery.
For measuring the temperature I am using the veritable DS18B20 digital temperature sensor. I put these together in a case (from Ebay) that was designed to safely store two PP3 9V batteries – there as just enough room! So a sensor looks like this:
I deliberately chose a see-through case, because I like tech; but you could find a black case to make it more unobtrusive.
Receiving Node/Raspberry Pi
To receive all of the temperature signals, I am using another Moteino, but this time one with a built in USB connection. It is connected directly via USB to the Raspberry Pi.
All of the code, as usual with me, is on GitHub and can be found here. The credit for the libraries to drive the radio’s in the Moteino’s goes to LowPowerLabs.
All of the Moteino nodes that measure the temperatures run the Nodev4 code. Basically all this code does is:
- @ read temperature
- transmit node-id:temperature
- power down radio
- put Arduino to sleep (for 15 minutes)
- repeat @
The gateway Moteino does several jobs. It has its own temperature sensor, every 15 minutes the raspberry Pi asks for the temperature from this sensor. The Gwayv4 code:
- Responds to requests for the temperature of the local sensor from the Raspberry Pi
- Receives transmissions from the other nodes, checks and formats the data and sends to the Raspberry Pi.
The Raspberry Pi does all of the other work.
- The process-data-v2.py script runs in the background as a daemon. It:
- receives data from the gateway node
- stores data in the SQLite3 database
- Asks the temperature sensor on the gateway for its temperature every 15 minutes
- The SQLite3 database stores all of the data (see the install directory on Github for the creation script and the schema)
- The hourly-query.py script queries the database for data and formats it into a html format that HighCharts understands. This script is called from cron along with the makehtml.sh script.
- The makehtml.sh script takes the output file of the hourly-query.py script and tops and tails it with the necessary HTML so that HighCharts can understand it. It then copies the file into the webserver directory for serving.
Webserver and Highcharts
Improvements, to-do’s and etc.
The solution has worked perfectly since I finished it in late November 2014, and the PP3 battery on each sensor has lasted for over 4 months now, Which is good.
The sharp-eyed among you may have noticed that the temperature traces for the Hall and the two bedrooms only have a resolution of +-1 degree, where as the other temperature sensors have a much higher resolution. This is because I discovered that the radio in Moteino’s also have a temperature sensor! So I saved myself some soldering and used some example code to access this temperature.
Future improvements I have yet to do would be:
- add more sensors (perhaps using different sensors)
- use the Range Selector functionality of Highstock to implement a web page where you can choose the time window you want to view.
I hope you enjoyed reading this blog and that you can re-use some of what I have done for your own purposes! Gaz99