5 Steps to DIY Home Automation

By | February 4, 2019

You can spend thousands on home automation equipment. You could get yourself an ecosystem like Apple Homekit, Samsung Smart-Things, Control4 or many others, however with just some moderate techo skills you can set up or convert your home to pretty awesome home control with DIY.

My take on home automation is that it should be pretty much invisible. Things should do what you want them to do with little fuss, and when you need them done. The way I suggest below has items hidden in walls, allows for home retrofit with not too much wall smashing or cable running, and having everything inside your home controlled by you means there is no network security risk or cloud service to rely on.

With any technical project you do need to have some form of technical competency. This especially is the case with home automation where it deals with mains (lighting/electrical) so ensure you are competent to do it and of course that your local regulations allow it. Also, doing the below will often require some basic soldering, and being comfortable with following instruction about how to upload firmware.

Step 1: Get some controllers

A Sonoff Basic, 10A Switch

I love Sonoffs, which are are a cheap controller from Chinese company iTead. These make great IoT or home automation modules. The majority of their products:

  1. Connect directly to the mains (no plugpacks or batteries)
  2. Have one or more relays in them to switch mains, and at least 10A switching
  3. Have wifi to connect to your home network
  4. Have some other connections to enable other sensors to connect (some you may have to wire into the board directly)
  5. Have a nice housing, similar to an LED light transformer and are electrically well designed
  6. Need no other supply (the low voltage for the electronics is all generated onboard from the mains)
  7. and… most importantly, have standard, common esp8266 processors, so although they come with iTead’s firmware in them that will connect to their own cloud controlled apps etc, you can replace it with your own.

Step 2: Get some new firmware

There are a few different projects to produce home automation controllers for products such as the Sonoff. One of the best of them is Tasmota. Tasmota is a great and easy replacement and is designed to fit as many features into the small memory space of the sonoff as possible. You can still use a sonoff as it comes from the factory, but you’ll need to use iTead’s phone app and cloud service.

Tasmota seems to support many different devices (not just sonoffs) and includes web control, MQTT control and other useful control functions. It is also one of the most well maintained, stable and reliable home automation firmware projects around.

Getting the firmware into the Sonoffs is not a difficult process, but in most cases will involve some simple soldering (not always), an FTDI device (eg this one) which are usually just a few $, and using some tools such as the Arduino IDE or this guide shows how to use the Atom text editor and PlatformIO

Step 3: Get yourself an MQTT Server

Although not totally required (you can switch Tasmota devices on and off with various phone apps or via a web interface), MQTT is a standard and open way of getting home automation stuff talking together. There are actually commercial servers online that you can use too, but again, I prefer to keep it in house if you can so your devices aren’t talking across the insecure internet.

Think of an MQTT server as a box or database that all the devices talk to. You can make a switch that sets a field in the database to either on or off. This is not much use by itself, but imagine then you had a relay controlling your lights that was continually looking at this database field. When it saw ‘on’ it would change the relay and turn the lights on. Now imagine you can add another switch that does the same for two way control. And then an app on your phone that sets the same field so you can turn it on and off from bed. And now a sensor that detected how dark it was and set the field to ‘on’ automatically if it gets too dark. And now one that randomly changes the field every few hours when you were away on holiday. And… well you get the picture.

An MQTT server can be built on an always running PC or server that you have at home, but more simply on a Raspberry Pi.

Step 4: Set up some Control Software

Again, not totally needed as if you have a whole bunch of things talking back to and reading from MQTT you already have a functioning home automation system. But you don’t yet have a lot of “smarts”.

What if you (in the above example) wanted to turn the light on when it got dark, but only if you were home. And then maybe switch it off again 3 hours later. You need some “control software” to set up these automated tasks.

There are many types of home automation control software available. Some run on Windows, or Macs, but my two favourites are best to run again on an “always on” server… or again Raspberry Pi (even better, use the same one that the MQTT server is on). The couple I mostly recommend are:

Node Red

A Simple Node Red Function to set a floor or ceiling fan

Node Red is a great an easy to use way of making Home Automation ‘rules’ or smart functionality. Rules are created graphically with blocks that can be dragged and dropped. I often use it to create control rules before I put them in to something like Home Assistant below, but there is no reason not to use this as your main automation tool.

Home Assistant

Again, you can create complex rules and functions for your home automation and Home Assistant is more ‘script’ based with text files to allow you to do this. HA is useful if you have some (at least basic) programming experience, but the barrier to entry is reasonably low due to the vast numbers of ‘recipes’ already available in the community forums.

There is also no problem running multiple automation tools, I usually have both Node Red and Home Assistant running all the time.

Once scripts are created in Home Assistant, you can create displays and even room layouts

Step 5: Build some client devices

You can build a complex LCD touch display, or just have some switches, LED lights and knobs talking to the MQTT server

Finally, you really want a way for people to see information such as ‘what temperature the pool is’, or have some buttons knobs to ‘change the brightness of the home theatre lighting’.

This can be done with a combination of hardware (eg displays or knobs connected to controllers such as Sonoffs), or virtual buttons in a browser, phone app or wall mounted screens. All of these devices just query or input stuff live, from the MQTT database.

Some References:

Leave a Reply

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