Introduction: Smart Home Automation Webserver on OpenWRT Router WR703N Interfaced to Arduino, Compared to Raspberry Pi and Ubuntu
Download the WR703N Digest (150MB zip file):
https://sourceforge.net/projects/wr703n/
------------------------------------------------------------------------------------------------
Dear Reader,
there are many Linux boards on the market: Bifferboard, NanosG20, Foxboard, Beagleboard, AlixPC, Android phones and tablets, routers, netbooks, and most popular is the Raspberry Pi. How to decide what to choose?
A nice solution is a small pocket router TP Link WR703N.
(Unfortunately WR703N is out of production and the closest replacement is MR3020 and WR710N).
Price 25 USD, nice looking 5x5x2 cm plastic box, internal Wifi, USB port. Can be ordered on Ebay, shipping is free and it arrives from HongKong in a month. This router has a 400 MHz CPU, 4 MB flash (quite small), 32 MB RAM, 1 Ethernet, Wifi, 1 USB, 0.5 W power consumption. Powered via the USB cable. Included power supply can be plugged into 110V or 220V.
It must be reflashed with OpenWRT Linux, where most necessary program modules exist, however, not everything is compatible with Debian Linux. Can add USB hub, USB stick, USB HDD, USB sound card, bluetooth, webcam, 3G modem, 1-wire USB or serial module, connect to Arduino, set up Wifi client, place home webserver with php and rrdtool database on router. With the help of Arduino USB connection can read out sensors, electricity or gas meters, control robotics.
Limitations are that internal flash 8 MB is quite small, but can be extended using external USB flash stick or HDD. Compiling C code is not possible directly on router. Need to cross compile and after an hour of compilation there is a chance that the executable might not work.
Experience also that router's flash gets tired and a fatal error emerges in 3 months, if saving is done into flash once in 5 min (~100 000 cycles). If need to save frequently should save into RAM or USB HDD and only once and while backup on flash.
All small-scale hardware has some bugs. Not all things work as supposed, for example, Wifi client configuration might not work using Luci configuration interface, need to manually edit config files. Usually need to spend one day to work around some particular bug.OpenWRT trunk changes every day and often new bugs appear. So I have made a backup of somewhat older, but stable version on my PC. Experience with the recent OpenWRT version Attitude Adjustment Beta 12.09 was OK.
Due to large size of materials about WR703N programming I had to place files on Sourceforge.
Please download the zip file (150 MB) containing information about setting up different functions on WR703N:
https://sourceforge.net/projects/wr703n/
00 Introduction links
01 Flashing OpenWRT, vi, nano
02 Open WR703N cover & solder serial RX TX CP2102
02 Network
02 USB Hub
03 USB flash, HDD, system overlay
04 curl, lftp, samba, NAS, Dropbox, Twitter
04 uhttpd and lighttpd webserer with php5
05 Webcam, video
06 Bluetooth
06 Mouse, keyboard, PIR, photodiode
06 Sound card
07 GPIO, hardware schematics, 1wire, i2c, SPI
08 Digitemp 1wire temperature with CP2102
09 DS9490R 1wire bus adapter
10 Arduino sensors via USB
11 Graphing dataplots Pachube, rrdtool, Google charts, Sarmalink
12 Gmail control of USB relay board
13 sending email
14 compile your own OpenWRT distribution
15 compile C program module
16 Python install on USB HDD
17 Lua programming language for Luci
18 uci
20 Robotics WiFi remote controlled car
70 Nice Webpage designs
80 Example WR703N setups
90 Smart home, alarms, baby monitor
91 Long term reliability
92 LinkDuino customization by Squonk
93 mr3020 similar to wr703n
------------------------------------------------------------------------------------------------
Raspbery Pi
Much advertisized in press as the cheapest, but it is a circuit board only, needs power supply, HDMI and network cables, SD card, enclosure, WiFi, keyboard, mouse. So together it is ca 80 EUR.
------------------------------------------------------------------------------------------------
Arduino
Experience is that Arduino is the most reliable. It never hangs. With Ethernet shield can make IP-controlled power outlet for your home server remote reboot or temperature webserver. I have written several instructables about Arduino. Arduno can be interfaced to WR703N router via USB. Can process analog inputs, 1-wire temperature sensors, control switches, servo motors, and a small display. However serial communication between Arduino and router hangs after some unregular time. Hanging happens only if Arduino reset is disabled. Solution might be to enable reset and write values that should not be lost into EEPROM. Please have a look at my summarised Instructable about Arduino:
https://www.instructables.com/id/Arduino-Microcontroller-Projects/
------------------------------------------------------------------------------------------------
Ubuntu Netbook
For example eeePC with Ubuntu, 13W consumption. HDD is faster than flash, runs for at least 1 year on heavy writing load. Best compatibility, reliability, speed. Also monitor and keyboard. WiFi client works out of the box. But wifi sometimes hangs. And eeePC does not power up without manually pressing a button. So someone has to be present at home and can not do remote reset via GSM box.
eeePC has no boot rom function to restart power, need to press a button. So actually best solution if electricity use if not concerned would be a desktop PC.
Another experience with running reliably was Beagleboard or Beaglebone with USB HDD.
------------------------------------------------------------------------------------------------
Android phone
High quality Webcam, mic, speaker, Wifi, GSM, battery, keyboard, display, battery temperature sensor, large flash, fast CPU. Can get for ca 60 EUR for Example Samsung i5500.
Disadvantage - Android SDK programming is complicated. Option is to install Ubnuntu in a loop drive on a SD card,
but Ubuntu cannot access camera or sensors.
------------------------------------------------------------------------------------------------
ESP8266
80 MHz processor has integrated WiFi, costs 3EUR, can be programmed from Arduino IDE, 0.3W power consumption, deep sleep mode, sometimes restarts spontaneously. Commercial relay modules (7EUR) made by SOnOff contain ESP8266 and can be reprogrammed.
------------------------------------------------------------------------------------------------
Conclusion
Use Linux boards only for applications where low power consumption or space is needed. Every Linux board has some compatibility issues and bugs as it is not mass produced and be prepared to spend days for customization.
------------------------------------------------------------------------------------------------
42 Comments
7 years ago
Are you want that your wr703n be visible anywhere in the world ? If yes, send e-mail to tcpipchip@hotmail.com
7 years ago on Introduction
Is it possible to flash an arduino board by uploading the file (code or compiled) to the mr3020 it's connected to?
Reply 7 years ago on Introduction
In principle is possible to compile a custom image including WinAVR to compile and upload
to Atmega.
User Squonk42 (Miochel Stemplin) has done it a couple of years ago.
Recently he run a Kickstarter project to include AR8981 Chip and Arduino.
https://www.kickstarter.com/projects/706167548/dominoio-an-open-hardware-wifi-platform-for-things
The Domino Pi basic is the equivalent of a router such as the TP-Link TL-WR703N, based on the same SoC, i.e., it is a 400MHz-class 32-bit MIPS CPU with 64 MB DDR2 RAM and 16 MB SPI Flash, whereas the RPi is >800MHz, > 256MB DDR2 RAM and no Flash except SDCard. But The Domino Pi only consumes 1/2W and has built-in Wi-Fi and up to 3x Ethernet 10/100MB with integrated switch... So these 2 are not equivalent, but fills some overlapping needs.
As for the Qi, it includes an additional ATMega32U4 (list price $3.50 / 1000 pieces), some expensive voltage level translators, plus it requires dual-sided component mounting, which is also more expensive. It happened that we reached 1/2 of the price of the Yun, but that is just a coincidence, it was not a target :)
You may rather wonder why the Yun is twice as expensive, given the quantity they are selling
Reply 7 years ago on Introduction
In principle is possible to compile a custom image including WinAVR to compile and upload
to Atmega.
User Squonk42 (Miochel Stemplin) has done it a couple of years ago.
Recently he run a Kickstarter project to include AR8981 Chip and Arduino.
https://www.kickstarter.com/projects/706167548/dominoio-an-open-hardware-wifi-platform-for-things
The Domino Pi basic is the equivalent of a router such as the TP-Link TL-WR703N, based on the same SoC, i.e., it is a 400MHz-class 32-bit MIPS CPU with 64 MB DDR2 RAM and 16 MB SPI Flash, whereas the RPi is >800MHz, > 256MB DDR2 RAM and no Flash except SDCard. But The Domino Pi only consumes 1/2W and has built-in Wi-Fi and up to 3x Ethernet 10/100MB with integrated switch... So these 2 are not equivalent, but fills some overlapping needs.
"As for the Qi, it includes an additional ATMega32U4 (list price $3.50 / 1000 pieces), some expensive voltage level translators, plus it requires dual-sided component mounting, which is also more expensive. It happened that we reached 1/2 of the price of the Yun, but that is just a coincidence, it was not a target :)
You may rather wonder why the Yun is twice as expensive, given the quantity they are selling "
8 years ago on Introduction
I have not managed to merge video and sound.
So I used just sound. There was a problem
You can find notes about sound in folder:
Digest WR703Nsetup / 06 USB sound / ffmpeg ffserver microphone and streaming
I also had used another programm called listener.
in the folder
_listener detects sound and saves
It records sound when it becomes loud in the room.
.
10 years ago on Introduction
Baby monitor problem solved!!!
Learned how to stream audio from USB sound card or webcam microphone using ffserver. Also can record sound when something happens using package called listener.
Reply 9 years ago on Introduction
Hi! Really great stuff all ovet there, thanks for that.
Can you be more specific about the ffserver? How to config it? I'm really interested in it, thank you!
Reply 9 years ago on Introduction
Please find notes about seting up ffserver inside the 150MB zip file directory
/06 USB sound/ffmpeg ffserver microphone sound streaming/ffmpeg ffstreamer.txt
Reply 8 years ago on Introduction
Hello and thanks for your hard work.
Have you managed to make a workaround regarding the ffmpeg video + audio?
In other words whats the best setup for a baby monitor?
I had success using mjpeg_streamer but it doesn't support audio, and combine ffmpeg video and mjpeg_streamer isn't the best approach...
Thanks in advanced!
Reply 9 years ago on Introduction
Thank you! I tried DarkIce+Icecast and the best result I got was about 5-10 seconds delay which is terrible for me... I read that ffserver is the same...
What is the best way? Can I somehow stream raw pcm and play it on the other side?
9 years ago on Introduction
my experinc was that ffserver has zero delay in the beginning, but delay increases with time. So I reloaded the webpage after few minutes.
10 years ago on Introduction
Hey man lot of eforrts... like so o much... Seems you are expert in this field...
How would you compare the avr board that you used and in the link below.
http://albert-david.blogspot.in/
this guy also seems working for long time
Reply 10 years ago on Introduction
I start to have a feeling that budget priced Android phones like Samsung i5500 (60 EUR on Ebay) are the best as they already include camera, mic, speaker, keyboard screen, wifi, battery, large memory, fast processor. sensors. But programming is quite tricky, so easiest is to wait untill someone writes an app that suits you.
Reply 9 years ago on Introduction
With regard to Android - have scripting API sl4a + Lua. Oche rich API gives access to all equipment on the familiar and beloved Lua.
10 years ago on Introduction
Hello, it's a very nice project.
I have also bought a TPLink 703 and would like to use it as a gateway to arduino.
I've already flashed OpenWRT, it's working Okay.
Now I need to forward TCP/IP sockets to serial (USB CDC) stream.
Unfortunately the dropbox link doesn't work now, too much trafic.
Could somebody reupload the files to the net ?
Regards,
10 years ago on Introduction
webradio inside Wr703N. Amazing! Lots of work. Might be easier to use a smartphone.
http://piie.net/index.php?section=tplink-radio
10 years ago on Introduction
Successfuly tested aircrack-ng on wr703n.
WR703n main chip datasheet is now available
10 years ago on Introduction
Hi DE8MSH,
You can play mp3 files from a directory on a USB flash drive connected to wr703n with madplay? .I could make a page similar to the OWWRS and choose which mp3 to play ?
Regards
10 years ago on Introduction
If anyone is interested: this is what I did with madplay.
http://pastie.org/5477486
A simple script that kills madplay process and than starts a new one.
10 years ago on Introduction
Hi Janis,
thank you very much for this nice instructable. With your brilliant draft I did this:
http://incaseyoureat.dyndns.org/cgi-bin/weather
I did a local net web service, too: