Smart Home Automation Webserver on OpenWRT Router WR703N Interfaced to Arduino, Compared to Raspberry Pi and Ubuntu

by janisalnis in Circuits > Linux

234178 Views, 352 Favorites, 0 Comments

Smart Home Automation Webserver on OpenWRT Router WR703N Interfaced to Arduino, Compared to Raspberry Pi and Ubuntu

00 a wr703N.png
usb HDD.png
05 mjpg-streamer webserver.jpg
WR703N GPIO.png
03 serial port connection wires.JPG
03 serial connecting CP2102 module.jpg
10 temperature webserver.png
52 mouse as motion detector.JPG
60  Arduino read temperature.png
svg gauges.png

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.

------------------------------------------------------------------------------------------------