You are on page 1of 14

Home Sign Up!

Browse Community Submit


All Art Craft Food Games Green Home Kids Life Music Offbeat Outdoors Pets Photo Ride Science Tech

Home automation server with router


by mrx23 on November 7, 2010 Table of Contents Home automation server with router . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Intro: Home automation server with router . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 1: Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 2: .................................................................................................................. 1 2 3 3 4 5 6 6 8 8 8 9

Step 3: Configure the Router . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 4: Setup the web page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 5: Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 6: More Technical Details . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Step 7: What is gained? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

File Downloads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 Related Instructables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

http://www.instructables.com/id/Home-automation-server-with-router/

Intro: Home automation server with router


Turn a cheap router into a home automation server! This project will allow you to switch outlets/lights from your iPhone, or any browser. You will also be able to send out serial commands remotely. This project is based on SmartLinc. http://www.smarthome.com/2412N/SmartLinc-INSTEON-Central-Controller/p.aspx http://wiki.smarthome.com/index.php?title=2412_Manual_rev_2.0 Components OpenWRT compatible router, with serial header AVR microcontroller Development Board (like Arduino) Actuators like: RF switched outlets (433.92Mhz) with a remote

http://www.instructables.com/id/Home-automation-server-with-router/

Step 1: Overview
The System The Router runs a web server, you access it via browser. After you push a button on the web page the router sends out a serial command, we process this with a microcontroller, the AVR converts it to RF protocol, injects it into the RF remote, which controls the RF outlets.

Image Notes 1. MCU board with AVR 2. RF remote

Step 2:
Buy a router, listed here:http://wiki.openwrt.org/toh/start I chose the TP-Link TL-WR741ND, because it is cheap (~$30). Disassembly it (this will void the warranty!). You will have to solder a serial header to the circuit board, to gain access to the serial port. The TL-WR741ND instructions can be found here: http://wiki.openwrt.org/toh/tp-link/tl-wr741nd For other routers, search here: http://wiki.openwrt.org/toh/start After finished soldering, manage the four cables out of the case, through the vent holes. I used a RJ22 plug at the end, for rapid connection.

http://www.instructables.com/id/Home-automation-server-with-router/

Image Notes 1. Serial 3V3 header

Image Notes 1. Nice case for AVR and RF remote :D 2. RJ22 connection 3. TP-Link TL-WR741ND Router 4. AC adapter for AVR & RF remote

Step 3: Configure the Router


Install the Linux based OpenWRT firmware on the router. The TL-WR741ND instructions can be found here: http://wiki.openwrt.org/toh/tp-link/tl-wr741nd If you are stuck, start here: http://openwrt.org After you have a working SSH connection you can proceed. Because of the router (by default) runs the web admin page on the port 80, we need to add a secondary port to serve our custom web site. For that, we need to configure the uhttpd (web server application) configuration file. Download WinSCP, to simply do this through SSH. http://winscp.net/download/winscp429.zip Set up a new connection: Host name: normally 192.168.1.1 (by default) Port: 22 User name: root Password: what you gave after installation File protocol: SCP Find this file: /etc/config/uhttpd Copy the following into it: config 'uhttpd' 'secondary' option 'listen_http' '81' option 'home' '/HomeAutomation/www' option 'cgi_prefix' '/cgi-bin' option 'script_timeout' '60' option 'network_timeout' '30' And save it.

http://www.instructables.com/id/Home-automation-server-with-router/

Step 4: Setup the web page


Upload the /HomeAutomation/ folder structure into the root directory. Set permissions for the script files located here: /HomeAutomation/www/cgi-bin Select all of them -> F9 Properties -> set the execution rights (X) for everyone (Owner, Group, Others) Close WinSCP, restart router (e.g. recycle power). Now the web server is ready. Try it out: Open up a web browser, type in: http://192.168.1.1:81 You should see your custom web page. If you press a button on the included web page, the router will send out serial commands through the previously attached serial cable. We need to intercept these commands and process them. For that purpose we need to build a microcontroller board (like Arduino). The included web site is very basic. If you make good CGI/AJAX based web sites please share it with us. How does the web site work When you click on a button, the browser loads a script file, the router executes the shell commands (serial outputs) located in each cgi file. The script file then redirects the browser back to the index page (takes about ~1sec). If you want to output custom serial commands, modify the .cgi files. Serial commands are sent out like this: echo -e "\x9B\x11\x08\x22\xC5\x0D" > /dev/ttyS0 (the \x modifier is used to output data in HEX instead of ASCII) Protocol detail I made this simple as possible. One package contains: Byte# 1. 2. 3. 4. 5. 6. Function: Synchronization (0x9B) Message type, use 0x00 or 0x01 for now (check firmware for details) Data1 Data2 Checksum (calculated from Byte#2-4) End character (, 0x0D)

http://www.instructables.com/id/Home-automation-server-with-router/

File Downloads

HomeAutomation web page.zip (1 KB) [NOTE: When saving, if you see .tmp as the file ext, rename it to 'HomeAutomation web page.zip']

Packet Generator.xls (17 KB) [NOTE: When saving, if you see .tmp as the file ext, rename it to 'Packet Generator.xls']

Step 5: Hardware
For me the Atmega88 (with internal 8Mhz oscillator) failed to run on 3V3 (supplied by the router), so I had to include an external power supply, with 5V. Because of that, we need to make a voltage conversion between the 5V MCU <-> 3V3 Router serial. This PSU also has a 12V rail for the RF remote control, so it can run without battery. Signal injection into RF remote controller You need to find your own remote control's data path, normally it is between the IC and the transistor (see image). Use a resistor for driving the transistor. Firmware Burn the firmware using: http://www.atmel.com/forms/software_download.asp?family_id=607&fn=dl_AvrStudio4Setup.exe http://sourceforge.net/projects/winavr/files/WinAVR/20100110/WinAVR-20100110-install.exe/download http://electronics-diy.com/avr_programmer.php MCU: ATMEGA88 Oscillator: internal 8Mhz Clear DIV8 fuse! Firmware included in zip file. You are more than welcome to share your improvements on the software.

http://www.instructables.com/id/Home-automation-server-with-router/

Image Notes 1. Buffer IC 2. RF remote 3. AVR 4. PSU

Image Notes 1. Address setup 2. TX IC 3. RF section 4. Tap in here to TX custom data

Image Not 1. TX IC in 2. RF sect 3. Data inp 4. TX indic 5. Nice wa

http://www.instructables.com/id/Home-automation-server-with-router/

Image Notes 1. RF protocol 2. RX IC

Image Notes 1. TX IC

File Downloads

MCU M88 int8Mhz.zip (36 KB) [NOTE: When saving, if you see .tmp as the file ext, rename it to 'MCU M88 int8Mhz.zip']

Remote Encoder HX2262.pdf ((612x792) 341 KB) [NOTE: When saving, if you see .tmp as the file ext, rename it to 'Remote Encoder HX2262.pdf']

Schematic.ms10 (162 KB) [NOTE: When saving, if you see .tmp as the file ext, rename it to 'Schematic.ms10']

Schematic.pdf ((595x842) 62 KB) [NOTE: When saving, if you see .tmp as the file ext, rename it to 'Schematic.pdf']

Step 6: More Technical Details


Commonly used ICs in the RF switched outlet and remote controls are: Remote Decoder PT2272.pdf Remote Encoder HX2262.pdf The RF protocol is included in these datasheets. The reaction time from pressing a button on the page to the serial output from the router is: iPhone & wifi: 1sec PC & LAN: instantaneous (~100mS) The delay can be decreased by using an AJAX based web page .

File Downloads

Remote Decoder PT2272.pdf ((612x792) 1 MB) [NOTE: When saving, if you see .tmp as the file ext, rename it to 'Remote Decoder PT2272.pdf']

Remote Encoder HX2262.pdf ((612x792) 341 KB) [NOTE: When saving, if you see .tmp as the file ext, rename it to 'Remote Encoder HX2262.pdf']

http://www.instructables.com/id/Home-automation-server-with-router/

Step 7: What is gained?


You get a linux based system, running your custom softwares 24/7 with a power consumption of only 4.5W. Connect an IP webcam, embed the video feed in web page Ability to send out custom serial commands to any external device. (be aware of the 3V3 serial voltage levels, I would strongly advise you to use CD40106 as a buffer) In this application you are able to send out any possible RF commands (based on the RF protocol) to the receivers. (i.e. no limitations on button numbers on the remote control) How stable is it? The system will not miss any commands, thanks to the TCP/IP Internet protocol and to the sophisticated microcontroller firmware. Further improvements: Tap into the switched outlet's RF receiver, add a MCU, detect data pattern, output IR code and you will get an Internet based remote controlled, remote control :D Write software for the router that can handle incoming serial data. YES you will be able to Twitt from your router (e.g. power consumption reports from external measuring devices). Or do old school things like SMS two way control, home alarm system, IR repeater (through web), scheduler program to automatically control things on time bases. Here is the original SmartLinc web page (it uses AJAX, and runs on AVR web server!) http://www.cocoontech.com/forums/index.php?autocom=downloads&showfile=71 This is a good way to start developing web pages. Don't forget to share what have you done with this project. Created by: Arpad Toth All rights reserved 2010 Some pictures are taken from other sites, I do not own all of it.

Image Notes 1. RF receiver 2. Relay 3. PSU cap 4. RX IC 5. RF Board

Image Notes 1. Address setup 2. RX IC 3. RF PSU Connector 4. Relay driver transistor 5. Relay

Image Notes

http://www.instructables.com/id/Home-automation-server-with-router/

1. RX IC 2. RF board

Image Notes 1. 433.92 Mhz RF board

http://www.instructables.com/id/Home-automation-server-with-router/

Image Notes 1. RF partion 2. Relay 3. Fuse 4. PSU cap 5. Address setup 6. RX IC

Image Not 1. 941N pr

http://www.instructables.com/id/Home-automation-server-with-router/

2. Home A 3. 3V3 Ser 4. AVR & R

Image Notes 1. iPhone browsing router's web page

File Downloads

SmartLinc web pages by xlurkr.zip (354 KB) [NOTE: When saving, if you see .tmp as the file ext, rename it to 'SmartLinc web pages by xlurkr.zip']

http://www.instructables.com/id/Home-automation-server-with-router/

Related Instructables

Cheap touchpad. by Computothought

Sheevaplug + Python Daemon + MySQL = RS232 Logging Made Easy by jimk3038

A Media Center solution even the wife and kids will use. by Hextor

Play AdSupported iPhone Games without Ads by hjfast

Reuses for legacy computers. (Photos) by Computothought

Temperature sensor / weatherstation by chr

Comments
19 comments Add Comment

skeegan says:

Dec 2, 2010. 8:24 AM REPLY Hi mrx23, This project is great- I think it could be really useful for me. I have a couple of questions regarding the schematic (please forgive my electronic ignorance:). Schematic attached-would be great if you could offer some insight. S

mrx23 says:

Dec 4, 2010. 3:00 PM REPLY hi, - 1st 2 arrows: Schmitt trigger inverters, in one package you get 6 of them, the last 2 of them are unused (so they had to be terminated properly) - the PSU nets are only connected logically, in the schematic - the last one is an LED I wouldn't recommend this project for beginners, first you should learn the basics on an Arduino. Cheers,

madmax2003 says:

Nov 14, 2010. 9:10 AM REPLY Why didn't you use an arduino with Ethernet shield? In my opinion its easier than the Serial Communication between Router and arduino. What do you think? Greets max

mrx23 says:
Hi, using a router as an embedded system has a lot of advantages: for ~$30 you get: - ~17MB of free user flash space (that's a lot) - LAN PHY, no need to get magnetics, no soldering involved - Sweet case, SMPS PSU - Wifi -> can't beat this with AVR :D - Linux OS, the possibilities are endless - upload new web pages via SSH anytime - No hassle with IP stack - 400 Mhz CPU - Possible USB 1.1/2.0 support - Pre-installed web server app You will save insane amount of time, if you choose this route. Serial communication was very easy, it's a state machine in C, built in one day. Lets compare this to the widely used Arduino: Arduino Eth Shield $40 Arduino $30 -> flash space for web pages <<1MB + PSU + CASE + Time^2... It's an easy choice.

Nov 15, 2010. 3:29 PM REPLY

http://www.instructables.com/id/Home-automation-server-with-router/

mrx23 says:

Nov 11, 2010. 2:46 AM REPLY I'm not familiar with the X10 prices, but these RF switched outlets cost about $8 each. X10 products unfortunately are not available in our country. You can make this system much safer, if you protect your home network with WPA2.

an4rchyy says:

Nov 13, 2010. 11:48 AM REPLY Would you be able to link a page for the outlets you used? I was unable to find switched outlets for 8$ and it would be great to get them that cheaply

mrx23 says:
3 for $25

Nov 13, 2010. 12:36 PM REPLY

http://www.amazon.com/Stanley-31164-Wireless-Control-Transmitter/dp/B0020ML762/ref=sr_1_5?s=hi&ie=UTF8&qid=1289680424&sr=1-5

an4rchyy says:
Thank you very much! This will be a great help along with your instructable

Nov 13, 2010. 2:39 PM REPLY

kal00 says:
I think X10 would be much cheaper since you skip the "Avr, RF, RF Remote" part.

Nov 10, 2010. 1:22 PM REPLY

rocco says:

Nov 13, 2010. 2:14 AM REPLY X10 is only cheaper if you exclude the feature that costs the most - the web based control of power outlets/switches... so, that's not really a fair comparison.

yoda112 says:

Nov 12, 2010. 1:39 AM REPLY Nice projet. I would like to use the same router. What version of the router did you use? And what version of openwrt? Do you have any problems with openwrt? Thank you.

mrx23 says:

Nov 12, 2010. 1:48 AM REPLY I used v1.9 HW, this might be the latest you can get in shops. For this device I downloaded this firmware: http://downloads.x-wrt.org/xwrt/kamikaze/snapshots/ar71xx/default/openwrt-ar71xx-generic-tl-wr741nd-v1-squashfs-factory.bin Openwrt runs perfectly, it's very stable.

dbzoo says:

Nov 11, 2010. 5:23 PM REPLY Yeah not a bad effort I did something similar with an old ADSL router - see the Home Automation Hub project. http://www.dbzoo.com/livebox/livebox

mrx23 says:
Nice work!

Nov 12, 2010. 1:44 AM REPLY

yoghurtsniffer says:

Nov 11, 2010. 3:18 AM REPLY Hi, Nice project. I am planning on doing something very similar very soon if time permits. But from scratch. I have some ideas on some protocols i can use with some of the Arduino stuff. Thanks for your ible :D

Computothought says:
Liked the web page. I may borrow it.

Nov 10, 2010. 5:37 PM REPLY

nfarrow says:

Nov 10, 2010. 11:57 AM REPLY If you had some kind of security on your router you could plug the, "RF switched outlet" to an automated door opener/gate and only give the security key & web address to only people you want over.

nfarrow says:
I had that phone at one time LOL

Nov 10, 2010. 11:41 AM REPLY

joejoerowley says:
Very very cool! You could even port forward the router and allow remote control from outside your wifi network! Nice project!

Nov 7, 2010. 11:04 AM REPLY

http://www.instructables.com/id/Home-automation-server-with-router/

You might also like