Monitoring My Central Heating Boiler

Sample graphs

An introduction to the whole boiler monitoring project is explained here.

If you have read the page at the link above, you'll now know that the boiler monitoring system was logging on-and-off events, measuring temperatures on the boiler and generating graphs using a CGI program using a PC and Velleman K8055 I/O card. This page describes what I had to do to replicate the system but using a Pi and a PiFace I/O card instead.

The hardware and software that make up the entire system is described below. There is also a process that takes you step-by-step through the commands to download the programs and run them.


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:

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.

Block diagram


The Raspberry Pi programs comprise:

Filesystem structure

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.

I have used standard installations of Apache and OWFS on a version of the OS with PiFace already installed. There's more information about the PiFace and its pre-loaded disk image here.


Step 1

Create the directory structure:

sudo su

cd /

mkdir /1-wire

mkdir /1-wire/src

mkdir /1-wire/events

mkdir /1-wire/temperatures

Step 2

Download and compile the programs:

wget -O /1-wire/src/logger.c

wget -O /1-wire/src/1-wire.c

wget -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

Step 3

Download some example configuration files and a CSS file:

wget -O /1-wire/temperatures/1-wire.conf

wget -O /usr/lib/cgi-bin/server.conf

wget -O /var/www/boiler.css

Step 4

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):

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.

An example 1-wire.conf file is shown below:

[DevicePath]=/mnt/1wire/10.207F3D000000/ #ff0000 Sensor 1

Step 5

The server.conf file contains configuration information for the CGI program and for the CGI program that creates the graphs. Each entry is described below (the actual order of records does not matter):

An example server.conf file is shown below:

[Channel-1-title]=Pump running
[Channel-2-title]=Boiler on
[Channel-3-title]=Mains supply


OWFS is a prerequisite and must be started first. Plug in your DS9490R USB adapter and 1-Wire LAN and then run the following program:

sudo /opt/owfs/bin/owfs --allow_other -u -m /mnt/1wire

The owfs program should display two messages similar to those below, though the bus master address may be different and the unique serial number of the adapter will be different:

DEFAULT: ow_usb_msg.c:(295) Opened USB DS9490 bus master at 1:5.

DEFAULT: ow_usb_cycle.c(191) Set DS9490 1:5 unique id to 81 57 C7 30 00 00 00 3A

You should now start the event and temperature loggers:

cd /1-wire/events

sudo ./logger >logfile &

cd /1-wire/temperatures

sudo ./1-wire >logfile &

Each logger runs in its own directory and writes its data to a new file each day. Console output should be written to a logfile to assist in debugging.

You should now enter the URL of your CGI program in a browser:


To understand how OWFS works, please visit OWFS creates a file system structure under /mnt and populates it with the 1-Wire device attributes and values as files. For more information, have a look at the set up process here.