Inexpensive Web Publishing of Arduino/ARM Sourced Data – home automation webserver

I started out working on a WiFi client to use with the the setup of the Ethernet Module Post. However, the idea has morphed into something else – a method for inexpensive web hosting of Arduino or ARM system data over WiFi to the Internet. The chosen hardware is sophisticated enough to host its own website or feed it upstream to another website.  The simplistic idea is for the Arduino or ARM system to be able to access the internet. After some web research I discovered that Chinese router manufacturer TP-LINK makes an inexpensive, tiny router called TL-WR703N, that can be set into client mode or, as I am using it, a standalone HTTP server that is smaller than a deck of playing cards. I purchased one from a USA eBay supplier for $23 with free shipping. It is, indeed, tiny, measuring 2-1/4 inches square and 3/4 inch thick. The TL-WR703N is only intended for the Chinese market so there is initially NO English interface. The solution for the lack of English and a way to get even more software capability is to install the OpenWRT firmware.

I jumped into flashing the unit a bit too quickly. I should have read a few more blogs. I am used to DD-WRT firmware immediately having an administrative webpage but OpenWRT has no admin webpage upon boot – it must be added, if desired.

In my case, once I flashed it via the Chinese webpage upgrade link there was no webpage at Thinking that I did something wrong I opened up the TL-WR703N, removed the PCB, wired up the serial port (I wasn’t as fancy as this link) and using TFTP I loaded several other OpenWRT firmware versions and even reloaded the original Chinese firmware. It wasn’t until I read another blog that I realized that the web server was deliberately missing from standard TL-WR703N OpenWRT package. The English language XincheJian blog from Shanghai China explained how to install the administration web server module called “luci”. An alternative is to simply edit the configuration files with “vi“, which is in the basic OpenWRT build. The instructions provided by the Rechenzentrum Garching (RZG) group of Germany are useful, at least initially.

tl-wr703n without case

tl-wr703n without case

I am embarrassed about how much time I spent on this project trying to get WAN routing to work. After trying innumerable versions of OpenWRT I discovered that my biggest problem was that the hardware version of my TL-WR703N was too new. Mine is version 1.7, the newest, and the current stable release of OpenWrt does not properly support the Ethernet port for the 1.7 hardware. So, instead of loading the generic OpenWRT firmware I ended up loading the current Trunk release, which includes the fixes to properly support the v1.7 hardware’s Ethernet port. More about Trunk releases and their “gotchas” later in this post.

Once OpenWRT is loaded into the TL-WR703N, with vi on the TL-WR703N, modify /etc/config/network and /etc/config/network. Rather than explain each step, I simply show my files later in this post.

Since the goal is to connect an Arduino/ARM to the TL-WR703N, some Linux drivers need to be installed into OpenWRT. Once again, the instructions provided by the Rechenzentrum Garching (RZG) group were useful but required some changes, in my case. RZG indicated success with getting a /dev/ttyUSB0 from plugging in an Arduino Duemillanove’s USB port but they stated that this would not work for an Arduino UNO. I am using an Arduino NANO, which, while it is based upon the UNO, there are some differences, one of which is with the USB hardware. lectroleevin’s blog writes that, using an Arduino UNO, his TL-WR703N successfully creates a ‘/dev/ttyACM0’. However, mine, initially, did not create a ttyUSB0 or ttyACM0. I say “Initially” because later I got it to work – read on.

Given my initial failure to get a /dev/ttyUSB0 created my plan “B” is to use a PL-2303 based serial module or cable. For my initial tests I used a PL-2303 cable from With the “kmod-usb-serial-pl2303” driver installed, plugging in the aforementioned PL-2303 cable creates /dev/ttyUSB0. Note that this setup will not use the Arduino USB port but will, instead, connect to a software serial port. I prefer this anyway because, if things go as planned, I may end up building my own PCB with an AVR chip rather than use an Arduino board.

Here is how I initially installed the PL-2303 library with the downloaded trunk build:

opkg update
opkg install coreutils-stty
opkg install kmod-usb-serial
opkg install kmod-usb-serial-pl2303
# a device should appear with plugged in pl-2303 interface
ls /dev/ttyUSB0


I must point out that, in addition to OpenWRT’s router firmware, another option is DD-WRT’s firmware. See THIS-LINK for DD-WRT. I have not tested the DD-WRT firmware on the TL-WR703N but it has worked wonderfully for me on other router hardware.

Now that I know that I can communicate between the TL-WR703N and the Arduino NANO future projects will be to create some variation of the home automation webserver system posted by German engineer “janisalnis”. Take a look at his TL-WR703N webserver at THIS-LINK.

Now, regarding Trunk releases and my most recent update (2013-03-07):

I had previously installed a February trunk snapshot into my TL-WR703N. On March 6th, when I tried to install a package I discovered the flaw with trunk loads – when openWRT changes the on-line build adding new packages will fail due to version differences. I had not downloaded the February packages so they were no longer available to me. I then installed the March 5th trunk snapshot and discovered that the r35037 patch seemed to be missing again. I really didn’t want to wait for a new snapshot (who knew that it would be the next day) so I decided to build my own release.

I went to “” and used git to clone “git:// (clone of trunk)” and “git:// (clone of packages)”. Then I followed the building instructions at “

Worked like a charm the very first time! I built a generic build except that I included kmod-usb-serial drivers in the kernel so that I wouldn’t need to load them. My DIY OpenWRT load booted and ran perfectly!

These are the packages that I installed in the kernel build:

kmod-usb-acm – 3.8.2-1
kmod-usb-core – 3.8.2-1
kmod-usb-ohci – 3.8.2-1
kmod-usb-serial – 3.8.2-1
kmod-usb-serial-cp210x – 3.8.2-1
kmod-usb-serial-ftdi – 3.8.2-1
kmod-usb-serial-pl2303 – 3.8.2-1The

I also added Luci to the feeds so that it would be available in menuconfig. When I ran menuconfig I added the full Luci to the build.

After booting the TL-WR703N on my version of the Trunk build, I immediately used my connected PC’s router to browse to and opened Luci. I navigated to network->wifi and selected Scan and then Join Network and finally Save&Apply. This configures the TL-WR703N as a client. My resultant /etc/config/network and /etc/config/wireless, et al,  can be downloaded from THIS-LINK. This particular configuration is not really in “client” mode since it does not feed the wan to the lan. To feed the wan to the lan you need to add relayd (more about this later on). So, this configuration really establishes the TL-WR703N as a stand-alone device that can host a small webserver and Arduino/ARM serial interface, which serves my purposes. Also, while these config files show DHCP for the wireless, a static IP would be preferable. In my case behavior is similar since my router does an IP reservation for the wireless’ MAC. You may also find useful, the config files and instructions at the eDIY blog, which is about the MR3020, a TPLINK router that very similar to the TL-WR703N, making the instructions mostly, but not completely applicable.

I discovered could not ping the TL-WR703N from any other of my PCs. A bit of Googling and I think that have found the problem. My router runs dd-WRT and nat-loopback is said to be broken. The fix that I found seems to work. It comes from  It is simply to open Administration->Commands in dd-WRT and run “iptables -t nat -I POSTROUTING -o br0 -s -d -j MASQUERADE”

With the config files posted above, the TL-WR703N can reach the Internet and my other PCs can reach the TL-WR703N over my LAN. I can even administer the TL-WR703N using Luci from my primary desktop, over the LAN and with a port forward setup in my router, you can also reach the TL-WR703N from the Internet.

The configuration above established the TL-WR703N as a webserver e/w serial ports. If, instead, the goal is for the TL-WR703N to serve purely as a WiFi client that provides wireless connectivity to a PC that has only wired Ethernet, you must add “relayd” to the mix. Relayd will relay the traffic between the wwan subnet and eth0. Note, however, that while you gain Ethernet client connectivity, you will lose the webserver functionality. The webserver functionality is more important to me so while I tested the relayd configuration, I ultimately removed it. If you want a pure WiFi client, follow the relayd installation procedure at the Cave Tinker Pit website or’s particularly well documented instructions.

Check back – I will update this post when I add some cgi functions…

This entry was posted in Electronics, hardware, Linux, Programming, software and tagged , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s