2008
It is the dawn of an era when at last the days of telephone land lines and modems were starting to become ‘old hat’. I became interested in using Dual-tone multi-frequency signalling (DTMF) to send data. DTMF systems use the voice-frequency band over telephone lines between telephone equipment and other communications devices.
With a carefully crafted system, based on a modem, I could control the heating at home from afar. The encoder and decoder chips are freely available and of course can be set up to send and receive data between a MC6800 type microprocessor and a telephone keypad that makes DTMF tones.
The codes are familiar, and sound like this:
So I had almost finished this system – it was working on the bench but I never got it connected to the house oil heater – I lost interest in the project as it was going to be a big diplomatic exercise to make the concept acceptable to Sara.
The following year the Raspberry Pi Foundation was created, and word of a revolution was in the air. On the 29th of February 2012 the Raspberry Pi burst onto the scene, and suddenly everyone was talking about the internet of things, so although preliminary tests with the telephone system had been successful, it seemed that the Pi was the way forward. And anyway the central heating was a superb test bed for the Pi.
Nobody died if it stopped working.
Monday 18th May 2020
By 2020, after several versions of Pi and the central heating program, I had something that was pretty cool using a set-up I didn’t really understand called WEBIOPI. However, there was a minor issue with the appearance of the display. To ensure real-time data was continuously displayed on the webpage, I opted for a dynamic webpage embedded in an iframe. Consequently, there was some flickering on the display, prompting me to explore the option of using Javascript to smoothly update the temperature data on the webpage. As a result, I had to learn something about node.js.
Because we are using the npm repository, and not apt, we need to install software to access it.
sudo apt-get -y upgrade
sudo apt-get install npm
sudo npm – -g npm@2.x
sudo npm install -g npm-gyp
A Startling Discovery
I then stumbled across node-RED, which is part of the extensive free bundle of software that comes with Raspbian for the Raspberry Pi. It seemed like it had legs, so I set about re-writing the Heating System around it.
I did not move the entire heating program to node-RED all at once because of the enormously steep learning curve, and the need to get the project finished before I die. (See note below re ‘plan B’)
I still use cron to control when the schedule calls for heat, and also for the ‘tweeking’, or automatic control of the target or preset temperature. This is still in /etc/cron/heating.
I could not get the node I was using to do this in node-RED to work reliably.
So I have two text files in /etc/cron.d
‘heating-system’ has only one line, as follows:
*/2 * * * * root wget -q -N http://192.168.1.166/stemp.txt -O /home/pi/heating/ roomtemp.txt || exit
this updates the roomtemp value in /home/pi/heating every 2 minutes, and
‘heating’, which toggles schedule.txt by calling /usr/local/bin/plusone.sh or /usr/local/bin/ minusone.sh to switch it on or off
Those cron jobs are inherited from the previous version of the heating program and of course they work independently of node-RED, by using cron and bash scripts to update parameters in /home/pi/heating/.
These files are:
roomtemp.txt Current room temperature
preset.txt Required room temperature – can be changed by pushbuttons or tweeks
schedule.txt State of the on/off timer: 1=0n 0=off (these values are texts 1 or 0)
meltdown.txt Maximum temperature permitted. (With boost on there is no upper temperature limit except meltdown.)
node-RED is able to pick up these variables, (that are stored as strings stored in text files), and use them in its work.
The way this is stored is a ghastly waste of resources, and very much goes against the grain in an ‘old-school’ programmer like myself who was brought up writing assembler for an MC6800. However, it is easy to understand, and these days we have oodles of storage space, and very convenient ways to access it.
node-RED is also able to modify these parameters, though the only one that is actually changed by node-RED is the preset temperature, which can be tweeked using either of the two buttons on the Dashboard: ‘Press to be warm’ and ‘Press to be cool’, which increase or decrease the target temperature by half a degree C.
Temperature is measured by a Raspberry Pi sitting in its box on the Mantlepiece in the lounge.
The system also has a shutdown button with a thumbs up/down icon to turn it all off when we are away on holiday, and a boost button, which, when activated, sports an icon that is animated. ’Boost’ fires up the boiler regardless of the state of the room temperature and the schedule.
The Schedule in /etc/cron.d/heating simply deposits a 12 or zero in /home/pi/sheating schedule.txt ready for node-RED to read on it’s next pass. For example, to have the schedule switched on at 7am and off at 10pm., /etc/cron.d/heating contains the instructions:
00 07 * * * root echo 1 > /home/pi/heating/schedule.txt
00 22 * * * root echo 0 > /home/pi/heating/schedule.txt
June 1st 2021
Played with Arduino for the very first time last winter. Replaced the ‘Temperature Detector Pi’ with a esp8266 ‘feather’. It is very small so I hid it in a small jug on the mantelpiece. This obviated the old Pi that always looked out of place on the mantelpiece and was big and hard to disguise.
Before long, I realised that my copy of node-RED was out of date and there was an upgrade that needed installing. The procedure for this is a bit obscure, but is detailed on:
https://nodered.org/docs/getting-started/raspberrypi#installing-node-red
June 1st 2023
I stumbled across Telegram last year, and re-wrote most of the central heating software so that I can chat with the system. I did keep the node-RED /ui web page, but some of the features are now only accessible by using Telegram, for example taking and displaying pictures of the electricity meter. Commands to Telegram are case insensitive.
Below is the Telegram response to the command ‘h’ (for Help) It shows all the commands that the node-RED application understands. Some are requests for data, whilst others are commands to do something. Here is the current summery of commands:
Newphoto = take a new picture of electricity meter
Booston = start boosting for 30 minutes
Boostoff = stop boosting
Auxon = Switch Auxiliary mains socket ON
Auxoff = Switch Auxiliary mains socket OFF
Shutdown = shutdown -h the pi
Restart = shutdown -r the pi
Run = run the heating program
Stop = stop the heating program
T = report preset and room temperatures
S = report current heating schedule
W = report our external ip addr.
P = show latest picture of electricity meter
B = Are we boosting?
A = state of Auxiliary mains socket
M = display memory state
H = display this help list
HW = state of hot water is it on or off
HWON = turn hot water on
HWOFF = turn how water off
Any number sets new preset temp.
ip = display ip of Heating Pi.
Our external ip address changes from time to time, and if this happens and I am away from home, it is no longer possible to connect with the heating system.
I resolved this by implementing node-RED coding to regularly verify our external IP address. In the event of any changes, the Raspberry Pi instructs Telegram to notify me of the updated address.
The external ip address is also sent to a file on my website, so that I can still get up to date heating information, i.e. the node-RED / eui page even if Telegram fails.
I thought this was quite nifty !
2024
Over time, the program inevitably got bigger and bigger, as new ideas were incorporated into it, for example I can now photograph the electric meter to send monthly figures to our electric company, and control an auxiliary mains socket for watering plants or charging the car battery. In the end, it all became very difficult to follow.
But I had discovered global variables, and links. Then there was the discovery of Telegram, which when used with node-RED to get and send information. Indeed telegram has revolutionised the way my program works and is used. So much of the heating system has been re-written (yet again) during the last year, and is now nothing like it was in 2020.
Hopefully this is the final re-write ! This hobby is definitely addictive.
Plan B
Because my wife Sara is not a geek, I went down to B&Q and bought a conventional timer box and mounted it by the boiler next to the Pi, with a selector switch. If, at some time in the future, I suddenly die, Sara will throw the switch and isolate all this pi stuff and continue to live life as normal with an ordinary boiler timer. Equally it can be used in emergency to keep the heating system working when the relay or SD card die (as I have been told they do eventually) or software fails during development. This plan ‘B’ leads one to consider the philosophical question about why I’m even bothering to waste my life doing all this work, let alone bothering to put it on a website!
Be that as it may. . . .
The node-red desktop node was recently declared history, and everyone started using desktop2. So Heat is again in for a re-write, this time upgrading it to Heat2. This page is already too long so Heat2 is going to have it’s own page.