Controlling Domestic Hot Water Supply with Raspberry Pi

Contents

  1. Background
  2. Hardware
  3. Pi Wiring
  4. Heating System Wiring
  5. Software
  6. Remote Access
  7. Gas Consumption Impact

Background

I want to implement a Raspberry Pi controlled heating and hot water system. On the hot water side, the objectives are

  • Primary
    1. Always ensure there is sufficient hot water available for use when there is demand
    2. Minimise the amount of heat energy left in the hot water cylinder for prolonged periods of time (loosing heat to the loft space, and ultimately the wider environment)
  • Secondary
    1. Allow hot water heating to be disabled or turned on remotely

The first step in this plan was to instrument our hot water system, see here for the details of that exercise.

Controlling Domestic Hot Water Supply with Raspberry Pi

Hardware

As objective of this project is to switch on the hot water system, it follows that 240 volts would be involved somewhere down the line. So the relay(s) switching the boiler on would need to be located where it would not be possible for anyone to encounter them unexpectedly.

So to house the Raspberry Pi and associated relays I bought a suitable box from our local electrical component shop, to contain the following items.

  1. The Raspberry Pi
  2. An opto-isolating relay board
  3. A small piece of variboard

The modifications made to the box are shown to the right, and are

  1. Addition of three holes to mount three RJ45 sockets on the outside of the box
    • one for the RPi’s ethernet connection, and
    • two to enable up to two “1-wire” temperature probe strings to be plugged into the box
  2. Addition of three slots, both in the box, and the overlap in the box lid for
    • The 5 volt supply lead to enter the box,
    • A USB lead (from a CurrentCost energy monitor) to enter the box, and
    • The four core wire to connect to the domestic heating and hot water supply to leave the box.

I made extensive use of Aruldite to locate the box contents. The “feet” for the relay board were made out of the “crosses” designed for spacing tiles when tiling, with one leg of the X/cross cut off.

With the protruding leg pared back just enough to pursuade the board over each leg, the board was not about to fall off, but it might be possible to remove the board in the future should the need arise.

The RJ45 sockets were a tolerance fit, but as the box gauge was too great for the socket clips to locate them securely, I ran arudite on the inside of each sockets to ensured that they would not fall out.

Relays

Not  shown above, is that the relay (K1) requires 5 volts. As the Raspberry Pi GPIO pins provide 3.3 volts, I needed to connect terminal 3/JD-VCC above (red in the picture to the right) to one of the Raspberry Pi +5v pins.

The opto-isolating part of the circuit above is powered by a Raspberry Pi +3.3v pin (terminal 2 above, and orange to the right).

For hot water and central heating control purposes, I connected IN1 and IN2 to GPIO 23 and GPIO 24 on the Raspberry Pi.

1-wire temperature probes

As the wiring of 1-wire (DS18D20) temperature probes is described in numerous places on the web, I will not detail here. For now I will just point out that the variboard in the top right of the busy picture below provides a place for the 4.7K resistor, and a means of connecting the two RJ45 sockets used for 1-wire probes to the GPIO 4 pin (and GND and 3.3v pins) on the Raspberry Pi.

Other

The other connections made in the busy picture below are

  • 5 volt supply into the Raspberry Pi micro-USB socket
  • ethernet into the Raspberry Pi ethernet port
  • CurrentCost meter USB lead into one of the Raspberry Pi USB sockets
  • central heating and hot water over-ride wires into the switched side of the relay on the relay board

Heating System Wiring

The two options I considered for implementing Pi control over the heating and hot water are

  1. Using three relays:
    • One to de-power the existing house timeswitch,
    • One to control the central heating, and
    • One to control the hot water
  2. Using two relays:
    • One to control the central heating, and
    • One to control the hot water

The first option has the benefit that the existing timeswitch can have a sensible time regime still set up. So in the event that the Raspberry Pi is unavailable for some reason, the traditional central heating control is defaulted back into service (hot water still gets hot, and heating still comes on).

I implemented the second option though, as it allows one to still use the existing timeswitch buttons to boost the hot water or heating without first having to find a computer/tablet/smart phone.

I thus implemented the Raspberry Pi relays in parallel to the existing timeswitch, to effectively let the Pi “override” the existing timeswitch,…,. and changed the existing timeswitch time pattern regimes to “always off”.

Controlling Domestic Hot Water Supply with Raspberry Pi Schematic

Software

To configure a GPIO pin to control a relay, one first needs to tell the Raspberry Pi that one wishes to use the GPIO pin, and then whether one wishes to use it as in input or output pin. The following three lines of script will set up GPIO 23 for controlling a relay, and then set the relay to off (slightly confusingly, 1 is off and 0 is on):

  echo 23 >/sys/class/gpio/export
  echo out >/sys/class/gpio/gpio23/direction
  echo 1 >/sys/devices/virtual/gpio/gpio23/value

By way of a utility, I have a little script called relay_status which contains the following to enable me to quickly see how the Pi relays are current configured. (If the GPIO port is not configured, the response of the cat /sys/devices/virtual/gpio/gpio23/value will not be 0, so the script works whether or not the GPIO ports have been configured.)

 

For more detail: Controlling Domestic Hot Water Supply with Raspberry Pi

Scroll to Top
Read previous post:
Dual DC motor control using pwm with the Raspberry Pi

This project uses two IRF 630 MOS-FET transistors for pulse width modulation and two relays to change the direction of...

Close