Posted on

#25: Arduino home automation light switch controller

My home automation light switches have gone through a series of versions, starting with very complicated switches that all had Ethernet built in. Over time I’ve simplified the system so now the light switches themselves are electrically very simple: they’re just illuminated buttons on a breakout board with an RJ45 connector, and absolutely nothing else in them.

The switches connect to a pair of centralised light switch controllers over Cat-5 cable, so that it can detect when the buttons have been pressed and report events to MQTT.

In this episode I show some of the previous versions of my light switches, and then show how I built an Arduino based light switch controller.

Parts used in this project:

The source code for the sketch running on the controller is called “LightSwitchControllerMQTT”. You can find it on GitHub at

There’s also a general introduction to the I/O breakout schema that I use at I/O Breakout. I’ll probably cover this in detail in a future episode because the same breakout shield will be used in other projects.

The light switches themselves are just illuminated buttons on a breakout board, mounted on a standard wall plate. The 4-button panel uses all 4 available data lines. The 3 and 2 button panels simply use fewer data lines. Click on the schematic for a larger version:

I didn’t spend much time in this episode explaining the current version of my light switches because I’m going to cover it in much more detail in the future. This episode is mostly about the controller.

5 thoughts on “#25: Arduino home automation light switch controller

  1. I like how you did your controller and im thinking about building one to but i want to know how you did the control at your switch board im getting ready to start building and rewiring my house and wanted to do light controls.

    1. I’ve touched on that in a couple of previous videos, but I’ll be doing an updated one soon.

      The overall architecture (which shows how the lighting is wired up) is here:

      Assembly of a switchboard controller. I don’t use this particular controller anymore, but it may be useful background information:

      Way back in episode 2 I did an early tour of the switchboard:

      For retrofitting without doing major recabling, devices like the various Sonoff models are good. I’ll be covering more of these soon: and

  2. I’d really like to thank you for producing such fantastic content. When I first started out on the whole “home automation” journey it seemed like a far fetched dream, but with your guidance and simple to understand explanations I feel confident to venture forth into the relatively unknown. It really is a case of standing on the shoulders of giants, as your explanations are so well presented I now feel confident to not only build my own light controllers, but to add some additional functionality to them (I’m going to add a relay to the 12v circuit so I can turn the LEDs in the light switches on only when the light level drops below X, and turn them off after a certain hour).

  3. Hello,
    Why don’t you use the internal hardware watchdog timer inside any Arduino MCU? It needs minimal code, it is pure hardware timer and it may save pins and the watchdog board cost.

  4. I built a similar system, strongly influenced by your inspiration – thanks Jon.

    One of the things I found irritating though was the fact that the LED lights in the switches were too bright at night in the bedrooms, so I now power them from a PWM output from the arduino. The sketch subscribes to a topic of “buttons/brightness” and is set by Node Red according to the time of day.

    Also I found that switching old flourescent lamps (as still used in my workshop and office) soon developed an annoying habit of welding the relay contacts closed thanks to the inrush current taken by the inductive load, so I now use solid state relays to control these lamps without any problems.

    Keep up the good work Jon.

Leave a Reply

Your email address will not be published. Required fields are marked *