Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Table of Contents
Step 6: Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Step 9: Controlling from the internet method 3 (using a script)(even from my phone) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
http://www.instructables.com/id/Arduino-Home-automation/
Intro: Arduino Home automation
This is a relatively simple controller for controlling equipment in your home.
I am also able to login remotely from the internet to control the equipment at home connected to this controller.
http://www.arduino.cc/
The arduino board is a hardware interface allowing you to control and monitor hardware devices with your computer.
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.
Image Notes
1. digital pins needed
2. usb
3. power pins if used
Tools
Soldering iron
Solder
Cutters
http://www.instructables.com/id/Arduino-Home-automation/
Image Notes
1. digital pins needed
2. usb
3. power pins if used
http://www.instructables.com/id/Arduino-Home-automation/
Image Notes
1. the left hand buttons switch the modules on the right hand buttons switch the
modules off
Image Notes
1. the remote controlled modules
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.
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
http://www.instructables.com/id/Arduino-Home-automation/
Image Notes
1. the arduion board
2. the resistors to limit the current and the led's to show which channel is being driven
3. the opto isolator to activate the remote control and also to keep the remote control isolated from the circuit board
4. the remote control the left hand rail is for all on switches. the right hand rail is for all off switches. and the center common terminals for buttons 1 to 4
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.
http://www.instructables.com/id/Arduino-Home-automation/
Step 4: Modifying the remote control
I unscrewed the screw under the rear label. And carefully prised open the case.
Image Notes
1. wires for the led
2. the link to replace the switch
3. the cable to the PCB
4. power cable
http://www.instructables.com/id/Arduino-Home-automation/
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.
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
void loop() {
if( Serial.available() ) // if data is available to read
{;}
val = Serial.read(); // read it and store it in 'val'
{
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
{
http://www.instructables.com/id/Arduino-Home-automation/
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.)
http://www.instructables.com/id/Arduino-Home-automation/
Image Notes
1. the arduino board you can see the board is connected and powered
2. the PCB you can see led 1 in active.
3. the remote control you can see the remote is transmitting
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.
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.
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.
http://www.instructables.com/id/Arduino-Home-automation/
When logged in
You can find out which device the arduino board is, by typing this command.
ls /dev/tty*
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.
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
Image Notes
1. the command to open the tty terminal device USB0 baud rate 9600
Image Notes
1. this is a list of tty serial devices. this is the one you are looking for
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 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.
http://www.instructables.com/id/Arduino-Home-automation/
so now it can all be controlled from my phone
#!/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
http://www.instructables.com/id/Arduino-Home-automation/
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.
http://www.instructables.com/id/Arduino-Home-automation/
Related Instructables
Cheap
$10 Smart Home Digital Name
touchpad. by
System by Plate (video) by
Home Web Controlled Computothought Create the
inkwash kunal_djscoe
automation Arduino LED by Arduino driven
server with tamberg LED growbox by
router by mrx23 cpo
Comments
25 comments Add Comment
i seriously need to add some flat cables to my next project...its works but it looks very ugly ^^'
The main differences are that my project uses the ethernet shield and is controllable via some custom software on my mobile phone over the internet
Plus that I use a 433Mhz AM transmitter and a library I created by researching other peoples work that reverse-engineered the protocol.
I can transmit the code for the old simple protocol(sockets have dial on back) and the advanced protocol (socket have small button on front). So i can
actually control millions of sockets all from 1 pin on my arduino.
I have timers for turning on and off electric heating, water and even my electric blanket on my bed , plus I have an output for controlling my electric door lock
so I can actually let in a friend when I'm not there if they call me.
Code is getting rather big now as I keep adding things and might have to upgrade to a mega just for the extra space :p
Who knew such a small device could take up most of my free time. ( I own 2 and probably more soon).
With regards to your own project, great work and if ya want to upgrade your project to using a dedicated 433Mhz transmitter, just give me a shout and can
send you my library with instruction on how to use it.
is this correct?
http://www.instructables.com/id/Arduino-Home-automation/
killersquirel11 says: Jan 23, 2010. 8:55 AM REPLY
Technically, no, but it will work since its just the comments that are screwed up. Should read
if( val == 'B' ) // if 'B ' was received
if( val == '9' ) // if '9 ' was received
if( val == '0' ) // if '0 ' was received
but the code will still compile the same either way
http://www.instructables.com/id/Arduino-Home-automation/
simon72post says: May 5, 2009. 11:21 AM REPLY
I just used an old box I had laying around. I think it came from maplins originally
http://www.instructables.com/id/Arduino-Home-automation/