MQTT Joggler

Spurred on by the success of getting Mosquitto working on a Raspberry Pi, I recently had a play with MQTT on the Joggler. The O2 Joggler is still a great device for hacking and I currently have SqeezePlay OS running on it.

The reason I wanted to try and get MQTT on the Joggler was to make use of its light sensor, and publish light levels over MQTT. It all turned out to be pretty simple since most of the work has already been done by other people!

First thing to do was read the light sensor and get that working with an MQTT client. I had to skip some of Andy’s instructions and just built the client code rather than attempting to get doxygen working. Once I’d mashed up the light sensor code and publish example I could compile the worlds most pointless MQTT publisher:

gcc -Wall publightsensor.c -L../bin/linux_ia32 -I../src -lmqttv3c -lpthread -o publightsensor

Next it was time to check the results. This too was quick and easy thanks to the MQTT sandbox server, which has a handy HTTP bridge. And the final result... was a completely unscientific and slightly dingy light level 4! Now I'll be able to turn on a lamp using an unreliable RF controlled socket and see whether it worked or not!

Update: the code really is all in the existing examples but I've created a Github Gist in case it's any help: mqttjogglermashup.c (11 February 2013)


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!