Picture of 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.

• 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

Picture of 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.
1-40 of 67Next »
mrx23dot (author) 3 years ago
Check out my latest project:
javierbrath made it!10 months ago

javierbrath made it!10 months ago

i made with arduino nano,

This week I sent the entire link , it will be quite graphic as it is written in Spanish

javierbrath10 months ago
SashaS210 months ago

Thank you for sharing this amazing project!

I can program Ajax based web sites. Plus I'm also a HTML5 mobile User Experience designer & programmer. I'm going to do the project and come up with a cool app like web page. Keep you posted!
mrx23dot (author)  WeekendEngineer1 year ago
Sounds great!
Here is one companies webpage collection running on embedded server (like linux routers), I think it uses ajax. It can be reused.
Need to keep it small and fast, because it runs on ~200Mhz.
engcu903 years ago
Great project!
I am doing it, but I have a problem that hex data is not received correctly.
First I tried to send from the router to my PC via:

echo -e "\x9B\x11\x08\x22\xC5\x0D" > /dev/ttyS0

I received: 0x9B 0x11 0x08 0x22 0xC5 0x0D 0x0D 0x0A
I receive 2 bytes in excess and I don't know why!

Then I tried to send from the router to pic, then from pic to my PC to check the received data, I get only 6 bytes but all wrong, not the data I sent.

I am using pic18f452 as I didn't use avr before..
I think the problem is the interface circuit..I used shmitt trigger, res, cap as you did but it doesn't work. Is this circuit need to be modified to be suitable for PIC?
mrx23dot (author)  engcu903 years ago

I also had some hard time with the router's serial port, because it uses weird voltage levels like ~1.8V in idle.
I pulled up the TX line (from the router) to 3V3 (from Vdivider+Cap), you should fed this into two inverters (powered from 3v3). Measure this output in idle state, it should read 3-3,3V.

3V3 TX line should be enough for any kind of 5V MCUs.

For proper communication with the PC you need 3V3 TTL - RS232 converter,
for 5V converters you could use a second voltage shifter on the TX line.
And always use pull ups on the inputs. I'm guessing you got those extra bytes because of noise (generated by weak or omitted pull ups or low voltage levels on the converter). An oscilloscope would be very handy in these situations.

You can debug your PIC's FW by sending out the data from the PC to PIC. The baud is 115200 8N1

I can recommend this adapter, it works on 3V3 and 5V at any speed:
Thank you very much. The inverter solved the problem =)
I used the same cct in your schematic, but replaced smhitt trigger with 2 inverters
For excess bytes, it was CR & LF characters. echo -n solved this.
But when I send data from the PIC to the Router, How can I receive the data in index page for example?

mrx23dot (author)  engcu903 years ago
Sorry, I forgot that I used commands like this:
echo -e -n "\x9B\x21\x01\x21\xBD\x0D" > /dev/ttyS0

I haven't done any two way communications yet.
But it should work like on a desktop PC:


Check out the Cron scheduling service on the router, it can run commands on timely bases. Or run scripts like this:
run every 4min:
if ping google fails -> reset modem's switchable socket.

Or turn on sprinkler/Christmas lights at a given time.
Really appreciate your help..I have successful two way communications :)

I have inquiry about ADSL Modem and the Router connection. I have modem & router in one device TD-W8901G with default ip and router wr741nd default ip
I must connect cable from router to my PC to be able to acess
Can I access this page without the need for the cable? My PC is connected to the internet via wireless from TD-W8901G, in another words,, when I type in my browser, the ADSL modem forward to the port where the router is connected to.
Also I want the web page be public over the internet.
Same manner,The ADSL has real ip, for example I want when some one enter in his browser, my ADSL modem forward this to the port where the router is connected to, then the router forward to port 81, web page.
Is there a tutorial about how to do that?
Hope my question is clear enough! :)
mrx23dot (author)  engcu903 years ago
Can you describe the serial reception, or attach the program?
For network setup refer to the image.
Thank you for your help mrx23dot :)
For serial reception, I used only voltage divider at Rx of the router to make 5v --> 3.3v
And used command cat for reception, default baud rate 115200. I tried to send ASCII characters and received successfully. When I finish reception of HEX Data, I will attach the full program.
hey can you post the full program you used? I still can't receive anything with RX pin on the router :(
would be much appreciated, thank you for your time :)
- It is better to us Micro-controller that operates on 3.3v (like PIC18F452), so you will connect the Router and Controller directly without any additional circuits between them,i.e..Connect Router Tx pin to Controller Rx pin and vice versa.
- By default the serial port of the router is occupied by the console. So it can’t be used for other uses. To free the serial port: open /etc/inittab and remove the last line of the serial port ttyS0:
ttyS0::askfirst:/bin/ash --login
- To send/receive you should config the serial port first on the router:
stty -F /dev/ttyS0 115200 cread cs8 -parenb -cstopb sane -echo -echok -icrnl -ixon -icanon -opost -onlcr time 1 min 0
- To send data from router to controller: echo -e -n "\x9B\xA1\x02\xA3\x0D" > /dev/ttyS0
- To receive data: x="$(cat /dev/ttyS0)"

Hope this help! :)
Thanks alot alot alot, seriously thanks,
Really appreciate it. :)
Hello Sir,
I am still confused with this setup. May you clear the steps please?
How to enable DHCP client?
How to get router's mac address?
mrx23dot (author)  engcu903 years ago
For all your questions here is the documentation:
Hello mrx23dot,

This is what I did for serial reception

First, I used voltage supply 3.3v to my PIC18F452 instead of 5v, and then connected the PIC and the Router directly without the need for inverters, shmitt trigger, ... etc

For reception to the router:
The firmware needs to be upgraded to add packages: coreutils, setserial, using commands opkg install/update

Then to receive data I used:

stty -F /dev/ttyS0 115200 cs8 -parenb ....
#there are many parmaeters to be set according devices specs

cat /dev/ttyS0 >> a.txt
#read data and save it a.txt file

setserial -a /dev/ttyS0 >> is used to check that the device is configured properly

cpatchava2 years ago
Hey I have the newer version of the router and i was trying to find the Find this file: /etc/config/uhttpd in the latest version i installed from the wrp website but i couldnt find it. Any ideas on where else to look for that?
D_Ghost012 years ago
hello, i would really appreciate it if you could send me the arduino code. i have seen a link where you posted this before (2012) its a zip file and i dont understand its contents. what are all those files and where is the actual arduino code. thanks
mrx23dot (author)  D_Ghost012 years ago
hi, it is for gcc compiler not, arduino.
nolte9192 years ago
I'm having trouble getting the web page/script files to send anything out of the serial port. The serial port is definitely working, I see tons of stuff when I first power on the router and I can send commands and see the output through the serial port using my computer. I can also see the webpage when I connect through my LAN (or over the internet) but when I click on either of the two giant buttons nothing comes out of the serial port. I used WinSCP to set executable permission for everyone (all three) on both script files. Any idea what my problem might be?
mrx23dot (author)  nolte9192 years ago
SSH into the router (w/ Puttty). Try to send out serial data with one line commands. If that works copy its structure into the script.
Check for warnings. Also check your serial port address.
My Linux skills are almost nonexistent but after some Googling I figured out that I needed to change the ttyS0 to ttyATH0 and the double quotes to single.
cmorisco3 years ago
Hello mex 23dot error
Command 'cd "/etc/config"'
failed with return code 0 and error message
-ash: groups: not found.
thank you
cmorisco3 years ago
hello mrx23dot this project works with a visual basic
instead of using ipod 192.168.200
prince4e3 years ago
Thanks for making this DIY guide. I am almost there but I am little confused about Remote encoder and decoder. Well to be frank I am lost. And what if I have to use 2 RF control outlet. Can I buy same products and use one remote to control both outlet or what should I do?? I am stuck at the last step so any help would be appreciated...
mrx23dot (author)  prince4e3 years ago
All outlets must use the same protocol (buy from the same brand).
The protocol has addressing in it so you can control a lot of devices.
And what if I want to make my own RF control outlet and remote do you have the schematics?? Can it be done?? Thanks for your help. I really appreciate what you are doing?
mrx23dot (author)  prince4e3 years ago
Schematics can be found in the datasheets, check the instruction, but there is no point making on you own when it's dirt cheap.
sneaksneak3 years ago
Hello, very nice project.
How aboute the software code for the arduino? Can you upload it?
mrx23dot (author)  sneaksneak3 years ago
jfurcean3 years ago
I just finished a similar project, but I used a laptop instead of a router. I am getting ready to use a OpenWrt router to try and make the overall cost of the project cheaper. I also set it up using an X-10 interface module. This allowed me to configure any number of modules to control.

mrx23dot (author)  jfurcean3 years ago
Thanks, it looks great.
cryphakon3 years ago
How would add more buttons to the webpage to control separate outlets?
mojunwei3 years ago
hi mrx23dot

i am stucked in this
more detail about
mrx23dot (author)  mojunwei3 years ago
Configure the httpd according to the article.
First start with a simple html file, then move on to the cgis.
Also the debug the serial connection by SSHing into the router and manually give out commands.
mojunwei3 years ago
and more detail about MPFS2?

your help will be appreciated! thankx
1-40 of 67Next »