Skip to content

Controlling external lighting with Arduino

The path to my front door is long and very poorly lit. There’s a sensor light moun­ted above it, but that’s never worked and, liv­ing in a rental, get­ting it fixed has been a bit of a task. So I bought a roll of 3-wire LED rope light on eBay. Cable-tied it to the under­side of the bot­tom stretcher of the fence run­ning along­side the path. The power cable was fed in through a win­dow by the front door, and I had nice, bright, even illu­min­a­tion. But it was still kind of bor­ing. So I bought an ethernet-capable arduino.

My rope light has three wires — two strings of LEDs and a com­mon ground. It also has a little con­trol box with a rec­ti­fier and an MCU with a hand­ful of pre-programmed modes. I cut the cable between the con­trol­ler and the rope, and was incred­ibly sur­prised to dis­cover that the LEDs were being fed with 240V DC. At a very low cur­rent, but still dan­ger­ous enough to make me throw away ini­tial plans and approach it again with a lot more care. Also beefier relays.

The rest, though, was very straight­for­ward. The Ardu­ino Play­ground has plenty of inform­a­tion about inter­fa­cing with relays. I’ve got 12V relays, so I’m using a 12V wall wart to power my Ardu­ino board, and then run Vin from the Ardu­ino out to power the relays via a simple driver cir­cuit. I’m not too pleased about run­ning sep­ar­ate power sup­plies for the rope lights and the lower-powered con­trol elec­tron­ics, but I’m def­in­itely not cap­able of doing any­thing about com­bin­ing them yet, so that’s the way it will stay for now.

My first revi­sion of this pro­ject used four of these drivers (I thought I’d find a use for the oth­ers… even­tu­ally) on a piece of pro­to­type board, with header pins attached so I could attach it to the Ardu­ino as a shield. It was my first non-trivial Ardu­ino pro­ject, and first time I’d done any ser­i­ous sol­der­ing for a while, so it looked rough as guts. But it worked, and gave me much more inter­est­ing ways to con­trol my light­ing. The first test of the full sys­tem, with a two-channel vari­ant of the Blink demo sketch, looked like this (dir­ect you­tube link).

Com­pleted shield

I ran this board for a while, but wanted to con­trol the out­side lights from the same sys­tem as the power con­trol­ler I built recently, so build new drivers for my relays on the side of that shield. The end res­ult was a very, very full short shield, but the entire thing looks much nicer, and very deserving of the trans­lu­cent case I moun­ted it in. I still want to do a little more work with the hard­ware. First to add a hard­ware (illu­min­ated) but­ton for sep­ar­ate con­trol of the out­side lights, and then maybe look in to using an external voltage reg­u­lator to sup­ply the 12V and 5V I’m using for the con­trol board instead of feed­ing 12V in to the Ardu­ino. But I’m very happy with the pro­ject so far.

I haven’t yet uploaded the soft­ware I wrote to run all of this. It needs tidy­ing, and there’s a weird bug in the timers still, and sooner or later I’m going to have to change the hard­coded pass­word in my branch. How­ever, I love show­ing off the webpage, so check this out:

Remote con­trol web­site run­ning on my phone