OpenWrt Forum Archive

Topic: Would be nice to have some advice for my next project.

The content of this topic has been archived on 22 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi all!

I'm Kasper from Belgium and discovered openwrt yesterday while browsing the internet for collecting info for my next hobby project. I immediately ordered a TP-LINK TL-WR703N from ebay to enter the wonderful world of openwrt. Mainly I'm a web developer (php,sql,ajax,jquery and so on...) and started doing some arduino stuff since last year. While the arduino is also a wonderful piece of technology it has its limits. it does not have enough processing capabilities for my next project. I think openwrt can help me doing what I want. However I face a problem... I'm not into linux (yet :-).

basically I want to connect an arduino to the USB port from my TL-WR703N together with a webcam for streaming video (using an USB hub). I understand I can use the openwrt/linux command line to send/receive serial data to/from the arduino. It would be great to bypass the terminal with a web interface hosted on the TL-WR703N. In the past I placed my web interfaces on the arduino but it lacks processing power and memory to handle streaming webcam video. That's why I'm here ;-)

1) does the USB from the TL-WR703N has enough bandwidth for streaming video and controlling an arduino over serial?
2) Is the 4mb flash memory from the TL-WR703N enough to install lighttpd so I can use php serial class to communicate with the arduino through a web interface? Is php the best technology to do the trick or is there something better to bypass the terminal?


Any info and suggestions are welcome.

Peace!

1. yes.
2. it’s tight. there will only be a few hundred kb free for a default image and up to 1mb free for a totally slimmed down custom image.

php probably will not fit. but i dunno. personally, i use cgi shell scripts since the shell is built in and my stuff is not very elaborate.

by the way, you can hook the arduino directly to the serial port on the board of the router, hence you can avoid the usb hub. you have to solder a header or wires directly to the correct pads on the board for that.

just bite the bullet and learn some shell. something that will certainly prove useful in many other situations.

If you are going to use a usb hub anyway, you might as well use a usb stick and extroot, then the flash size won't matter...

What Xerion says is very true.  It would also be easier to use usb/serial off of the hub than to try the very delicate and fragile soldering of the internal serial.  Yes you will have the power to do webcam streaming.  PHP is very heavy for a flash device with 4 or 8 meg of flash--but that can be solved with usb flash memory (but might still be sluggish).

I would also recommend not using lighttpd on such a small and low-powered linux device.  cgi using the built-in server works well.

It would probably be possible to do what you want internally without usb flash (but using the hub because you need to talk both to the webcam and the arduino).  Tell us more about the project.

(Last edited by lizby on 23 Apr 2012, 00:07)

thank you all!

The plan is to make a remote laser cat toy for touch enabled devices. Logging in on the openwrt router will display a webinterface -> streaming video from the webcam. Clicking, Touching or swiping the screen will move 2 remote servos (x and y movement). A laser (and maybe the webcam itself) will be mounted on the servos. This can be easily done with the arduino and the webcam as seperate nodes on the LAN but I like to use only one wifi connection for both the camera and arduino.
I can do it with a la fonera card but I'm more interested in using an openwrt device as it seams it is more versatile :-)

However I like the idea of having a small php server on a small device like the TL-WR703N, I think shell scripts/cgi will fit my needs better. thank you for that! I'll dive into linux shell scripting as soon as I feel to...

extroot in combination with a php server will be an option too, but like I said I'm almost a total noob with linux and prefer starting with the beginning.

I hope I'll receive my TP-link very soon so I can start experimenting :-)

EDIT
------

just an other quick question about cgi: I could easily make a webpage and post data to a cgi shell script through ajax. Lets say this data are the coordinates from a screen touch on my android phone. Now the cgi script has to talk serial to the arduino and move the servos according to these coordinates . Is this functionality available when I flash my TP-link with the standard openwrt image found here http://wiki.openwrt.org/toh/tp-link/tl-wr703n or do I need extra usb libraries? Is perl the best way to write cgi scripts for a linux platform like openwrt?

(Last edited by kasperfish on 23 Apr 2012, 15:15)

My openwrt project to do servo pan and tilt for a webcam (controllable by anyone over the web) is documented here: 

http://www.picaxeforum.co.uk/showthread.php?13705

and here:

http://www.picaxeforum.co.uk/showthread.php?9425

I used a picaxe rather than the arduino, but the principle is the same.

Here is a fairly simple web page with radio buttons (/www/furnace.html):

<html>
<head>
<title>702 Furnace</title>
</head>

<body>
<form name="form1" method="get" action="/cgi-bin/set-furnace.sh">
  <p>
    Click a button to set furnace runtime
  </p>
  <p>
<TABLE BORDER="1" CELLSPACING="0" CELLPADDING="5">
<TR><TD>Furnace</TD></TR>
<TR><TD>Run Time</TD></TR>
<TR><TD>
    <input name="Radio_Button" type="radio" value="p0" onClick="this.form.submit()"> off<br>
</TD></TR>
<TR><TD>
    <input name="Radio_Button" type="radio" value="p1" onClick="this.form.submit()"> 15 minutes
</TD></TR>
<TR><TD>
    <input name="Radio_Button" type="radio" value="p2" onClick="this.form.submit()"> 30 minutes<br>
</TD></TR>
<TR><TD>
    <input name="Radio_Button" type="radio" value="p3" onClick="this.form.submit()"> 45 minutes
</TD></TR>
<TR><TD>
    <input name="Radio_Button" type="radio" value="p4" onClick="this.form.submit()"> 1 hour<br>
</TD></TR>
<TR><TD>
    <input name="Radio_Button" type="radio" value="p5" onClick="this.form.submit()"> 75 minutes<br>
</TD></TR>
<TR><TD>
    <input name="Radio_Button" type="radio" value="p6" onClick="this.form.submit()"> 90 minutes<br>
</TD></TR>
<TR><TD>
    <input name="Radio_Button" type="radio" value="p7" onClick="this.form.submit()"> 105 minutes<br>
</TD></TR>
<TR><TD>
    <input name="Radio_Button" type="radio" value="p8" onClick="this.form.submit()"> 2 hours
</TD></TR></TABLE>
  </p>
</form>
</body>
</html>

And its action script (simplified)--/www/cgi-bin/set-furnace.sh:

#!/bin/sh
tmp=$(echo "$QUERY_STRING"|awk -F'=' '{print $2}')
echo "$tmp" > /dev/ttyUSB0
echo "$tmp" >> /var/log/furnace.log
echo "Content-type: text/html"
echo ""
cat /www/furnace.html

Hope this helps.

(Last edited by lizby on 23 Apr 2012, 16:03)

For usb serial, you with need to install packages for usb serial and your serial dongle (probably CH341, PL2303, or CP210x):

opkg update
opkg install kmod-usb-serial kmod-usb-serial-ch341 kmod-usb-serial-cp210x kmod-usb-serial-pl2303

Right now, these packages are not available in trunk for the WR703N's ar71xx platform, and have not been for a week or more.  Hope this gets fixed soon, otherwise you will have to build your own firmware (or use the latest backfire release, 10.3.1).

(Last edited by lizby on 23 Apr 2012, 16:20)

Yeah you can POST to a CGI shell script. With mjpeg-streamer you can get pseudo motion jpeg. The last time I tried I got 640x480 at 20 fps, but at a fairly high bandwidth.

@lizby: thanks bro for your example! It will surely help me with my project.
@towolf: I'll try it as soon as I have my TP-link from CN... hope it won't take too long.

thank for the promt info and help!

The discussion might have continued from here.