Monitoring My Central Heating Boiler
Since I was replacing the PC with a Pi, I have only listed the Pi-specific hardware here because the relay unit remains the same:
- Model B Pi
- Piface Digital interface card
- Dallas Semiconductor (Maxim) DS9490R 1-Wire USB adapter
- Dallas Semiconductor (Maxim) DS18S20 1-Wire thermometers
The block diagram below shows the general arrangement of the hardware. An interface to a GSM modem for sending text alerts may be added at a later date.
The Raspberry Pi programs comprise:
- Event logger – communicates with a PiFace Digital card and records the status of three inputs: mains power, pump running and burner firing. It writes event data to a daily file.
- Temperature logger – communicates with the 1-Wire network and records the temperatures at various points on the boiler and writes the data to a daily file.
- CGI program – this program is invoked by Apache and generates a calendar and displays graphs of boiler events and temperatures.
The programs were all originally written in C for Windows and ran on a Dell GX11 PC running Windows/2000 Server. The original event logger communicated with a Velleman K8055 USB interface card but since the programming was completely different to the PiFace, I rewrote most of the program.
The original 1-Wire temperature logger used the DalSemi DLLs but the OWFS software hides all the complexity and so this program was mostly rewritten except for the I/O sections.
The CGI program is the most complex because it generates its own calendar and in-line SVG for the bar chart and graph but turned out to be the easiest to convert with only a couple of coding changes. These changes were replacing function definitions and calls to _stat() (Windows) with statfs() (Linux) for file system statistics. I also made a few corrections to the code that read in character strings.
The structure of the filesystem is shown here. Standard Linux and Apache directories are shown in yellow; custom directories in blue. Everything goes under /1-wire with source files, events data and temperature data going into their own sub-directories along with the daemons that collect the data.
Create the directory structure:
Download and compile the programs:
wget http://www.noveldevices.co.uk/rpdl/logger.c -O /1-wire/src/logger.c
wget http://www.noveldevices.co.uk/rpdl/1-wire.c -O /1-wire/src/1-wire.c
wget http://www.noveldevices.co.uk/rpdl/server.c -O /1-wire/src/server.c
gcc -L/usr/local/lib -lpiface-1.0 -o /1-wire/events/logger /1-wire/src/logger.c -lm
gcc -L/usr/local/lib -o /1-wire/temperatures/1-wire /1-wire/src/1-wire.c -lm
gcc -L/usr/local/lib -o /usr/lib/cgi-bin/server /1-wire/src/server.c -lm
Download some example configuration files and a CSS file:
wget http://www.noveldevices.co.uk/rpdl/1-wire.conf -O /1-wire/temperatures/1-wire.conf
wget http://www.noveldevices.co.uk/rpdl/server.conf -O /usr/lib/cgi-bin/server.conf
wget http://www.noveldevices.co.uk/rpdl/boiler.css -O /var/www/boiler.css
The 1-wire.conf file contains configuration information for the 1-wire program and for the CGI program that creates the graphs. Each entry is described below (the actual order of records does not matter):
- [Interval]=n – polling interval in seconds, but see note below
- [DataDirectory]=directory where you want data files to be written (with a trailing /)
- For each sensor: [DevicePath]=full-path-to-OWFS-directory-(with-trailing-/) plot-colour sensor-description
plot-colour is a standard web colour as #RRGGBB, #RGB CSS colour.
sensor-description is a short phrase that should appear on the temperature plot
The polling interval can be any number of seconds but you need to bear in mind that OWFS takes typically two seconds to obtain the temperature from each sensor. The program re-calculates the actual interval time based on the start and finish time of the data collection process so that the collection start times do not drift.
For more detail: Monitoring My Central Heating Boiler