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.
• OpenWRT compatible router, with serial header
• AVR microcontroller Development Board (like Arduino)
• Actuators like: RF switched outlets (433.92Mhz) with a remote
Step 1: Overview
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.
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.
Step 3: Configure the Router
The TL-WR741ND instructions can be found here:
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.
Set up a new connection:
Host name: normally 192.168.1.1 (by default)
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.
Step 4: Setup the web page
Set permissions for the script files located here:
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)
I made this simple as possible. One package contains:
1. Synchronization (0x9B)
2. Message type, use 0x00 or 0x01 for now (check firmware for details)
5. Checksum (calculated from Byte#2-4)
6. End character (
Step 5: Hardware
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.
Burn the firmware using:
Oscillator: internal 8Mhz
Clear DIV8 fuse!
Firmware included in zip file. You are more than welcome to share your improvements on the software.
Step 6: More Technical Details
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 .
Step 7: What is gained?
• 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.
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!)
This is a good way to start developing web pages.
Don't forget to share what have you done with this project.
All rights reserved
Some pictures are taken from other sites, I do not own all of it.
Thanks for reading.