declan bright

Arduino Home Automation

Control heating and lighting with an Arduino

Remotely controlling the lighting and heating in my house is something I have always wanted the ability to do. It's not very welcoming to come home after a weekend to a cold house. Leaving the heating on, even with a timer, is a waste as I don't always know what time I will arrive home. The ideal solution would be to remotely switch on the heating when I am about twenty minutes away from the house.

The Arduino is a flexible platform for building basic electronics projects. One of it's strengths is that there are numerous circuit boards which can be mounted onto the Arduino to extend its functionality.

The Ethernet Shield from nuelectronics.com is one of several boards which allow you to connect an Arduino to a network, using this setup to control some relays seemed like a good starting point.


WARNING: If you do not have experience working with mains electricity do NOT attempt this project.

Proof of Concept

Components for the initial proof of concept:

Arduino Diecimila Arduino Ethernet Shield Fotek Solid State Relay
Arduino Diecimila available from Maker Shed and other suppliers. Ethernet Shield V1.0 for Arduino available from nuelectronics.com Solid State Relays can be found on eBay, this FOTEK relay has a switched rating of 25-480VAC 25A and a control rating of 3-32VDC.

Home Automation - Proof of Concept Putting it altogether took less than 2 hours, I wired up a socket through a relay and plugged a desk lamp into the socket. Using the web switch sample code from nuelectronics.com made it very easy to get the Arduino onto my home network and once I wired the controller connection of the relay to the Arduino I was able to switch the light on and off from my PDA.

Modifying the Arduino Code

Before this could be connected up on a more permanent basis there were several things which needed to be added to Arduino code. I found a modified version of the Ethershield library with a better TCP/IP stack which was put together by Andy, full details here. Using this library I modified the following:

Arduino Hosted Web Page

The Arduino Diecimila with the ATmega168 microcontroller only has 1024 bytes of space to create and manipulate variables. With the help of PROGMEM, which is part of the pgmspace.h library, the strings for the web page are stored in flash memory instead.

Download

Dynamic DNS

Like most home internet users I don't have a static IP address so setting up a dynamic DNS is the next best option. Initially I wasn't sure how I could setup dynamic DNS for the Arduino, I had thought about programming the Arduino to periodically call a dynamic dns service itself. I had also read that some DSL routers can call a dynamic service but the admin pages of my router didn't give any clue that this could be done. After some searching I eventually discovered that my Netopia 2247 does indeed have a client for www.dyndns.com. It is only accessible via telnet and by following the instructions on page 262 of the Netopia Software User Guide V761 I got it up and running.

Putting it all together

One of the most difficult aspects of this type of project is wiring up the various components around the house. There are x10 units which use the existing electric wiring and there are several wireless solutions. Unfortunately these can also be quite expensive so I decided to keep things basic for this phase of the project, I wired up one socket to power a lamp or sound system and I wired up the heating system.

Fotek Relay Socket without cover Fotek Relay Socket For the socket I used an old plug-in timer which didn't work any more, having it as a plug-in unit gives me the flexibility to move it around a bit. Once I removed the original circuit board from the plug-in timer, I had to carve away some plastic so that the relay would fit in, I drilled a small hole in the top to feed in two controlling wires and then wired the mains live connection through the relay. It all fit back together and was ready to be connected up to the Arduino.

Vokera Boiler with Relay Connected For the heating system I bought 30 meters of bell wire and ran it from my office/study up into the attic, right across the attic, down the back wall, in through an air vent and finally into the gas boiler. I have a Vokera gas boiler and although it is quite old I found the Installation and Servicing Manual on their web site. This manual gave detailed instructions on how to connect up external controls for the boiler, these would usually be external timer switches or thermostats but connecting a relay would be no different.
There were some empty mounting holes inside the boiler control panel which conveniently lined up with the mounting holes of the relay. After connecting the relay to the boiler controller terminals and connecting the wire from the Arduino I did some testing before putting the boiler fuse back in, the LED on the relay let me know that it was working and once I put the fuse back in it all worked perfectly.

Using the system

I have been using this system much more than I thought I would. My initial plan was to use it to turn on/off a light when I was away from the house or to turn on the heating when I was on my way home. I actually use it most often when I am at home, I use it to turn on the heating for 10 or 20 minutes while I am working on my computer or if I am watching TV I use my phone to switch it on. Its really lazy and geeky but I still get a kick out of it!