Introduction: Arduino Home Automation

This is a relatively simple controller for controlling equipment in your home.

At the moment I control my central heating, security and lighting.
By sending commands from my home computer.

My homeeasy central heating controller hack.
https://www.instructables.com/id/BampQ_homeeasy_home_automation_central_heating_c/

I am also able to login remotely from the internet to control the equipment at home connected to this controller.

This project is built around an Arduino board.

http://www.arduino.cc/

The arduino board is a hardware interface allowing you to control and monitor hardware devices with your computer.

And the homeeasy home automation controllers available from B&Q.

http://www.homeeasy.eu/home.php

These are basically plug-in module which allows you to switch devices on and off using a remote control.

The idea behind this project was. I wanted to be able to login to my home computer and send commands that would allow me to turn lights on remotely.
Or have the computer do it automatically at a set time or when it gets dark.

Step 1: Parts Needed

1 arduino board.
1 homeeasy controller - part number HE300
1 prototype board - Vero board
10 resistors - 47 ohm
10 led's
4 opto isolators - RS part 308-613
Some ribbon cable.
a strip of pins to connect to the headers on the arduino board.
1 box - to put it all in.
some HE302S - remote control socket


Tools

Soldering iron
Solder
Cutters

Step 2: Basic Principle

Hardware

Basically the arduino board when programmed will switch the digital outputs high.
Which will send 5 volts through the resistor and light the led's.
Which will activate the opto isolator which will connect the contacts on the remote control.
which will send the comand to the remote control sockets
And turn on or off the lights, heating or anything you want.

this circuit shown is for the first on and off switches.
just repeat the circuit for the following channels

software

I programed the software so when I pressed (H) in the terminal the arduino board will send a 1 second pulse to my remote control and switch my heating on.
when I press(h) the board will send a 1 second pulse my heating switches off.
(S) for security on
(s) for security off
(G) garden lights on
(g) garden lights off

and so on this can be changed to any button you want

Step 3: Building the Board

The board I built on some prototype project board available from most electronic stores.

It was just a matter of soldering on the components as show in the circuit diagram.
And making sure there were no short circuits.

the first led connects to pin 1 on the opto isolator, led 2 connects to pin 4 on the opto isolator.
pins 2 and 3 are then connected to ground. which is next to digital pin 13 on the arduino board.

opto isolator pins 6 and 7 are connected together and go to the center contact on the remote control for the first on off buttons.
opto isolator pin 8 goes to the left track on the remote.
pin 5 goes to the right track on the remote.

and then it's just a matter of repeating the circuit for the other channels.







Step 4: Modifying the Remote Control

I unscrewed the screw under the rear label. And carefully prised open the case.

When open you will see the PCB.
On the PCB there is one track on the left which when connected to the centre contacts will switch devices on.
And there is a track on the right which when connected to the centre contacts will switch equipment off.

I just attached the contacts to my circuit as shown in my diagram.

and soldered on a link in place of the remote switch.

Next I attached the battery to the 3v output on the arduino board.
You don't have to do this. But I did it so I wouldn't need a battery in the remote control.

Step 5: The Software

the arduino board is controlled from it's own software this can be downloaded from here.
http://www.arduino.cc/en/Main/Software

you can then copy and paste this code in to the arduino software and upload it to the board.

char val; // variable to receive data from the serial port
int ledpin = 2; // LED connected to pin 2 (on-board LED)

void setup()
{
pinMode(ledpin = 2, OUTPUT); // pin 2 (on-board LED) as OUTPUT
pinMode(ledpin = 3, OUTPUT); // pin 3 (on-board LED) as OUTPUT
pinMode(ledpin = 4, OUTPUT); // pin 4 (on-board LED) as OUTPUT
pinMode(ledpin = 5, OUTPUT); // pin 5 (on-board LED) as OUTPUT
pinMode(ledpin = 6, OUTPUT); // pin 6 (on-board LED) as OUTPUT
pinMode(ledpin = 7, OUTPUT); // pin 7 (on-board LED) as OUTPUT
pinMode(ledpin = 8, OUTPUT); // pin 8 (on-board LED) as OUTPUT
pinMode(ledpin = 9, OUTPUT); // pin 9 (on-board LED) as OUTPUT
pinMode(ledpin = 10, OUTPUT); // pin 9 (on-board LED) as OUTPUT
pinMode(ledpin = 11, OUTPUT); // pin 9 (on-board LED) as OUTPUT

Serial.begin(9600); // start serial communication at 9600bps

}

void loop() {
if( Serial.available() ) // if data is available to read
{;}
val = Serial.read(); // read it and store it in 'val'

if( val == 'h' ) // if '2' was received

{
digitalWrite(ledpin = 2, HIGH); // turn ON the LED
delay(1000); // waits for a second
Serial.println("h = Heating off");
digitalWrite(ledpin, LOW); // sets the LED off

}
if( val == 'H' ) // if '3' was received
{
digitalWrite(ledpin = 3, HIGH); // turn ON the LED
delay(1000); // waits for a second
Serial.println("H = Heating on");
digitalWrite(ledpin, LOW); // sets the LED off
}
if( val == 's' ) // if '4' was received
{
digitalWrite(ledpin = 4, HIGH); // turn ON the LED
delay(1000); // waits for a second
Serial.println("s = gate off");
digitalWrite(ledpin, LOW); // sets the LED off
}
if( val == 'S' ) // if '5' was received
{
digitalWrite(ledpin = 5, HIGH); // turn ON the LED
delay(1000); // waits for a second
Serial.println("S = gate on");
digitalWrite(ledpin, LOW); // sets the LED off
}
if( val == 'g' ) // if '6' was received
{
digitalWrite(ledpin = 6, HIGH); // turn ON the LED
delay(1000); // waits for a second
Serial.println("g = Garden lights off");
digitalWrite(ledpin, LOW); // sets the LED off
}
if( val == 'G' ) // if '7' was received
{
digitalWrite(ledpin = 7, HIGH); // turn ON the LED
delay(1000); // waits for a second
Serial.println("G = Garden lights on");
digitalWrite(ledpin, LOW); // sets the LED off
}
if( val == 'b' ) // if '8' was received
{
digitalWrite(ledpin = 8, HIGH); // turn ON the LED
delay(1000); // waits for a second
Serial.println("b = Bedroom light off");
digitalWrite(ledpin, LOW); // sets the LED off
}
if( val == 'B' ) // if '9' was received
{
digitalWrite(ledpin = 9, HIGH); // turn ON the LED
delay(1000); // waits for a second
Serial.println("B = Bedroom light on");
digitalWrite(ledpin, LOW); // sets the LED off
}
if( val == '9' ) // if '9' was received
{
digitalWrite(ledpin = 10, HIGH); // turn ON the LED
delay(1000); // waits for a second
Serial.println("9");
digitalWrite(ledpin, LOW); // sets the LED off
}
if( val == '0' ) // if '9' was received
{
digitalWrite(ledpin = 11, HIGH); // turn ON the LED
delay(1000); // waits for a second
Serial.println("0");
digitalWrite(ledpin, LOW); // sets the LED off
}

}

Step 6: Testing

After I had set up the homeeasy module to respond to the remote.
(You can find out how to do this in the instructions for the modules.)

I loaded the software on to the arduino board.
And ran the command (H)

And my heating switches on.
I tested the other commands for the lights and security and they all responded as planned.

Step 7: Final Assembly

the last job was to fix all the boards in a plastic box and made a hole for the USB to plug in to the arduino board.

You may find when the boards are in the box the range at which they work is shortened.
If this happens you can mount the remote antenna on the out side of the box as I have done this to solved the problem I had with range. But you will have to keep the leads short or they will effect the frequency at which the antena transmits at.

Step 8: Controlling Remotely From the Internet Method 1 and 2

The computer I have connected to the arduino board is running Linux ubuntu.
But this board will work with windows, mac and Linux.

I have 3 ways of remotely controlling the board from the internet at the moment.

The first way will work with any computer. And that is using VNC to remotely login and control the board from the desktop. There are other software alternatives to remotely login.

Such as windows remote desktop.

And log me in https://secure.logmein.com/home.asp?lang=en

The second way which I use most of the time because of security.

Is to login using the Linux SSH terminal from windows using a program called putty.

you can also you do it this way using a mac.

When logged in

You can find out which device the arduino board is, by typing this command.

ls /dev/tty*

You should get a screen like this.

My device is USB0 but this can be different.

Then you can send the command.

screen /dev/ttyUSB0 9600

to open the tty terminal.

When the tty terminal is open you can then type the command to turn the device on or off. I.e. G or g for garden lights.

And that is about it.

if you have any problems here are some more usefull commands.
these comands will show you which tty services are running.
ps -lt ttyUSB0
ps ax | grep tty

this command will stop the service running.
kill (job number)

Step 9: Controlling From the Internet Method 3 (using a Script)(even From My Phone)

This is a new update I have just set up to alow me to control the arduino board from any web browser.

I wanted to control my home automation from my phone but this was not very easy using VNC or SSH.

So installed webmin on my server this will give me full control of the machine from within a web browers.

In web min there is a page called command shell that will allow me to run commands from the web browser.

I original tried to run the comands I was using in the SSH terminal. but they didn't work in webmin.

So with help from my brother we wrote a script.

so now all I have to do is send a command like "home_auto h1" and the heating will switch on. or "home_auto h0" to switch the heating off.

so now it can all be controlled from my phone

here is a copy of the script.


#!/bin/bash

_usage () {
echo "gl1 it will run this comand echo G > /dev/ttyUSB0 9600 and turn my garden lights on"
echo "gl0 it will run this comand echo g > /dev/ttyUSB0 9600 and turn my garden lights off"
echo "s1 it will run this comand echo S > /dev/ttyUSB0 9600 and turn my gates on"
echo "s0 it will run this comand echo s > /dev/ttyUSB0 9600 and turn my gates off"
echo "h1 it will run this comand echo H > /dev/ttyUSB0 9600 and turn my heating on"
echo "h0 it will run this comand echo h > /dev/ttyUSB0 9600 and turn my heating off"
echo "b21 it will run this comand echo B > /dev/ttyUSB0 9600 and turn my bedroom 2 lights on"
echo "b20 it will run this comand echo b > /dev/ttyUSB0 9600 and turn my bedroom 2 lights off"
echo "N it will run this comand echo N > /dev/ttyUSB0 9600 and turn next bank of outputs on for 5 seconds"
echo "R it will run this comand echo R > /dev/ttyUSB0 9600 and turn the Relay on"
echo "r it will run this comand echo r > /dev/ttyUSB0 9600 and turn the Relay off"

}

case "$1" in

gl1)
#garden lights on
/bin/echo G > /dev/ttyUSB0 9600 && echo "Lights On"
;;

gl0)
#garden lights off
/bin/echo g > /dev/ttyUSB0 9600 && echo "Lights Off"
;;

s1)
# gates on
/bin/echo S > /dev/ttyUSB0 9600 && echo "Gates On"
;;

s0)
# gates off
/bin/echo s > /dev/ttyUSB0 9600 && echo "Gates Off"
;;

h1)
#heating on
/bin/echo H > /dev/ttyUSB0 9600 && echo "Heating on"
;;

h0)
# heating off
/bin/echo h > /dev/ttyUSB0 9600 && echo "Heating Off"
;;

b21)
# bedroom 2 lights on
/bin/echo B > /dev/ttyUSB0 9600 && echo "Bedroom 2 Lights On"
;;

b20)
#bedroom 2 lights off
/bin/echo b > /dev/ttyUSB0 9600 && echo "Bedroom 2 Lights Off"
;;

N)
#Next Bank on
/bin/echo N > /dev/ttyUSB0 9600 && echo "Next Bank on for 5 seconds"
;;

R)
#Relay on
/bin/echo R > /dev/ttyUSB0 9600 && echo "Relay on"
;;

r)
#Relay off
/bin/echo r > /dev/ttyUSB0 9600 && echo "Relay off"
;;

*)
#echo $0 ": Not a valid command";
echo "Please retype command";
_usage;
;;

esac


Step 10: Updates and Upgrades

Update

I have now added the option of switching to the next set of button. It was just a matter of wiring in a spdt relay.

so when the relay is off the first bank of buttons are selected.

and when the relay is energised the second bank of buttons are selected.

I have also added a second relay incase I want to conect anything up in the future.

Step 11: Future Upgrades

I am now in the process of connecting light and tempiture sensors to the arduino board.
which can help automate devices.