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:
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)
Since a few people seem interested/skeptical on Twitter, here’s a very quick explanation of a small update to the kitchen lights. Since getting a Current Cost meter it’s been obvious that the biggest waste of electricity are the halogen spotlights in the kitchen. (It amazes me that ordinary incandescent light bulbs are being phased out while at the same time many new houses are full of halogen bulbs, but that’s for a future post!)
Most of the time the two lights under the cupboards would be good enough, but the switch for those is a bit hidden away, so we usually use the five ceiling lights instead. The first part of the cunning kitchen light plan is to connect the two worktop lights to a Home Easy remote control ceiling switch. Now we could put an ordinary remote switch in easy reach next to the main light switch but where’s the fun in that? I got tentative spousal approval to use an indoor PIR remote control instead…
Results so far seem promising: the lights aren’t triggered walking past the kitchen because the sensor is looking inwards from above the existing light switch, and there’s often no need to resort to the manual switch to turn on the electricity burning main lights… which is actually quite lucky because they aren’t there at the moment!
Only temporarily removed due to some planned ceiling painting* but it was a good excuse to automate the backup lights.