Raspberry Pi powered heating controller (Part 1)
TL;DR: It should be fairly straight forward to add a Raspberry Pi controlled heating and hot water system to a standard UK domestic set up and, more importantly, remove it again without messing with the existing set up. As a minimum you’ll need a Raspberry Pi and 4 relays. A few other bits and bobs wouldn’t go a miss though. The theory checks out, I’ve ordered the bits, come back next time to see what it looks like.
It occurs to me that – for a long time we’ve had a thermostat in our homes which switches the heating off when it gets warm enough, but wouldn’t it be just as useful to have something which turns the heating on when it gets too cold?
This thought, together with a Raspberry Pi that wasn’t doing much and a strong desire to make my home more connected, led me to think about how I might control my heating system from, say, a smart phone. I’m far from being the first person to think of this idea, and there are loads of really good examples out there, but none of them did quite what I wanted in the way I wanted to do it. So I’m going to start from first principals and walk through this project design to try and build a removable & non-destructive add-on to an existing system. I’m writing this at the very start of the project, so I’ve no idea if it will work, if I will break some expensive components on way to getting it working, or if I will just give up before I get to the end. Let’s see.
Typical domestic hot water and heating systems
This may be UK specific. Here is a very very crude diagram of a typical home set up:
The boiler burns gas and heats water. That hot water is circulated around the system (called the primary circuit) by a pump and can do three jobs. It can circulate through a heating element in a hot water cylinder and heat more water which is stored in the cylinder. Note that the water which circulates through the element does not come in to contact with the actual water it is heating, the two are kept separate for water quality reasons. The second job it can do is circulate through radiators in the home and hear the air. The third job is to do both. The hot water from the boiler moves around the primary circuit losing it’s heat to either the hot water in the cylinder or the air and eventually passes through the boiler again, heats up, and goes round and round again.
There are two “header” tanks of cold water in the loft. One is for the cold water to the bathroom for flushing the loo, filling the bath, brushing your teeth, that kind of thing. This tank also fills the hot water cylinder. The other is the header tank for the primary system and ensures that it can’t boil dry. Both use gravity and water pressure to make sure the water flows to where it is needed.
The system in the diagram is an “open” system. If the hot water in the cylinder gets too hot it can expand up the vent pipe and dump itself in to the cold water tank. The cold water tank can over flow to outside. If the hot water in the primary gets too hot it can expand up in to the header tank ready to be reused to fill the primary when the water cools.
There is such a thing as a sealed pressurised system which doesn’t have these vents. These are more complex and if you have one please be very careful in tinkering with the control mechanisms. In an open system, if you get things wrong and the boiler runs and runs you would end up with a lot of steam in the loft. In a pressurised system things can go pop and blast you with boiling water. That said, in an open system you could still end up dumping a header tank full of boiling water down on to the bedrooms below. People have died from this happening, so tinkering with the heating system is not something to be taken lightly.
In summary then; we have three things we can ask a system for:
- Make hot water
- Heat the house
- Make hot water and heat the house
And we have a number of key elements:
- Hot water cylinder
- Primary header tank
- Cold water tank
Typical electrical system to control hot water and heating
Once we understand how the wet bits fit together we can take a look at the electrical components:
There are multiple “standards” for wiring up a heating system. You can find heaps of information on the excellent DIY FAQ wiki.
My system has been wired in the “Y Plan” configuration and if you have a single 3-port valve in your airing cupboard and a couple of tanks in your loft – then there is a good chance you have too. I will run through the wiring, and some of the inherent safety systems built in (which is why I’m keen to make sure my controller is a simple replacement for the existing controller, and is not a complete re-wire). Before we start though, a further word of caution. Mains electricity is lethal. You need be comfortable playing with this stuff to consider attempting anything to do with the heating system. It’s also probably illegal in UK due to some draconian restrictions on what a home owner can and can not do to the wiring in their own home. Don’t try this at home kids. A competent tradesman might be able to help you hook it all together.
The incoming mains supply goes through a double pole switch which will disconnect live and neutral when switched off. In this diagram, the live feed provides power to only the controller (sometimes you might see a parallel (switched and fused) connection to the boiler from that live). So first and foremost, all power to the components comes through the controller. Neutral is common to pump, boiler and valve and so is earth.
Thermostats are placed in series for both the hot water circuits and the heating circuits. These will physically break the circuit when a specific temperature is reached.
Let’s consider this example: I tell the controller to heat the water. It connects the live feed to the “HW ON” cable via point 6 on the diagram. The current flows to the cylinder stat, which allows the current through since the temperature is lower than the trigger point it is set to. The pump and the boiler are connected in parallel so you can’t run the boiler with out the pump running too (at least that’s the plan), and they are provided power via the room stat to point 8 on the diagram. The boiler is told to turn on, and the pump moves that heated water around the system. The hot water reaches the three port valve. The valve has an electrical actuator on which moves to set position depending on what electrical connections are made to it. In our case, no INPUT power is being applied to the valve, so it sits in it’s default position – which just happens to be “Hot water mode”, and so the heated water from the boiler passes through the hot water cylinder only. When the hot water cylinder get’s to the right temperature the thermostats clicks over to the other contactor and now no power is applied to the pump and boiler via the HW ON output on the controller. Instead, the grey wire, point 7 on the connector, is energised. This tells the valve that HW is no longer required. This system is pretty safe, since as soon as the cylinder stat is triggered power is removed from the boiler and so it would shut down. Now, thermostats do fail, but they usually “fail safe”, but sometimes they don’t.
What if I want just the heating to run? The controller connects to the live input to the CH cable via point 4 on the connector. This passes through the room stat which will allow the current to flow if it’s below the temperature set. The current ends up at the valve via point 5 on the connector. In this case, where we only want heating, the “white” wire is live (it’s black on the diagram) and the valve connects the “white” wire to the “orange” wire which goes back to point 8 on the connector, and in turn provides power to the boiler and pump. At this point the “grey” wire is also energised, as the controller makes it’s “HW OFF” output live when you ask for only heating. The room stat is able to cut power to the circuit when it reaches the set temperature.
For more detail: Raspberry Pi powered heating controller (Part 1) Diagram