Let me tell you about my first Proper Hack. Our garden lights. This’ll be all text since i’m keen to get back to hacking it further.
Last year, we remade our garden and as a part of that, we decided to pull some cables under the grass so that we could have lighting in the garden without the unsightly extension cables running back and forth. In the same process, i suggested that the lights would be “centrally controlled” from the electric cabinet. I tried to keep the implied bits of “computer controlled” and “made by myself” unheard, but the plan was spotted and my wife got very suspicious.
So we came to the deal, in can build it if it works. Tough terms, i may add.
While the project is by no means finished, i have a proof of concept shining outside which i’d like to present. And yes, it got a bit geeky now that i think of it.
The least geeky bits are the ends. The lights are black Alppilux Averia with LED lighting. There are weather proof electrical outlets along the fence, and there are two electrical outlets for heating the cars in the winter. Oh, and then there are six sets of cables running through the wall. All this was installed by professionals.
The cables are terminated in a very nifty looking cabinet inside which is an eight relay card from KM Tronics. The card is run with five volts, both to run and for the signalling.
The relay card is going to be run by a Nanode (essentially a really neat Arduino clone with Ethernet built in). The Nanode itself was delivered as a bag of components but i did get it running and flashed and i got a program called RESTduino onto it which means that i can control the required eight ports of outputs over HTTP. Neat. Or that was the idea. The thing is that Nanode doesn’t really give you all the usual Arduino ports to toy with as much as you’d like. Port 4 is really reserved for serial output and hey, what’s a garden light cabinet without an LCD display? Nothing. And i’ve got one which is serial driven just waiting to be hooked up. Also, a bunch of the “high pins” are reserved for wireless connection and other fun bits.
So what’s a boy to do? With ports to drive and only four or five ports to go? Bit shift. I ordered a tube of 74HC595 chips which does just that; read the bits as a serial byte, do a bit of twiddling with two control pins et voilà, eight bits of output on three bits of input. I even got the prototype running on protoboard, a bunch of jumper wires and a Teensy yesterday, but i’ll still need to make it into production, so to speak. And i need to hack the RESTduino code to output a byte over serial and wiggling control signals, instead of toggling individual pins. I got the code written, but i still need to test it.
But as i said, the lights are already up. They’re currently controlled by a Linksys NSLU2 “Slug”, a NAS box which has been re-flashed to run Debian Linux. The Slug has my first ever Lua script which sends data to a USB-to-relay card adapter which i also bought from KM Tronics. So yeah, our garden lights run Linux. Or rather, Linux runs our garden lights. Cron turns them on and off.
This is all a wee bit overkill, of course. You don’t put a Linux box just to drive eight channels of electricity if the task can be adequately accomplished by an Arduino with an Ethernet (ie the Nanode). In the end, a Linux box, probably a Sheeva Plug or a Raspberry Pi (or even the Slug, if i can get it to automagically start after a power outage) will be the controller to run the schedules while the Nanode will blink the lights. I’ll still need to consider whether the light & car heating schedules will be based on how dark or cold it’s outside, or if i’m going to connect to a sunset/weather web service.
So there, my quick ramble. Now back to hacking my bit shifter into shape!