wifi Robot – 3

July 14, 2013 § 3 Comments

I have gone a little bit far away from making robot to making a wifi speaker.

Now, at present i will tell you about how i have converted a TP-Link Tl-MR3020 Router to a wifi-sound system or wifi-sound-box or wifi-speaker whichever you prefer/like to call the project.

Ok, after installing the a new usb pendrive(a 8gb pendrive with 75000 mb avilibility) which is partitioned as 500 mb as linux swap and 7 gb of linux ext4 formatted filesystem. And it is installed by my previous posts.

After mounting the pen drive the system says just like the following picture:

blg1

Then i have installed the packages kmod-usb-audio and kmod-sound-core by this command in ssh.

opkg update
opkg install kmod-usb-audio kmod-sound-core

After success, the basic support of sound is installed. Now, we have to install an audio player. At starting point, we will use an easier one. For that i have selected madplay. To install madplay, insert the following command and then press enter in ssh.

opkg install madplay

After success, attach your usb sound card and restart router. I have used the following cheapest sound card.

dbf9e868-c309-4601-b9c0-faebb79803fa

Then re-login using your putty and also with winscp. Browse with winscp to this folder /www/cgi-bin make a file there named index.cgi and paste the following code(this code is for testing only, it is not optimized).

</pre>
#!/bin/sh
#!/www/cgi-bin/80sonly

&nbsp;

echo "Content-type: text/html"
echo ""
echo "<html>"
#echo "<body bgcolor='#000000'>"
echo "|------[ ] <font size="5" face="Monaco"><a href="off.cgi">Turn OFF</a></font><br/>"
echo '<a href="../StartAudioStream.vbs" target="_blank">Download Script</a>'

echo "My IP IS : ${REMOTE_ADDR}"

echo "<form method=GET action=\"${SCRIPT}\">"\
 '<table nowrap>'\
 '<tr><td>IP</TD><TD><input type="text" name="val_x" size=12 value="'${REMOTE_ADDR}'"></td></tr>'\
 '<tr><td>Port</td><td><input type="text" name="val_y" value="8085" size=12 value=""></td>'\
 '</tr></table>'
echo '<br><input type="submit" value="Apply">'\
 '<input type="reset" value="Reset"></form>'
 # Make sure we have been invoked properly.

if [ "$REQUEST_METHOD" != "GET" ]; then
 echo "<hr>Script Error:"\
 "<br>Usage error, cannot complete request, REQUEST_METHOD!=GET."\
 "<br>Check your FORM declaration and be sure to use METHOD=\"GET\".<hr>"
 exit 1
 fi

&nbsp;
#sleep 1
#kill $(pidof madplay)

# If no search arguments, exit gracefully now.

 if [ -z "$QUERY_STRING" ]; then
 exit 0
 else
 # No looping this time, just extract the data you are looking for with sed:
 XX=`echo "$QUERY_STRING" | sed -n 's/^.*val_x=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
 YY=`echo "$QUERY_STRING" | sed -n 's/^.*val_y=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
# echo "val_x: " $XX
# echo '<br>'
# echo "val_y: " $YY
# echo '<br>'
wget -O - http://$XX:$YY/ | madplay -&

fi

echo '</body>'
echo '</html>'
<pre>

Then save it, right click again on the file>properties and make the property like the following picture(executable) and click ok.blg2

Then make another file there named off.cgi and paste the following codes :

</pre>
#!/bin/sh
#!/www/cgi-bin/80sonly
sleep 1
kill $(pidof madplay)
#killall madplay
echo "Content-type: text/html"
echo ""
echo "<html>"
echo "<body bgcolor='#000000'>"
echo "wait..."

#sleep 1
#kill $(pidof madplay)
#sleep 1
#opkg update
#opkg remove madplay
#opkg install madplay --force-depends --force-maintainer

echo "|------[ ] <font size="1" face="Monaco"><a href="index.cgi">Turn ON</a></font></br>"
echo "|------[ ] <font size="1" face="Monaco"><a href="off.cgi">Turn OFF</a></font>"

#wget -O - http://streaming206.radionomy.com:80/80sOnly | madplay - &
echo "</body>"
echo "</html>"
<pre>

Then, make the file(off.cgi) also executable.

Then  the configuration of the router aka wifi speaker is finished. Now, we need to configure our desktop/laptop to stream sound over lan/wifi.

for this, download vlc media player from here. Install it, Run it. Then configure it like the following pictures.

Click Media>Stream

blg3

Then click Capture Device and set everything like following picture.

blg3

click configure button of audio device name and set everything just like following.

blg3

If you can’t find stereo mix in the pin line drop-down menu, you need to google for it. After that, click OK click Stream, then the following window appears.

blg3

Click Destination Setup>New Destination(select HTTP from dropdown)>Add

blg3

Select Port=8085 and profile audio-mp3 and then click Stream.

blg3

Then you will get the window.

blg3

Then click the little vlc icon in the system tray and vlc window will disappear. For those who dont know what the system tray is –

blg3

Then with your router connected with lan and a speaker is connected with the usb sound card which is connected with the usb hub with the router, go to your favorite browser, type the following address YOUR ROUTER IP/cgi-bin/index.cgi in my case it is :

blg3

It will automatically detect your PC IP. In my case my local pc ip : 192.168.1.110 and my router ip is 192.168.1.250. You dont need to change anything here. Click apply and you can hear the audio played into your PC.

If any problem, then you have missed something. Although i have not told everything briefly coz your best friend google is there for you to help(yeah it helped me to do this project). And if you can please comment of your problems, i must help you if i can.

And another post will come later related this subject with much more controlling from desktop.

Advertisements

Tagged: , , , , , , , , , , ,

§ 3 Responses to wifi Robot – 3

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

What’s this?

You are currently reading wifi Robot – 3 at khairulhasanmd.

meta

%d bloggers like this: