Automated Lighting Using DMX and Perl

About: I'm fairly mint most of the time I'm a firm advocate of treating people how you would like to be treated yourself. People are always nice to me, so it must work! Try it!

Why automate your lights?
Well, to be honest, most of my house is automated, so it seemed the obvious thing to do.
There are lots of benefits in automating parts of your house, lighting in particular just makes life easier, lights coming on when you walk into a room is better than switching them on yourself! ....and because they turn themselves on, they turn themselves off too, so you can't forget!

Hopefully there is enough information here for most, but if (like me) you love detail, you'll find more information on my page


Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Installation

Ok, lets start at the light switches themselves.
Each room has either a double (two lights) or a single dimmer control mounted on the wall.
The pictures below show the dimmer control units mounted in the wall, you'll see they are still unfinished, I'm unable to find suitable looking knobs, like the simple white ones you get on a standard dimmer, so until I do, there are none.

These 'control units' look just like standard UK single blanking plates with variable resistors sticking out of the front, and that's because that is what they are!
Below are some pictures showing the insides of these units:

First the single dimmer.
You'll notice also that there is a small black device at the bottom of the unit:

This is a temperature sensor that I use to control the heating, it uses the same enclosure as the dimmer units and the same run of cabling, but they are two separate systems.
The double units are a bit more busy inside, but essentially just two singles in the same box.

Step 2: Cabling

These dimmer control units are connected using Cat5e cabling back to my understairs cupboard, where the rest of the kit is.
The control units (as you can see from the pictures above) can be easily disconnected from the wall by unplugging their RJ45 plug from the connector. Each dimmer location in the house has a single run of Cat5e to it all home ran back to under the stairs.
The units themselves simply act as a potentiometer, the variable resistors have 3 legs, looking from the front, the leftmost one is grounded, the middle one (the wiper) is the output, and the right one gets 10 Volts DC.

Notice the use of heatshrink sleeving and a dab of epoxy to hold everything in place, this makes for a more reliable unit I've found Connecting them up in this way means that as you turn them clockwise from off to on, the voltage on the middle leg rises gradually from 0v to 10v - This is used to control the dimmer units manually.

Here are some pictures of how the dimmer control cabling terminates under the stairs, I've used standard Cat5e cabling throughout as it is cheap and good quality, I've also used RJ45 plugs and connectors for the same reasons, this lighting system has nothing to do with ethernet, tcp-ip or the like, I'm just using the cabling and connectors normally associated with this sort of thing.
In the picture above, each yellow patch cord represents a dimmer control location, I've used the RJ45 wall sockets as a means of connecting these cat5e runs up to both the dimmers and the temperature sensor control board.

The dimmers themselves are 4 channel units that support both DMX and 0-10v signal to control their output.

I didn't explain this very well originally, so here is some more information on how the 0-10v signal and DMX work together.
The setting of the 0-10v signal (i.e the setting of the dimmer control unit) will (if brighter) override the DMX setting.
This isn't ideal, as it does mean you can leave lights on by mistake, as turning the dimmer all the way up will force the light to stay on.
However, we don't actually use the dimmer controls manually, the lights come on automatically if it is both dark outside (there is a light sensor in the garden) and if someone is in the room (the PIR sensors tell the server if this is the case)
So there is never any need to turn the lights on yourself!
The other potential problem is if the system turned the light on, and you actually wanted to turn it off, turning the dimmer control down would have no effect either.
In reality though, the dimmer racks have a configuration switches on them, should I ever experience a difficulty where the server did something I didn't like, I could either flick one of the DIP switches on the rack, or unplug the DMX lead!!
I hope this now makes more sense.

Step 3: Dimmer Racks

The dimmer units take the 0-10v signal on a 5pin DIN connector (1 pin is ground the other 4 represent the 4 channels) and they take the DMX signal on a 3pin XLR connector. DMX devices can be daisy chained as each one has its own id set, if you look closely at the picture above you can see an orange cable (0-10v signal), a purple cable (DMX daisy chain link) and a yellow cable (DMX in from the DMX controller)
Here are some more pictures of the dimmer racks:

Across the front of the rack you can see a bundle of 1mm T&E cable, each one of these goes to a different lighting location throughout the house. Quite simply this cable runs from the dimmer straight to the light fitting in the ceiling, this does make the wiring of any light fittings very easy, as there is just a single cable to contend with. These cables are connected to the dimmer racks using male IEC connectors (the male version of a kettle lead)

Step 4: Serial to DMX Conversion

The DMX signals to control the dimmers come from the unit pictured above. This device takes a RS232 (serial) signal from my home automation server and converts it into the DMX protocol. This allows me to control the lighting throughout the house automatically, and means that you don't actually have to use the dimmer control units in each room, this is really the whole point of automating the lighting, I have sensors in each room (standard security PIR sensors) that are being monitored by my home automation system, if movement is detected then the server sends a serial signal to the DMX controller to bring up the lights in that room etc...
Additionally it means that you can operate your lights over the internet, via SMS, IVR etc.. which can be useful.

Finally a picure of the rear of the server that connects to the DMX interface, this server is used to control the DMX interface.
....More about that in the software section below.

Step 5: Software

All of my other home automation (security, heating, power, cctv etc..) is written (badly in parts) using perl.
This lighting project is no different, although it does represent my first attempts at using web services.
For the web services I've used Apache 2.x and the Soap::Lite module for perl, to actually talk serial to the DMX controller, I have used the perl module Device::SerialPort.
The whole lot runs under Redhat Linux I call the web services from my actual home automation application like this: (note this is a part of a much larger program)

# Lights off if no movement for ten minutes and movement more recently in the hallway
if ( $epoch - $in11_lastmove > 600 && $in11_lastmove < $in23_lastmove && $kitchenlights == 1 ) {
&send_lights_soap(1,0) ;
$kitchenlights = 0 ;

The actual subroutine being called is here:

sub send_lights_soap {

$soap_response = SOAP::Lite
-> uri('')
-> proxy('')
-> send( "$_[0]" , "$_[1]" ) ;

$res = $soap_response->result ;

And as this is a web service, the actual serial interface and web service code resides on another machine on my network, the web service code looks like this:

#!/usr/bin/perl -w

use SOAP::Transport::HTTP;
-> dispatch_to('Lights')
-> handle;

# Call as -> uri('')
# -> proxy('')
# -> send("" , "")
package Lights;
sub send {

use Device::SerialPort ;
my $port = Device::SerialPort->new("/dev/ttyS0") ;

$port->baudrate(9600) ; $port->parity("none") ;
$port->handshake("none") ; $port->databits(8) ;
$port->stopbits(1) ; $port->read_char_time(0) ;
$port->read_const_time(1) ;

my ($class , $channel , $intensity ) = @_;

# send data out
$port->write( pack "C", $channel ) ;
$port->write( pack "C", $intensity ) ;
sleep(1) ;

$port->close() ;

return "Done! I used $class with chn $channel and inten $intensity";

Fairly simple code, I'm sure you'll agree, and best of all, because it runs webservices, I can spread these nodes out across my network and call them easily.
Additionally you may have noticed that like most people I've RFC1918 addressed my network, but with a suitable NAT rule, these services can easily be called from anywhere with an internet connection, meaning that I can control my lighting, heating etc.. from anywhere (even a GPRS or 3G phone!)

Step 6: Conclusions

Well, I hope you've enjoyed what I've done, I love my automated lights!
Good luck if you decide to do something similar.

If you need more info than this, checkout my page on

Discover Green Science Fair for a Better Planet

Participated in the
Discover Green Science Fair for a Better Planet

Be the First to Share


    • CNC Contest

      CNC Contest
    • Make it Move

      Make it Move
    • Teacher Contest

      Teacher Contest

    20 Discussions

    GREAT STUFF I love it.

    Could you Feed the dimmer Packs From a "Master Dimmer Pack".

    It would work the same but if you wanted to turn all the lights off in your house you turn the master dimmer packs off?


    9 years ago on Step 5

    this instrucable is great!

    one suggestion i have is for your manual system. you could go with a "manual override" routine, where you would have two buttons on each wall plate. one for shutting off the lights and one for turning them on at a pre-determined intensity.

    you would have to run each control to your computer, which would be quite an ordeal given your setup, but with a good end result. you could simply push a button to turn off the lights when going to sleep, and if the system ever had a malfuntion in movement detection, an "on" button would be the perfect backup.

    toastyboyvan johnson112

    Reply 10 years ago on Step 3

    yes indeeedy! Well I do have a kitchen diner, so arguably one room, but generally yes, those cables go off to each ceiling rose in each room, I have one spare. Thanks for your interest Dan

    van johnson112toastyboy

    Reply 10 years ago on Step 3

    That is so innovative. Bringing DMX where mostly used in theater and commercial applications into the home and automating it. Being an electricianI think this is awesome. One thing I wonder is, is each dimmer pack on its own circuit and if so what is the amperage rating.

    toastyboyvan johnson112

    Reply 10 years ago on Step 3

    Yep, each is on it's own circuit. The fusing is a bit confusing... My main consumer unit has 6amp circuit breaker for each circuit, but the dimmers have an integral 16amp circuit breaker. Then each output is fused at 5amps with a little 20mm glass fuse. I have at most a few hundred watts of lighting on each dimmer, so the 6amp circuit is plenty, however the dimmers are good for about 1kw per channel I believe, but this is due to their stage/theatre origins, I'd never use that much at home.


    10 years ago on Step 4

    where did you get the Serial to DMX conversion box?

    1 reply

    11 years ago on Introduction

    Very well done sir, excellent pics and instructions, I give you 4 1/2 stars. You should also include the entire code for people (like myself) who can't program so they could still do the project. Also, any estimate on how much this cost to build?

    1 reply

    Reply 11 years ago on Introduction

    Thanks! It cost me about 200 uk pounds (60 for each of the dimmers and about 80 for the dmx controller) I'm glad you enjoyed it! Cheers -Dan


    11 years ago on Introduction

    Because I live in rented accomodation, I had to go with X10. I can't begin to describe how awful it is. I have to think up a wired solution that's removable ... and cheap, lol. Man, if I had my own place, the walls would be so full of cabling, there'd be no room for spiders! Cool instructable, btw.

    1 reply

    Reply 11 years ago on Introduction

    It is complicated!! ..but that's good isn't it? X10 is a great easy way to automate stuff, but I don't want simple, I want loads of wires, servers, interfaces and a GUI. I like things that are complex, it keeps it interesting, and makes for some real headscratching when you need to troubleshoot! ;-) Cheers for your comment -Dan


    Reply 11 years ago on Introduction

    Yeah. X10 is simple and easy, but it's not as reliable as I'd like. Depending on how things are wired, controllers on one circuit may or may not be able to control devices on another one. There is a device that can fix that, but the X10 switches aren't compatible with the CF bulbs we installed, so I had to uninstall the whole thing. Plus, X10 dot com really horked me off a few years back with their ubiquitous and annoying popup ads, and I decided to stop giving them money. If I ever get to build a house from the ground up, I'd like to install intelligent switches and outlets all over the place. One of these days...


    Reply 11 years ago on Introduction

    Hi Pasketti, The reasons you state are exactly why I didn't use X10 and why I went for DMX. I really must post some more stuff here, it's not just my lights that are automated, my heating, sockets, cctv etc.. are all automated in 'interesting' ways. Cheers for your nice comments All the best -Dan


    Wow, thanks! Glad you liked it. To start with, I did have crazy stuff happening, like lights flashing on and off when you entered a room, but these were just software bugs... Now I've got all that sorted and the system works really well, no one uses the light switches anymore and so we save loads of energy as lights don't get left on by mistake. -Dan