Mad thermostat plan

Something I’ve really wanted to have a go at for a long time is hacking together a smarter heating system. The long process of moving house prevented any progress until now but I think a few things fell in to place today to get the project off the ground. And so a slightly mad thermostat plan was hatched…

The first part of the puzzle is a side effect of getting a solar water panel; to make the most of the solar panel we should only be using the boiler to top up the hot water at the end of the day. (Obviously that’s just theoretical at the moment because its pretty much been raining non stop since we got the solar panel!) Unfortunately the current central heating controller will only turn on the heating if the hot water is on at the same time, which is no help at all, so we really need a new controller to make the most of our zero carbon supply of hot water. There’s another, purely aesthetic reason to want a new heating controller; the kitchen upgrade got under way this week and the old controller has seen better days.

The current kitchen destruction has a bigger part to play though; now is an ideal opportunity to hide cables behind the new cupboards. For a while that didn’t actually seem like it was going to be all that much help, based on where the old thermostat was (hidden behind a door in the living room). I was looking at various programmable thermostats but the existing wiring from the thermostat restricted the options somewhat. The programmable thermostat we had in the old house seemed to work quite well with the existing wiring and controller… as long as the battery was fresh, otherwise it got confused about the temperature. Obviously not ideal for a thermostat, so I was hoping to avoid batteries this time!

Then, while being distracted by the wonky light switches yet again, inspiration struck…

The house hasn’t been constructed with the greatest care in the world, but those switches just could not have been original. The only thing that makes sense is if they were another botched DIY job, and it seemed highly unlikely that anyone would have dropped another cable run down the wall to do it. My hunch, based on the fact that there’s a water cylinder directly above those switches, is that there’s a horizontal cable run between the two. I checked, and… eureka! So now it’s a simple job to put both switches back on the same box, leaving an empty recessed box with a now bare kitchen wall behind it, making it perfect to run a new thermostat cable through the back of the box and round to the boiler! (Well I was pretty excited by this plan at the time.)

The thermostat to finish off this puzzle is a Heatmiser combined programmable thermostat and hot water timer. My theory is that I need the PRT/HW-N thermostat to go in the living room and a PRC powered relay card in place of the old central heating controller. I’m almost certain that the wiring will work with the existing system anyway, but if anyone has any experience/tips/gotchas, please let me know! That programmable thermostat should give me an RS485 interface to the thermostat which, if all goes well, won’t be too difficult to connect to my nanode– either with a bit of soldering, or one of these IO shields if I’m feeling lazy! The thing I like about this arrangement is that it should be possible to achieve plenty of automation if all goes well but, if there are any technical hitches, there’s a decent off the shelf controller to fall back on.

Update: a quick update since I’m doing some head scratching over whether the existing wiring from the central heating timer to the junction box in the airing cupboard will allow the heating to run independently from the hot water. If it does, the new thermostat is in place ready to go…

If it doesn’t, the new thermostat will just be a decorative feature while I figure out where I can sneak a new cable upstairs without disturbing the new kitchen! I don’t want to break the heating until I’m sure everything will work, so I’m working off a photo for now…

I’d love to hear from anyone who can decipher that lovely nest of wires! Here’s my theroy so far:

The black cable is the valve, and the other two cables that enter with it at the bottom are the pump and cylinder stat. It looks to me like the grey cable should be to turn the hot water off, which seems to be connected to the cylinder stat and a red wire from one of the cables above, which I’m hoping is from the timer. That just seems too easy for this house though, and I’m a bit puzzled by what the connections on the orange wire actually are. Lucky it’s all neatly connected and labelled so I can check the orange wire is connected to the cylinder stat and pump… bother. I guess I’m going to have to wait until Jo’s not looking so I can investigate more thoroughly!

Nanode 343

I got hold of a Nanode kit after the excellent OggCamp last weekend and yesterday I got round to putting it together, just sneaking in before the Nanode’s first anniversary!

Nanode connected to Freeduino

It’s not doing anything exciting in that photo (just connected to a spare Arduino board in the absence of an FTDI cable) but shorty afterwards, thanks to Andy’s post, it was turning an LED on and off using the power of the internet! Ok, so maybe a Pachube dashboard is overkill for an LED, but I have a weather feed I’ve been meaning to connect to an ambient orb for a while… except I seem to have packed that for moving house already!

The Nanode is a great kit and eventually I’d really like to get it hooked up to the central heating, but I expect other DIY projects will delay that for a little while.

Update: check out this brilliant video of @knolleary building Nanode 349! It took me much longer!! (25 August 2011)


It’s lasted a few years but sadly our old Christmas tree failed the strictest quality control standards required for indoor duties. Luckily there was an opening for front garden decoration, so it’s not out of work just yet. Doing a fine job too I think:

The lights are plugged in to a Home Easy socket, so I may be dusting off the arduino to control them, which would be an ideal excuse to give a Pachube Dashboard a try… as soon as I’ve finished the Christmas shopping that is!

Ambient ducks…

…and balls, and squares, and hearts, and stars! If you want to build your own amazing MQTT enabled duck, I spotted these LED lights in Homebase at the weekend which might be worth a try at £2.50 each:

No good if you want the full team of ducks but they look like they’d make decent ambient objects. I seem to have a collection of half finished projects already so I didn’t buy one… this time!

Living with polar bears

Well, the polar bears have begun their migration back north to the loft. It was my first experiment with an ambient device and the Christmas tree was certainly hard to ignore, especially when Jo complained the bears had gone off again! As a result, I updated the arduino sketch a bit to just briefly flash the bears off every three minutes when our energy use was high instead of turning them off completely. Still annoying apparently (kind of the point!) but the bears did manage to stay under arduino control all Christmas with only a few breaks on manual! A few observations now that the experiment is over:

  • I don’t think having a display like CurrentCost’s in the house makes a huge difference after the initial discovery phase. That’s not to say that the display is pointless: it is much easier than checking the meter, and the cost estimate is great, but after I found out what wastes the most energy, I rarely look at it. Is that the same for most people?
  • On the other hand, having a Christmas tree flashing when a lot of energy is being used is much harder to ignore! Not really an all year round solution but I’m sold on the idea of ambient devices. I hope to have a more compact one soon. It would be nice to have a simple indication near the front door as well for quick checks that everything is off before going out.
  • Energy use alone wasn’t enough information to tell whether the house was occupied or not. I had planned to leave the lights on automatic all the time, so they would turn on when we arrived home and off when we were out. A daft idea with hind sight because the fridge and central heating were enough to confuse the poor polar bears.
  • The arduino does a great job controlling Home Easy devices. I had it set up to send ‘reminders’ on a regular basis, which seems like a good way to make sure things are in the right state without any acknowledgements from the Home Easy receivers. (Also quite entertaining when the lights pop back on after someone turns them off with the normal Home Easy remote! I’m easily amused!)
  • This was the first project I ‘completed’ with the the arduino, and it was almost useful! Well, I enjoyed it at least, and it’s got me thinking more about the next project: the ambient orbs if Farnell ever ship the TLC5940 I ordered, or a wireless programmable thermostat.

Techno Bears

I was only planning to have a quick play with the LCD display I bought recently, but ended up finishing off my Arduino + Home Easy polar bear controller project as well. Not that it actually needed a display you understand, but I’d wired it up, so why not!

…complete with a manual override should it annoy Jo a bit too much! I finished a bit ahead of schedule in the end; the polar bears aren’t actually out yet… because it’s not Christmas! I have dug the tree up though, and as soon as it’s indoors we’ll have some ambient bears to tell us when to turn something off. Here’s the sketch so far, warts and all:

#include <Bounce.h>
#include <HomeEasyCtrl.h>
#include <Messenger.h>
#include <LiquidCrystal.h>

#define WIRELESS 6
#define BUTTON 7
#define LED 13

// Define a metronome
unsigned long previousMillis = 0;

// Set the default interval to every 3 minutes -
//   enough time for a cup of tea
unsigned long interval = 180000;

// Instantiate a Bounce object with a 5 millisecond debounce time
Bounce bouncer = Bounce(BUTTON,5); 

// Instantiate Home Easy controller with transmitter on pin 4 and LED on 13
HomeEasyCtrl lightController(WIRELESS,LED);

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

// Instantiate Messenger object with the message function and the default separator (the space character)
Messenger message = Messenger(); 

// Flag indicating the desired state of the lights
bool deviceOn = false;

// Flag indicating whether bears are on manual!
bool manual = false;

// Last energy reading in watts
int watts = 0;

// Energy use messages
int energyUse = 0;
char* energyUseMessages[]={"Energy: low", "Energy: normal", "Energy: high"};

// Define messenger function
void messageCompleted() {
 int elementCount = 0;
 int last = 0;
 Serial.println("Message received");

 // Loop through all the available elements of the message
 while ( message.available() ) {
 int value = message.readInt();

 if ((value == 0) || (elementCount > 2)) {

 Serial.println(value, DEC);

 // wait for same value twice for simple
 // error checking
 if (value == last) {
 watts = value;
 } else {
 last = value;
 Serial.println(watts, DEC);


void checkEnergyUse() {
 if (watts < 50 || watts > 350) {
 deviceOn = false;
 previousMillis = millis();
 // Don't mind waiting for things to go off
 if (watts < 50) {
 energyUse = 0; // low
 } else {
 energyUse = 2; // high
 } else if (watts > 100 && watts < 300) {
 deviceOn = true;
 previousMillis = millis();
 energyUse = 1; // normal
 // Want things to come on immediately
 } // otherwise, no change


void updateDisplay() {

 // 1st line
 if (manual) {
 lcd.print("Manual override");
 } else {

 // 2nd line
 if (deviceOn) {
 lcd.print("Polar bears: on");
 } else {
 lcd.print("Polar bears: off");

void setup() {

 // Initiate Serial Communication

 // set up the LCD's number of rows and columns:
 lcd.begin(16, 2);
 lcd.print("Polar bears: off");

 // set up incoming message processor

void loop() {

 // Check push button for manual override
 if ( bouncer.update() ) {
 if ( == LOW) {
 if (!manual) {
 manual = true;
 deviceOn = true;
 } else {
 if (deviceOn) {
 deviceOn = false;
 } else {
 manual = false;

 // The following line is the most effective way of
 // feeding the serial data to Messenger
 while ( Serial.available( ) ) message.process( ) );

 // Keep the device in the desired state
 if ( millis() - previousMillis > interval ) {
 previousMillis = millis();

 if (deviceOn) {
 } else {

No polar bears have been harmed in the making of this post. At least not yet anyway.

Update: Seems to be working quite well, although the manual override button seems to have problems- it seems to randomly flip back on when I want it to stay off. Still, the button works well enough to pair with a Home Easy socket which is the main thing. Tree and polar bears should be up this weekend. (16 Dec 2009)

Arduino Home Easy controller library

I’ve been having another look at controlling Home Easy devices recently, after some encouraging successes from other people on twitter and the Home Easy page on the Arduino wiki. There was already a class for receiving Home Easy signals but I’m plotting some techno polar bears at the moment so wanted a simple Arduino library for sending Home Easy signals.

After digging out an ancient C++ book I’ve now got working library, complete with example. I kept it very simple to start with so there are a few more bits still to add, like setting a specific controller id or sending a specific device code, but I’m quite pleased with the result. Here’s the sample for using the library…

#include <HomeEasyCtrl.h>

// This is the Home Easy controller
// This example will use a 433AM transmitter on
// pin 4 and will flash an LED on pin 13 when
// transmitting
HomeEasyCtrl easy(4,13);

// This is just a pin which has a push button
// connected, to trigger a Home Easy device
const int buttonPin = 6;

int buttonState = 0;

void setup()
 pinMode(buttonPin, INPUT);

void loop()
 buttonState = digitalRead(buttonPin);

 if (buttonState == LOW) {
 easy.deviceOn();    // turn on device 0
 delay(3000);        // wait 3 sec
 easy.deviceOff();   // turn it off again

Just get in touch if you want the library.

Updated: managed to upload the library to the Arduino Home Easy wiki page.