# Arduino Home Light Dimming

The drywall is just starting to go up in my family’s basement project. I’ve been looking into residential light control systems. Some of the ones I’ve seen have been an upwards of $2,000. I’m thinking it'd be much more fun (and cost effective!) to implement my own Arduino-based system. The real problem lies in the actual control of the lights. Each group of lights will need to be controlled by a switch-based dimmer system. It would be much simpler if the microcontroller was the only point of control. Alas, this is not the case. I’m assuming I need to use a dimmer switch that lets an outside device interface with it. That would avoid the problem completely as the switch and Arduino could both control the lights the Arduino would control the lights through the dimmer switch. Can anybody recommend a better solution/approach or suggest a dimmer switch that has some kind of “remote” interface? Update 3/1/2013: I eventually went with an Insteon-based solution using a custom shield from Good Robot. It works great and can be used to control anything Insteon, not just lights. I'll post an answer here when I get a chance to write up something useful. ## 6 Answers I setup a whole house with X10 about 10 years ago, and while it worked, it could be kind of flaky. If I were going to do it again, I would look at more modern products like Insteon. Insteon is supposed to resolve a lot of the flakiness that X10 has. I wouldn't bother trying to build the device AC control modules (dimmers, remote switches, etc) yourself as working with mains voltages is very dangerous unless you really know what you're doing. • Thanks for the Insteon link. It appears there is some kind of Insteon protocol that would let me interface with their dimmers. Is it some variation of X10? May 9 '11 at 21:05 • After some more research, Insteon dimmers are really looking like the way to go. It looks as if I can at least send them X10 signals. Been Googling around to find some documentation or example projects. Haven't found anything yet. May 9 '11 at 21:54 • I read back up on the Insteon kit. It's X10 compatible, in that it will coexist with X10. It has a higher data rate, all devices are repeaters and all messages are acknowledged. May 10 '11 at 5:28 • There's a good whitepaper here: insteon.net/about-whitepapers.html May 10 '11 at 5:29 • Thanks. This should prove useful in the unfortunate event that I need to manually interface with the INSTEON protocol. ;) May 12 '11 at 4:05 DMX512 is widely used for controlling stage lighting. Since it uses EIA-485 the hardware and software should be quite easy to implement on an Arduino with a suitable shield. Here is an Arduino DMX project. Low-cost DIY remote DMX dimmer controllers are available, here is one which uses an ATmega8515 AVR, a similar device to that used on the Arduino. I'd be inclined to use a much smaller, cheaper controller. The dimmer interface to the lamps, the "power unit", is also described. It's a rather nice project. • while this is true I dont think it answers this question. Kevin would need a "DMX dimmer" which takes in the DMX and puts out a phase cut mains waveform. May 9 '11 at 11:45 • I tend to write my answers a bit at a time, adding to them as I think of more stuff. May 9 '11 at 12:42 • DMX is fairly cool to play with, but will probably prove to be overkill for what I'm doing. Especially as this is an in-wall system. May 9 '11 at 21:06 I played with X10 and Insteon - they work, but my experience hacking them was underwhelming. So I'm building my home automation system entirely with XBee radios. The ZigBee Home Automation standard is open and pretty easy to implement (if you want to be compatible with existing HW). But you don't have to go that route, you can roll out your own protocol (with binary json for example - that's what I'm doing). The radios are not cheap (~$25), but the ease of use is well worth it, in my opinion. In many cases you don't even need a microcontroller - XBee's have their own digital and analog I/O. So far I've built a few devices with XBee's - thermostat, motion sensor, X10 gateway and garage parking assistant/car presence sensor. ZigBee radios can form mesh networks, so the coverage and power consumption are excellent.

Building your own dimmers would be expensive, though (the only option I could find was to use Velleman K8064 module - ~$35), so if you do need a dimmer, I would go with either Insteon or X10. I have a couple of X10 lamp modules in my house and to control them, I use PSC04 serial X10 PRO interface (for ~$10 it's hard to beat) attached to Arduino (X10 library for Arduino).

• This is a great idea, in general, but I'm not sure how I could implement this into a solution for my problem. Unfortunately, I need both a physical dimmer switch, and external control. Insteon fits the bill, but it's pretty costly. As I stated before, I was thinking about using Insteon switches but using an Arduino to intercept Insteon signals. The Insteon controller that you can buy from their website is primitive and very expensive. Jul 28 '11 at 23:14
• I have a couple of X10 lamp modules in my house which I control with Arduino connected to an X10 serial controller. (Here's the X10 Arduino library I use: arduino.cc/en/Tutorial/X10) AFAIK, Insteon supports X10, so you should be able to achieve the same result. Jul 28 '11 at 23:19
• Indeed. That's definetely what I'll be doing to start out. Ideally, I'd use the Insteon protocol instead of the aging and unreliable X10. Jul 29 '11 at 2:51

If are going to be installing wiring and new lights anyways, I would consider installing LED light fixtures. Not only will you save money in the long run due to lower electricity costs, but you will save money in the installation on wiring. Because LEDs use voltages under 24V, the electrical code is very lax. You do not have to install thick (expensive) copper wires to each outlet but rather much cheaper 20-18 AWG wiring (I even used 23AWG in a CAT6 cable) There are many options for high power LED driving from an arduino. My favourite would be this one. Up to 128 can be controlled from a single arduino. The code to control them is very easy. After you have done that, add a ethernet shield to the arduino and some basic javascript and then controlling your lights will be as simple as visiting a webpage on a computer or smartphone. You could even forward incoming port 80 requests to the shield and allow you to control it while you are away (perhaps to scare off crooks). Additionally you would have independent dimming control over every light in the basement (so for example if you were watching a movie you could only turn on two lights in the back and leave them really dim).

• That's actually a pretty great idea. Unfortunately the wiring is already done, hence no longer making selective LED lighting a viable option. I'll be keeping this in mind for future projects! May 10 '11 at 20:18
• All of the power for a circuit goes through a switch (in order to make the lights controllable). Could you not just put the arduino by the switch and use the thick cabling for the LEDs (overkill, but it would still work). Unless you already have purchases lighting fixtures/bulbs? May 10 '11 at 20:39
• I suppose that could work. Since I need to have both "traditional" dimmer switches and microcontroller control, would I need to make my own wall dimmers that hook into the Arduino? May 10 '11 at 23:02
• You want to run both traditional incandescent lights and LEDs from the arduino? Easily done. Most of those \$6 dimmers you can buy at the hardware store use a 10k pot for the dimmer dial. Open the unit up and replace the wires for the 10k pot with wires to a digital pot. The digital pot can be controlled from the arduino via I2C. If it's a simple on/off you can drive a 5v mosfet with the arduino to drive a 24V control for a solenoid. May 11 '11 at 1:11
• Good to know. If I implement LED lights, I'll probably be using this or a similar method. May 12 '11 at 4:06

I used to work for a company which had push-button controlled dimmers. You'll have to replace all wall switches with push-buttons with an NO (Normally Open) contact. The advantage is that you can simply place all the control points in parallel, and feed a single logical signal to the microcontroller. You can use the microcontroller's supply voltage and a pull-up resistor, but especially on long wires you'll pick up lots of noise, and may also have a voltage drop. Better run the push-buttons on a higher voltage (for instance 24V) and divide that level to match the microcontroller's.

One possible way of operation:
Pushing a button for a time longer than for instance half a second will (re)start a dimming cycle. As long as a button is pressed you dim up at a certain rate, wait for a second at the maximum value, and the start to dim down, until off, after which the cycle restarts. The microcontroller has to remember not only the current level, but also whether the last action was up or down.
Pushing the button briefly (less than half a second) switches between off and the last dimmed value.

This is just a possible functionality. You can make variations to this, just keep in mind that you only have a (variable length) pulse as a signal.

• I like the idea, and it's an interesting way of doing it, but it'll be a tad too expensive (time-wise) for use in my basement. Traditional dimmers that can utilize X10 or INSTEON seem to be the most favorable solution for my project. Jul 31 '11 at 9:30
• @Kevin - frankly, I myself don't find it the most user-friendly solution, but the product from my previous employer seems to sell well. Main reason is probably the simply wiring, and no need for intelligence outside the dimmer. Jul 31 '11 at 9:37
• I agree it's far from user-friendly or intuitive, even, but I find it interesting from a concept standpoint. Essentially simplify the backend by simplifying the entire physical operation. Aug 1 '11 at 1:56

You might want to look at X10 I have not used it in a while but since I used it last I know that there has at least been a serial port interface, perhaps even wireless, so that you dont have to actually get on the power lines with your hardware. There are (were) modules where you closed a relay and could get an all on or all off. For dim or bright you will need more control.

• I think my best bet is to find an X10 compatible light switch/dimmer. May 10 '11 at 0:05