<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>MightyOhm &#187; OpenWRT</title>
	<atom:link href="http://mightyohm.com/blog/tag/openwrt/feed/" rel="self" type="application/rss+xml" />
	<link>http://mightyohm.com/blog</link>
	<description>Join the resistance.</description>
	<lastBuildDate>Wed, 16 May 2012 17:02:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Jan&#8217;s Wifi Radio has a modern look</title>
		<link>http://mightyohm.com/blog/2011/03/jans-wifi-radio-has-a-modern-look/</link>
		<comments>http://mightyohm.com/blog/2011/03/jans-wifi-radio-has-a-modern-look/#comments</comments>
		<pubDate>Thu, 24 Mar 2011 21:16:25 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[AVR]]></category>
		<category><![CDATA[BASCOM]]></category>
		<category><![CDATA[OpenWRT]]></category>
		<category><![CDATA[wifiradio]]></category>

		<guid isPermaLink="false">http://mightyohm.com/blog/?p=3731</guid>
		<description><![CDATA[Jan Wante made this gorgeous Wifi Radio with a modern look. It is based on my original Wifi Radio tutorials. Not content to simply duplicate my work, he added a few creative twists of his own, including a custom handmade case made of alucobond, MDF, and real wood veneer that gives his finished radio a nice, [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.instructables.com/id/Build-your-own-Wifi-radio/"><img class="alignnone size-full wp-image-3732" title="Build your own Wifi radio" src="http://mightyohm.com/blog/wp-content/uploads/2011/03/Build-your-own-Wifi-radio.jpg" alt="" width="500" height="375" /></a></p>
<p>Jan Wante made this <a href="http://www.instructables.com/id/Build-your-own-Wifi-radio/">gorgeous Wifi Radio</a> with a modern look. It is based on <a href="http://mightyohm.com/wifiradio">my original Wifi Radio tutorial</a>s.</p>
<p>Not content to simply duplicate my work, he added a few creative twists of his own, including a custom handmade case made of <a href="http://www.alucobond.com/">alucobond</a>, MDF, and real wood veneer that gives his finished radio a nice, modern look.  Inside, a hacked WL-520gU wireless router running <a href="http://openwrt.org">OpenWrt</a> runs the show and an ATmega microcontroller programmed with <a href="http://www.mcselec.com/index.php?option=com_content&amp;task=view&amp;id=14&amp;Itemid=41">BASCOM</a> interfaces with a rotary encoder and graphical LCD display.</p>
<p>The very impressive result is shown in this video:</p>
<p><object width="500" height="405"><param name="movie" value="http://www.youtube-nocookie.com/v/bltRuA8pe4I?fs=1&amp;hl=en_US&amp;rel=0&amp;hd=1" /><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><embed type="application/x-shockwave-flash" width="500" height="405" src="http://www.youtube-nocookie.com/v/bltRuA8pe4I?fs=1&amp;hl=en_US&amp;rel=0&amp;hd=1" allowfullscreen="true" allowscriptaccess="always"></embed></object></p>
<p>Nice work, Jan!</p>
]]></content:encoded>
			<wfw:commentRss>http://mightyohm.com/blog/2011/03/jans-wifi-radio-has-a-modern-look/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Sneak peek at my finished Wifi Radio project!</title>
		<link>http://mightyohm.com/blog/2009/05/sneak-peak-at-my-finished-wifi-radio-project/</link>
		<comments>http://mightyohm.com/blog/2009/05/sneak-peak-at-my-finished-wifi-radio-project/#comments</comments>
		<pubDate>Thu, 28 May 2009 15:29:31 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[lcd]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[make]]></category>
		<category><![CDATA[maker faire]]></category>
		<category><![CDATA[OpenWRT]]></category>
		<category><![CDATA[photos]]></category>
		<category><![CDATA[wifiradio]]></category>
		<category><![CDATA[WL-520GU]]></category>

		<guid isPermaLink="false">http://mightyohm.com/blog/?p=1902</guid>
		<description><![CDATA[While I&#8217;m busy working on part ten of my series on building a wireless router-based DIY streaming internet radio, I couldn&#8217;t resist sharing a few photos of the finished project. If you want to see the radio in person, stop by Expo Hall Booth 166 at the Maker Faire in San Mateo, CA this weekend.  [...]]]></description>
			<content:encoded><![CDATA[<p>While I&#8217;m busy working on <strong>part ten</strong> of my series on building a <a href="http://mightyohm.com/wifiradio">wireless router-based DIY streaming internet radio</a>, I couldn&#8217;t resist sharing a few photos of the finished project.</p>
<p>If you want to see the radio in person, stop by <a href="http://makerfaire.com/pub/e/2315">Expo Hall Booth 166</a> at the <a href="http://makerfaire.com">Maker Faire</a> in San Mateo, CA this weekend.  I&#8217;ll be there to demonstrate the radio and answer questions!</p>
<p><a class="tt-flickr tt-flickr-Medium" title="Finished Wifi Radio" href="http://www.flickr.com/photos/mightyohm/3567609195/"><img class="alignnone" src="http://farm3.static.flickr.com/2455/3567609195_79760d88fe.jpg" alt="Finished Wifi Radio" width="500" height="375" /></a></p>
<p><a class="tt-flickr tt-flickr-Medium" title="Finished Wifi Radio" href="http://www.flickr.com/photos/mightyohm/3567599841/"><img class="alignnone" src="http://farm4.static.flickr.com/3593/3567599841_c6666d770c.jpg" alt="Finished Wifi Radio" width="500" height="375" /></a></p>
<p><a class="tt-flickr tt-flickr-Medium" title="Finished Wifi Radio" href="http://www.flickr.com/photos/mightyohm/3568413842/"><img class="alignnone" src="http://farm4.static.flickr.com/3351/3568413842_ca6a2bc59d.jpg" alt="Finished Wifi Radio" width="500" height="375" /></a></p>
<p><a class="tt-flickr tt-flickr-Medium" title="Finished Wifi Radio" href="http://www.flickr.com/photos/mightyohm/3568415386/"><img class="alignnone" src="http://farm4.static.flickr.com/3304/3568415386_c4b8b4506e.jpg" alt="Finished Wifi Radio" width="500" height="375" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://mightyohm.com/blog/2009/05/sneak-peak-at-my-finished-wifi-radio-project/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Building a Wifi Radio &#8211; Part 9, A Few Odds and Ends</title>
		<link>http://mightyohm.com/blog/2009/05/building-a-wifi-radio-part-9-a-few-odds-and-ends/</link>
		<comments>http://mightyohm.com/blog/2009/05/building-a-wifi-radio-part-9-a-few-odds-and-ends/#comments</comments>
		<pubDate>Wed, 27 May 2009 15:31:19 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[AVR]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mpd]]></category>
		<category><![CDATA[OpenWRT]]></category>
		<category><![CDATA[shell script]]></category>
		<category><![CDATA[wifiradio]]></category>
		<category><![CDATA[Wireless]]></category>

		<guid isPermaLink="false">http://mightyohm.com/blog/?p=1872</guid>
		<description><![CDATA[This is the ninth part of an ongoing series about building a low cost, open source streaming internet radio based on the ASUS WL-520gU Wireless Router.  If you haven’t already, check out the previous parts (see the links at the end of this article) for some background about the project. In part eight, we added [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is the ninth part of an ongoing series about building a low cost, open source streaming internet radio based on the <a onclick="javascript:pageTracker._trackPageview('/outbound/article/http://www.dpbolvw.net/click-3238164-10440897?url=http%3A%2F%2Fwww.newegg.com%2FProduct%2FProduct.aspx%3FItem%3DN82E16833320023%26nm_mc%3DAFC-C8Junction%26cm_mmc%3DAFC-C8Junction-_-Network%2B-%2BWireless%2BRouters-_-ASUS-_-33320023&amp;cjsku=N82E16833320023');" href="http://www.dpbolvw.net/click-3238164-10440897?url=http%3A%2F%2Fwww.newegg.com%2FProduct%2FProduct.aspx%3FItem%3DN82E16833320023%26nm_mc%3DAFC-C8Junction%26cm_mmc%3DAFC-C8Junction-_-Network%2B-%2BWireless%2BRouters-_-ASUS-_-33320023&amp;cjsku=N82E16833320023" target="_top">ASUS WL-520gU Wireless Router</a><img src="http://www.ftjcfx.com/image-3238164-10440897" border="0" alt="" width="1" height="1" />.  If you haven’t already, check out the previous parts (see the links at the end of this article) for some background about the project.</em></p>
<p>In <a href="http://mightyohm.com/blog/2009/02/building-a-wifi-radio-part-8-adding-a-tuning-control/">part eight</a>, we added a tuning control for the radio.  Now we can change to any of ten preset stations on the radio by adjusting the position of a potentiometer connected to our AVR microcontroller.   The LCD display we built in <a href="http://mightyohm.com/blog/2008/12/building-a-wifi-radio-part-7-building-an-lcd-display/">part seven</a> lets us know what stream we&#8217;re listening to and the artist and title of the current song.  This project is coming together very nicely!</p>
<p>Before we put the final touches on this project in part ten, there are a few miscellaneous chores to take care of:</p>
<h3>Fixing /etc/config/wireless:</h3>
<p><a href="http://mightyohm.com/blog/2009/02/building-a-wifi-radio-part-8-adding-a-tuning-control/">Last time</a>, we tweaked /etc/config/network to assign a static IP address to the LAN (ethernet) ports of the router.  This allowed us to directly connect a computer to the router via an ethernet cable and get a shell prompt, regardless of the state of the serial console or the wireless connection of the router.  Unfortunately, I made an omission in the setup instructions which may prevent this from working correctly.</p>
<p>To fix this, modify /etc/config/wireless as follows (changes are in bold, use your wireless network information in place of my example):</p>
<pre style="padding-left: 30px;">config wifi-device  wl0
    option type     broadcom
    option channel  3

    # REMOVE THIS LINE TO ENABLE WIFI:
    # option disabled 1

config wifi-iface
    option device   wl0
    option network  <strong>wan</strong>
    option mode     sta  # configures the router to connect to your network
    option ssid     MyNetwork # the SSID of your network
    option encryption wep  # the encryption mode of your network
    option key	XXXXXXXXXX  # add this line with your WEP key in place of X...X</pre>
<p>The only change is to set &#8220;option network&#8221; to &#8220;wan&#8221; instead of &#8220;lan&#8221;.  This minor change tells the router to separate the wireless interface of the router from the LAN/ethernet interface and allows the router to acquire two separate IP addresses, one for each interface.</p>
<h3>Launching mpd automatically at startup:</h3>
<p>Manually launching mpd every time the router boots is a drag.  You can automate this by creating a symbolic link to /etc/init.d/mpd from the /etc/rc.d directory, as follows:</p>
<pre style="padding-left: 30px;">root@OpenWrt:~# ln -s /etc/init.d/mpd /etc/rc.d/S93mpd</pre>
<p>Now every time the router boots, mpd will be started automatically as part of the boot process.  (That was easy!)</p>
<h3>Boot script for the user interface:</h3>
<p>Assuming we want a dedicated internet radio that doesn&#8217;t require user intervention to operate, the scripts for the LCD display and tuning control should also be launched at startup.  This will ensure that upon applying power, the radio will boot into a state where a stream is playing and the user interface is active.</p>
<p>First, we need to create a simple boot script.  Create the file /etc/init.d/AVR with the following contents:</p>
<pre style="padding-left: 30px;">#!/bin/sh /etc/rc.common
# Copyright (C) 2008 OpenWrt.org</pre>
<pre style="padding-left: 30px;">START=99
start() {
sleep 5    # make sure boot process is done, no more console messages
/root/interface.sh
}</pre>
<p>To launch the script at boot, create a symbolic link as follows:</p>
<pre style="padding-left: 30px;">root@OpenWrt:~# ln -s /etc/init.d/AVR /etc/rc.d/S99AVR</pre>
<p>Every time the router boots, the user interface will automatically start, mpd will start playing the selected stream based on the tuner position, and the AVR microcontroller (assuming it is still connected to the serial port) will update the LCD display and watch the potentiometer for any changes in position.</p>
<h3>Tweaking the firewall configuration:</h3>
<p>This is actually optional, but it can be pretty useful while hacking on the router.  As presently configured, the router blocks incoming requests on the WAN, which now includes the wireless interface.  This prevents us from using ssh or telnet to log into the router over our wireless network.  While we can still get a shell by connecting an ethernet cable to one of the LAN ports on the router, it is often more convenient to access the router across your wireless network.</p>
<p>The file /etc/config/firewall controls the firewall settings.  We&#8217;ll be modifying this file.</p>
<p>Open the file in vi and scroll down to this section:</p>
<pre style="padding-left: 30px;">config zone
    option name        wan
    option input    REJECT
    option output    ACCEPT
    option forward    REJECT
    option masq        1</pre>
<p>Edit the &#8220;option input&#8221; line so that it looks like this:</p>
<pre style="padding-left: 30px;">config zone
    option name        wan
   <strong> option input    ACCEPT</strong>
    option output    ACCEPT
    option forward    REJECT
    option masq        1</pre>
<p>Now restart the firewall (or just reboot the router):</p>
<pre style="padding-left: 30px;">root@OpenWrt:~# /etc/init.d/firewall restart</pre>
<p>You should now be able to ssh or telnet into the router over your wireless network.</p>
<h3>Enable SSH:</h3>
<p>By the way, if you want to access the router with <a href="http://en.wikipedia.org/wiki/Ssh">ssh</a> instead of <a href="http://en.wikipedia.org/wiki/Telnet">telnet</a>, just set a root password.  The telnet daemon will be disabled (for security reasons) and replaced with an <a href="http://matt.ucc.asn.au/dropbear/dropbear.html">SSH daemon</a> instead.  You can do this with the &#8220;passwd&#8221; command.</p>
<pre style="padding-left: 30px;">root@OpenWrt:~# passwd
Changing password for root
New password: *****
Retype password: *****
Password for root changed by root
root@OpenWrt:~#</pre>
<p>Log out of your telnet session and use ssh to log back in with your favorite ssh client (don&#8217;t forget to tell the client to use the username &#8220;root&#8221;).</p>
<h3>Stay tuned!</h3>
<p><a class="tt-flickr tt-flickr-Small" title="Wifi Radio Enclosure - Google Sketchup Model" href="http://www.flickr.com/photos/mightyohm/3306019406/"><img class="alignnone" src="http://farm4.static.flickr.com/3623/3306019406_7879de7ace_m.jpg" alt="Wifi Radio Enclosure - Google Sketchup Model" width="240" height="161" /></a></p>
<p>That&#8217;s it for now.  Stay tuned for the final part in this series, part ten, in which I&#8217;ll talk about what it took to turn this Sketchup model into a real wooden case for the radio!</p>
<p><strong>Update: </strong>Part ten (the final part in the series) <a href="http://mightyohm.com/blog/2009/05/building-a-wifi-radio-part-10-building-the-box/">is now online.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://mightyohm.com/blog/2009/05/building-a-wifi-radio-part-9-a-few-odds-and-ends/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Video of my NOTACON talk now online</title>
		<link>http://mightyohm.com/blog/2009/05/video-of-my-notacon-talk-now-online/</link>
		<comments>http://mightyohm.com/blog/2009/05/video-of-my-notacon-talk-now-online/#comments</comments>
		<pubDate>Thu, 21 May 2009 15:42:40 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[conferences]]></category>
		<category><![CDATA[NOTACON]]></category>
		<category><![CDATA[OpenWRT]]></category>
		<category><![CDATA[tweetawatt]]></category>
		<category><![CDATA[video]]></category>
		<category><![CDATA[wifiradio]]></category>
		<category><![CDATA[WL-520GU]]></category>

		<guid isPermaLink="false">http://mightyohm.com/blog/?p=1840</guid>
		<description><![CDATA[This week I finally got a working copy of the video of my talk from NOTACON 6 about hacking the Asus WL-520gU wireless router.  You can either watch the embedded video above or follow the link below to Vimeo.  If you don&#8217;t like either option, you can also download the m4v source file from here [...]]]></description>
			<content:encoded><![CDATA[<p><object width="500" height="375" data="http://vimeo.com/moogaloop.swf?clip_id=4714898&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=4714898&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /></object></p>
<p>This week I finally got a working copy of the video of my talk from <a href="http://notacon.org">NOTACON 6</a> about hacking the Asus WL-520gU wireless router.  You can either watch the embedded video above or follow the link below to Vimeo.  If you don&#8217;t like either option, you can also <a href="http://vimeo.com/download/video:2853238?v=2&amp;e=1242690112&amp;h=88582b105a06524ba66f5f143f5154c1&amp;uh=c2846a5380c315d30d2c0c338b7fdbf9">download the m4v source file from here</a> (thanks Vimeo!).</p>
<p>Special thanks to <a href="http://mediaarchives.com">Media Archives</a> for recording my talk!</p>
<p><a href="http://vimeo.com/4714898">NOTACON 6 &#8211; Hacking the Asus WL-520gU Wireless Router</a> from <a href="http://vimeo.com/user1035632">MightyOhm</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://mightyohm.com/blog/2009/05/video-of-my-notacon-talk-now-online/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Off to NOTACON!</title>
		<link>http://mightyohm.com/blog/2009/04/off-to-notacon/</link>
		<comments>http://mightyohm.com/blog/2009/04/off-to-notacon/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 19:36:36 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Events]]></category>
		<category><![CDATA[conferences]]></category>
		<category><![CDATA[NOTACON]]></category>
		<category><![CDATA[OpenWRT]]></category>
		<category><![CDATA[wifiradio]]></category>
		<category><![CDATA[WL-520GU]]></category>

		<guid isPermaLink="false">http://mightyohm.com/blog/?p=1665</guid>
		<description><![CDATA[It&#8217;s almost time to board the plane and I&#8217;m still messing with the slides for my talk at 1PM tomorrow in the East Ballroom at Notacon 6. It&#8217;s a good thing this stuff is so much fun, otherwise I might ask myself &#8211; why am I doing this?? I&#8217;m hoping to meet some cool peeps [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.notacon.org/"><img class="alignnone size-full wp-image-1666" title="notacon 6" src="http://mightyohm.com/blog/wp-content/uploads/2009/04/nac6.png" alt="notacon 6" width="500" height="81" /></a></p>
<p>It&#8217;s almost time to board the plane and I&#8217;m still messing with the slides for <a href="http://www.notacon.org/speakers.html#Keyzer">my talk at 1PM tomorrow</a> in the East Ballroom at <a href="http://www.notacon.org/">Notacon 6</a>.</p>
<p>It&#8217;s a good thing this stuff is so much fun, otherwise I might ask myself &#8211; why am I doing this??</p>
<p>I&#8217;m hoping to meet some cool peeps at the non-con.  I&#8217;ll have Rescue Shield kits and stickers with me for anyone who wants to check them out.  Even if you don&#8217;t see my talk, say hi sometime during the weekend.  I&#8217;ll be the nerdy looking tall guy in the black shirt.  Oh wait&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://mightyohm.com/blog/2009/04/off-to-notacon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Video: Hacking the ASUS router for the Tweet-a-Watt</title>
		<link>http://mightyohm.com/blog/2009/04/video-hacking-the-asus-router-for-the-tweet-a-watt/</link>
		<comments>http://mightyohm.com/blog/2009/04/video-hacking-the-asus-router-for-the-tweet-a-watt/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 15:20:08 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[adafruit]]></category>
		<category><![CDATA[OpenWRT]]></category>
		<category><![CDATA[wifiradio]]></category>
		<category><![CDATA[Wireless]]></category>
		<category><![CDATA[WL-520GU]]></category>
		<category><![CDATA[xbee]]></category>

		<guid isPermaLink="false">http://mightyohm.com/blog/?p=1655</guid>
		<description><![CDATA[As I mentioned last week, Adafruit Industries is hacking the Asus WL-520gU wireless router to talk to the Tweet-a-Watt. Their hack is based on the work I did to create my Wifi Radio project. Check out the video below to learn more about their cool hack!]]></description>
			<content:encoded><![CDATA[<p>As I mentioned <a href="http://mightyohm.com/blog/2009/03/tweet-a-watt-uses-wl-520gu-for-data-acquisition/">last week</a>, Adafruit Industries is <a href="http://www.adafruit.com/blog/2009/04/04/hacking-the-asus-router-for-the-tweet-a-watt/">hacking the Asus WL-520gU wireless router to talk to the Tweet-a-Watt</a>.</p>
<p>Their hack is based on the work I did to create my <a href="http://mightyohm.com/wifiradio/">Wifi Radio project</a>.</p>
<p>Check out the video below to learn more about their cool hack!</p>
<p><object width="500" height="375" data="http://blip.tv/play/g4Fg+IBvhq8E%2Em4v" type="application/x-shockwave-flash"><param name="src" value="http://blip.tv/play/g4Fg+IBvhq8E%2Em4v" /><param name="allowfullscreen" value="true" /></object></p>
]]></content:encoded>
			<wfw:commentRss>http://mightyohm.com/blog/2009/04/video-hacking-the-asus-router-for-the-tweet-a-watt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Looking for Asus WL-520gU Wireless Router Hacks</title>
		<link>http://mightyohm.com/blog/2009/03/looking-for-asus-wl-520gu-wireless-router-hacks/</link>
		<comments>http://mightyohm.com/blog/2009/03/looking-for-asus-wl-520gu-wireless-router-hacks/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 16:46:50 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[Asus]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[NOTACON]]></category>
		<category><![CDATA[OpenWRT]]></category>
		<category><![CDATA[WL-500gP]]></category>
		<category><![CDATA[WL-520GU]]></category>

		<guid isPermaLink="false">http://mightyohm.com/blog/?p=1389</guid>
		<description><![CDATA[Have you created a project or hack based on the Asus WL-520gU or WL-500gP Wireless Routers? It doesn&#8217;t matter if it was inspired by my project or developed independently &#8211; I&#8217;d love to hear from you! I&#8217;m putting together a talk for NOTACON and I&#8217;d like to feature as many projects as I can to [...]]]></description>
			<content:encoded><![CDATA[<p>Have you created a project or hack based on the Asus WL-520gU or WL-500gP Wireless Routers?</p>
<p>It doesn&#8217;t matter if it was inspired by <a href="http://mightyohm.com/wifiradio/">my project</a> or developed independently &#8211; I&#8217;d love to hear from you!</p>
<p>I&#8217;m putting together a talk for <a href="http://www.notacon.org">NOTACON</a> and I&#8217;d like to feature as many projects as I can to spread the word about how powerful, flexible, and affordable these routers are, especially when coupled with a Linux package (DD-WRT, Tomato, OpenWrt, etc.) and USB devices.</p>
<p>If you&#8217;d like to have your project included in the talk, leave a comment or <a href="http://mightyohm.com/blog/contact">contact me directly</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://mightyohm.com/blog/2009/03/looking-for-asus-wl-520gu-wireless-router-hacks/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Building a Wifi Radio &#8211; Part 8, Adding a Tuning Control</title>
		<link>http://mightyohm.com/blog/2009/02/building-a-wifi-radio-part-8-adding-a-tuning-control/</link>
		<comments>http://mightyohm.com/blog/2009/02/building-a-wifi-radio-part-8-adding-a-tuning-control/#comments</comments>
		<pubDate>Tue, 03 Feb 2009 15:27:46 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[AVR]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[DIY]]></category>
		<category><![CDATA[Embedded Linux]]></category>
		<category><![CDATA[lcd]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[noisebridge]]></category>
		<category><![CDATA[OpenWRT]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[shell script]]></category>
		<category><![CDATA[Streaming Radio]]></category>
		<category><![CDATA[wifiradio]]></category>

		<guid isPermaLink="false">http://mightyohm.com/blog/?p=1148</guid>
		<description><![CDATA[This is the eighth part of an ongoing series about building a low cost, open source streaming internet radio based on the ASUS WL-520gU Wireless Router.  If you haven’t already, check out the previous parts (see the links at the end of this article) for some background about the project. In part seven, we added [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is the eighth part of an ongoing series about building a low cost, open source streaming internet radio based on the <a href="http://www.dpbolvw.net/click-3238164-10440897?url=http%3A%2F%2Fwww.newegg.com%2FProduct%2FProduct.aspx%3FItem%3DN82E16833320023%26nm_mc%3DAFC-C8Junction%26cm_mmc%3DAFC-C8Junction-_-Network%2B-%2BWireless%2BRouters-_-ASUS-_-33320023&amp;cjsku=N82E16833320023" target="_top">ASUS WL-520gU Wireless Router</a><img src="http://www.ftjcfx.com/image-3238164-10440897" border="0" alt="" width="1" height="1" />.  If you haven’t already, check out the previous parts (see the links at the end of this article) for some background about the project.</em></p>
<p>In <a href="http://mightyohm.com/blog/2008/12/building-a-wifi-radio-part-7-building-an-lcd-display/">part seven</a>, we added an LCD status display for the radio that shows the stream name as well as the artist and title of the current track.  In this part, we&#8217;ll add a tuning knob that lets us change stations without using a computer.</p>
<p>It turns out that this is mostly a software exercise, made simple by taking advantage of the analog to digital converter function of the Atmel ATmega168 AVR that is controlling the LCD display.  The addition of the tuner control turns the display circuit into a very simple user interface.  Turn the knob and the station changes.  The position of the knob determines what station the radio is &#8220;tuned&#8221; to, and when combined with a calibrated scale it will make it easy to change to any one of the several streaming radio stations stored as presets (favorites?) in the router.</p>
<p>To give you an idea of how this works, here is a demo of the tuner control changing between ten preset stations I have set on the router.  The tuner control is in the upper right hand corner of the breadboard.  As I adjust the control, the music changes and LCD display updates to show the name of each new station.</p>
<p><object width="500" height="375" data="http://www.flickr.com/apps/video/stewart.swf?v=67090" type="application/x-shockwave-flash"><param name="flashvars" value="intl_lang=en-us&amp;photo_secret=4181c97c88&amp;photo_id=3238566442" /><param name="bgcolor" value="#000000" /><param name="allowFullScreen" value="true" /><param name="src" value="http://www.flickr.com/apps/video/stewart.swf?v=67090" /><param name="allowfullscreen" value="true" /></object></p>
<p>Is that cool or what?</p>
<p>If you are interested in adding this functionality to the radio, keep reading and I&#8217;ll show you how.</p>
<h3>Changes to the hardware:</h3>
<h4>You will need:</h4>
<ul>
<li>The completed AVR-based LCD display from part seven</li>
<li>A 1k-10k trimmer or potentiometer, linear taper</li>
<li>Some hookup wire</li>
</ul>
<h4>Schematic:</h4>
<p>Here is an updated schematic of the AVR circuit showing the potentiometer connected to ADC4 (pin 27).</p>
<div id="attachment_1154" class="wp-caption alignnone" style="width: 509px"><a href="http://mightyohm.com/blog/wp-content/uploads/2009/02/interface.png"><img class="size-medium wp-image-1154" title="Wifi Radio User Interface Schematic" src="http://mightyohm.com/blog/wp-content/uploads/2009/02/interface-499x314.png" alt="Wifi Radio User Interface Schematic" width="499" height="314" /></a><p class="wp-caption-text">click to enlarge</p></div>
<h4>Firmware:</h4>
<p>The AVR firmware has been significantly expanded, slightly reworked and cleaned up in some areas.</p>
<p>The most important changes are:</p>
<ul>
<li>The addition of a serial transmit function so the AVR can talk to the router (based on the uart_putchar function)</li>
<li>New code supporting the analog to digital converter (ADC) which reads the value of a potentiometer connected to ADC4.</li>
<li>A new Timer1 overflow interrupt has been added, which occurs roughly every 0.5 seconds.  The interrupt service routine (ISR) checks the position of the tuner control, and if it has changed, sends the value to the router.  The ISR is towards the top of the file, see the SIGNAL (TIMER1_OVF_vect) section.</li>
</ul>
<p>The ADC range of the ATmega is 0 &#8211; 1024 for an input voltage from 0 to 5V.  The AVR sends serial data in the format &#8220;Tuner: Value&#8221; back to the router when the tuner position changes by more than ADC_SENS counts (default is 5).  The AVR waits for an &#8220;AVR Start!&#8221; command from the router before sending any data, this avoids filling up the serial receive buffer on the router before it&#8217;s ready to start processing data.  An important consequence of this is that the AVR must be reset before running the control script on the router.</p>
<p>You can download the source code and compiled .hex file <a href="http://mightyohm.com/files/wifiradio/AVR_wifiradio_interface.zip">here</a>.  Flash it to the AVR using any compatible ISP programmer and you should be good to go.  The source is commented fairly well so if you&#8217;re interested in learning how the interface works, take a look.  You will need a copy of the <a href="http://www.atmel.com/dyn/resources/prod_documents/doc2545.pdf">ATmega168 datasheet</a> to understand the register names and other architecture-specific parts of the code.  Feel free to post in the comments with any questions.</p>
<h4>Modifying the circuit:</h4>
<p>This part is pretty simple &#8211; just wire the potentiometer as shown in the schematic.  Most potentiometers have three terminals.  The left terminal goes to ground, the right one to +5V, and the middle terminal to ADC4 on the AVR (pin 27).</p>
<p><a class="tt-flickr tt-flickr-Medium" title="Tuner control on breadboard" href="http://www.flickr.com/photos/mightyohm/3238589400/"><img class="alignnone" src="http://farm4.static.flickr.com/3108/3238589400_3134e598cc.jpg" alt="Tuner control on breadboard" width="500" height="375" /></a></p>
<h3>Tweaks to the OpenWrt configuration:</h3>
<p>To make bidirectional communication with the AVR work, we have to change a couple config files on the router and disable some services that would otherwise get in the way.</p>
<h4>/etc/config/network</h4>
<p>The first change is to modify the /etc/config/network file so that we can always telnet or ssh into the router on a LAN port using the IP 192.168.1.1.  The ability to access the router via ethernet is helpful in case we screw something up and lose the wireless connection or the router loses it&#8217;s IP address, etc.</p>
<p>Modify the LAN section of /etc/config/network to look like this (changes in bold):</p>
<blockquote>
<pre>#### LAN configuration
config interface lan
<strong>#option type     bridge</strong>
option ifname    "eth0.0"
option proto    static
<strong>option ipaddr    192.168.1.1
option netmask    255.255.255.0</strong></pre>
</blockquote>
<p>Save changes, restart the router, and connect an ethernet <a href="http://en.wikipedia.org/wiki/Ethernet_crossover_cable">crossover cable</a> (straight cable might work on some computers) to the router.  Configure your desktop/laptop computer with a static IP, like 192.168.1.185.  Try to open a telnet connection (or ssh if you have set a password on the router) and see if you can log in.  If not, don&#8217;t continue with the next steps until you can get this working.</p>
<h4>/etc/inittab</h4>
<p>We previously used the router&#8217;s serial port to get a login shell.  Now that we&#8217;re trying to receive data from the AVR on the same serial port, we need to disable the login shell or it will capture the data before we can get to it.</p>
<p>Edit /etc/inittab to look like this (changes in bold):</p>
<blockquote>
<pre>::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K stop
<strong>#tts/0::askfirst:/bin/ash --login
#ttyS0::askfirst:/bin/ash --login</strong>
tty1::askfirst:/bin/ash --login</pre>
</blockquote>
<h4>/etc/sysctl.conf</h4>
<p><a href="http://en.wikipedia.org/wiki/System_request">Sysrq</a> is a fascinating and very low level debugging feature of the Linux kernel.  It can be used to perform troubleshooting operations and reboot the system.  Usually it is invoked with a <a href="http://en.wikipedia.org/wiki/Magic_SysRq_key">magic key combination</a> on a desktop computer, but in this case I found that it is easy to accidentally trip over the serial port when using an AVR.  (The &#8220;break&#8221; RS-232 code triggers Sysrq, this probably has something to do with it.)</p>
<p>Fortunately, it&#8217;s easy to disable by editing the /etc/sysctl.conf file and adding these lines:</p>
<blockquote>
<pre><strong># Disables the magic SysRq key
kernel.sysrq = 0</strong></pre>
</blockquote>
<p>Reboot the router to apply the changes.  Now we can get on with the good stuff!</p>
<h3>Shell scripting magic:</h3>
<p>The real action happens on the router, where a shell script waits for input from the router and changes the station accordingly.</p>
<p>This script is called <a href="http://mightyohm.com/files/wifiradio/interface.sh">interface.sh</a> and can be downloaded to the router using wget as shown:</p>
<blockquote>
<pre>root@OpenWrt:~# <strong>cd ~</strong>
root@OpenWrt:~# <strong>wget http://mightyohm.com/files/wifiradio/interface.sh</strong>
...
root@OpenWrt:~# <strong>chmod ugo+x interface.sh</strong></pre>
</blockquote>
<p>The interface script calls an updated version of the display script from part 7, called <a href="http://mightyohm.com/files/wifiradio/display2.sh">display2.sh</a>:</p>
<blockquote>
<pre>root@OpenWrt:~# <strong>wget http://mightyohm.com/files/wifiradio/display2.sh</strong>
...
root@OpenWrt:~# <strong>chmod ugo+x display2.sh</strong></pre>
</blockquote>
<p>Once both scripts are downloaded, executable and located in /root you can launch interface.sh as follows:</p>
<blockquote>
<pre>root@OpenWrt:~# <strong>./interface.sh</strong>
volume: 60%   repeat: on    random: off
volume: 60%   repeat: on    random: off
adding: http://relay3.slayradio.org:8000/
adding: http://scfire-dtc-aa01.stream.aol.com:80/stream/1046
adding: http://208.101.28.234:8004</pre>
<p>&#8230; more stations here &#8230;</p>
<pre>Tuner Position:  0
New station...

http://relay3.slayradio.org:8000/

[playing] #1/10   0:00/0:00 (100%)
volume: 60%   repeat: on    random: off</pre>
</blockquote>
<p>The interface script adds ten presets to the router, shows the playlist, and then waits for valid tuner data from the AVR.  Once it receives a &#8220;Tuner: value&#8221; line (which should occur shortly after the AVR receives a go signal from the script), the script prints the received tuner positon and changes to the requested station.  It will then wait for new tuner data from the AVR and change the station when necessary.</p>
<p>As you can see in the video, this works very well.  Over a fast Wi-Fi connection, the time to change stations is almost instantaneous &#8211; very satisfying!</p>
<p>That&#8217;s it for part eight.  In part nine, I&#8217;ll add some finishing touches to the router configuration and start talking about enclosures.  Stay tuned!</p>
<p><strong>Update:</strong> There is a new <a href="http://mightyohm.com/forum/viewforum.php?f=2">Wifi Radio Discussion Forum</a>, hop over there to ask questions about the project or see what other people are working on!  (<em>4/12/09)</em></p>
<p><strong>Update 2: </strong><a href="http://mightyohm.com/blog/2009/05/building-a-wifi-radio-part-9-a-few-odds-and-ends/">Part nine is now available.</a><em><br />
</em></p>
]]></content:encoded>
			<wfw:commentRss>http://mightyohm.com/blog/2009/02/building-a-wifi-radio-part-8-adding-a-tuning-control/feed/</wfw:commentRss>
		<slash:comments>68</slash:comments>
		</item>
		<item>
		<title>Building a Wifi Radio &#8211; Part 7, Building an LCD Display</title>
		<link>http://mightyohm.com/blog/2008/12/building-a-wifi-radio-part-7-building-an-lcd-display/</link>
		<comments>http://mightyohm.com/blog/2008/12/building-a-wifi-radio-part-7-building-an-lcd-display/#comments</comments>
		<pubDate>Thu, 18 Dec 2008 23:20:42 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[AVR]]></category>
		<category><![CDATA[avr-gcc]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[DIY]]></category>
		<category><![CDATA[Embedded Linux]]></category>
		<category><![CDATA[lcd]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[OpenWRT]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[Streaming Radio]]></category>
		<category><![CDATA[wifiradio]]></category>

		<guid isPermaLink="false">http://mightyohm.com/blog/?p=822</guid>
		<description><![CDATA[This is the seventh part of an ongoing series about building a low cost, open source streaming internet radio.  If you haven’t already, check out the previous parts (see the links at the end of this article) for some background about the project. In part six, we used OpenWrt&#8217;s UNIX-style shell commands to interface with [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is the seventh part of an ongoing series about building a low cost, open source streaming internet radio.  If you haven’t already, check out the previous parts (see the links at the end of this article) for some background about the project.</em></p>
<p>In <a href="http://mightyohm.com/blog/2008/12/building-a-wifi-radio-part-6-a-conversation-with-mpd/">part six</a>, we used <a href="http://www.busybox.net/downloads/BusyBox.html">OpenWrt&#8217;s UNIX-style shell commands</a> to interface with mpd, the music player daemon, and redirect song and stream information to our <a href="http://www.anrdoezrs.net/click-3238164-10440897?url=http%3A%2F%2Fwww.newegg.com%2FProduct%2FProduct.aspx%3FItem%3DN82E16833320023%26nm_mc%3DAFC-C8Junction%26cm_mmc%3DAFC-C8Junction-_-Network%2B-%2BWireless%2BRouters-_-ASUS-_-33320023&amp;cjsku=N82E16833320023" target="_top">ASUS WL-520gU</a><img src="http://www.lduhtrp.net/image-3238164-10440897" border="0" alt="" width="1" height="1" /> wireless router&#8217;s serial port.  In this part, we&#8217;ll use a Sparkfun 16&#215;2 LCD display and a handful of other components to build an LCD status display for the radio.</p>
<h3>The Atmel AVR Microcontroller:</h3>
<p>After much thought, I decided to use an <a href="http://www.atmel.com/dyn/products/Product_card.asp?part_id=3303">Atmel ATmega168 AVR microcontroller</a> to drive the display.  I realize that this raises the technical level of this project significantly, but I have been wanting to feature an <a href="http://en.wikipedia.org/wiki/Atmel_AVR">AVR</a> project on the site and this is a great opportunity.  The truth is that an <a href="http://www.arduino.cc">Arduino</a> would work just as well and it shouldn&#8217;t be too difficult to port this program to an <a href="http://www.arduino.cc/en/Tutorial/Sketch">Arduino sketch</a>.  (The Arduino is built with the same ATmega168 microcontroller, after all.)  If anyone does this, let me know and I&#8217;ll post a link to your version of the display.</p>
<p>If you&#8217;re an AVR veteran, you can skip over this part and straight to the bill of materials below.</p>
<p>If you are new to the AVR, don&#8217;t be intimidated.  There are a number of tutorials online to help you learn how to use this inexpensive and powerful microcontroller.  I recommend starting with <a href="http://www.ladyada.net/learn/avr/">this one</a> or maybe <a href="http://www.sparkfun.com/commerce/tutorial_info.php?tutorials_id=93">this one</a>, but see my note about AVR MacPack below if you&#8217;re using a Mac.  If you&#8217;ve never programmed in C before, you&#8217;ll have an additional hurdle to get over, although for this project you won&#8217;t need any actual knowledge of programming or C to burn the code to the AVR and get things working.</p>
<p>You will need to install some software to work with the AVR, I recommend:</p>
<ul>
<li><a href="http://www.obdev.at/products/avrmacpack/index.html">AVR MacPack</a> for OS X (the Adafruit tutorial recommends OSX-AVR, use this instead)</li>
<li><a href="http://winavr.sourceforge.net/">WinAVR</a> for Windows</li>
</ul>
<p>I recommend following a tutorial or two and getting a simple blinking LED example working on your AVR before building the LCD display.  That way you can be sure your programmer, development environment, breadboard, etc are working first.</p>
<h3>Building the display:</h3>
<h4>Bill of Materials:</h4>
<p>You will need:</p>
<ul>
<li>one A-B USB cable (the kind with one flat and one square end)</li>
<li>an AVR programmer, such as the <a href="http://www.adafruit.com/index.php?main_page=product_info&amp;products_id=46&amp;sessid=5f4b1ada86e5cbba0de9c9fb6cf45f10">Adafruit USBTinyISP</a></li>
<li>an <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=7957">Atmel ATmega168 AVR microcontroller</a></li>
<li>a working AVR development suite or at least a way to get a .hex file onto an AVR (see above)</li>
<li>an LCD display like this fancy LED backlit <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=255">Sparkfun 16&#215;2 Character STN</a></li>
<li>a <a href="http://en.wikipedia.org/wiki/Solderless_breadboard">solderless breadboard</a>, like <a href="http://www.amazon.com/gp/product/B0002H4W1E?ie=UTF8&amp;tag=mightyohm-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B0002H4W1E">this one</a> (comes with precut wires!)<img style="border: none !important; margin: 0px !important;" src="http://www.assoc-amazon.com/e/ir?t=mightyohm-20&amp;l=as2&amp;o=1&amp;a=B0002H4W1E" border="0" alt="" width="1" height="1" /> or <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=112">this one</a>.</li>
<li>a 4-pin female 0.1&#8243; header, this <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=115">breakaway header</a> is handy.</li>
<li>two 22pF ceramic capacitors, rated &gt;6V (mine are 25V)</li>
<li>a 0.1uF capacitor, rated &gt;6V</li>
<li>a 10 Ohm resistor</li>
<li>for contrast adjustment, a small 1k or 10k potentiometer</li>
<li>a few feet of 20 to 24 gauge solid hookup wire</li>
</ul>
<p>also nice, but not required:</p>
<ul>
<li>a <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=8508">Sparkfun ISP breakout board</a> to simplify connecting the programmer to the breadboard<a href="http://www.sparkfun.com/commerce/product_info.php?products_id=8508"><br />
</a></li>
<li>a normally-open pushbutton switch to reset the circuit</li>
</ul>
<h4>Schematic:</h4>
<p>Here is the schematic of the LCD display (click to enlarge):</p>
<p><a href="http://mightyohm.com/blog/wp-content/uploads/2008/12/avr_wifiradio_display.png"><img class="alignnone size-full wp-image-879" title="Wifi Radio LCD Display Schematic" src="http://mightyohm.com/blog/wp-content/uploads/2008/12/avr_wifiradio_display.png" alt="Wifi Radio LCD Display Schematic" width="500" height="315" /></a></p>
<h4>Firmware:</h4>
<p>You can download the source code and compiled .hex file <a href="http://mightyohm.com/files/wifiradio/AVR_wifiradio_display.zip">here</a>.</p>
<p>Special thanks to <a href="http://jump.to/fleury">Peter Fleury</a> for his excellent <a href="http://homepage.hispeed.ch/peterfleury/group__pfleury__lcd.html">LCD library</a>, which saved me from reinventing the wheel!  He also has another page about <a href="http://homepage.hispeed.ch/peterfleury/avr-lcd44780.html">interfacing LCD displays to an AVR</a>.</p>
<h3>Assembling the circuit:</h3>
<p>Assembling the circuit on the breadboard is pretty straightforward.  Here&#8217;s a photo showing all components of the setup.  The router is shown above with the serial port wired to the breadboard (the RX line is floating as we&#8217;re not using it yet).  The USB AVR programmer is on the right, where it is also functioning as a 5V power supply for the circuit. Make sure the 2-pin jumper on the USBTinyISP is installed, this enables the +5V supply.  The LCD is shown displaying the current stream name (<a href="http://di.fm">DI.fm</a>).</p>
<p><a class="tt-flickr tt-flickr-Medium" title="Wifi Radio LCD Display" href="http://www.flickr.com/photos/mightyohm/3113532375/"><img class="alignnone" src="http://farm4.static.flickr.com/3201/3113532375_f429580226.jpg" alt="Wifi Radio LCD Display" width="500" height="375" /></a></p>
<p>Here is a closeup of the components installed on the breadboard to show how I did things, feel free to experiment with the placement of components.  As long as you follow the schematic the circuit should still work.</p>
<p><a class="tt-flickr tt-flickr-Medium" title="Wifi Radio LCD Display" href="http://www.flickr.com/photos/mightyohm/3114364124/"><img class="alignnone" src="http://farm4.static.flickr.com/3017/3114364124_d4ab638540.jpg" alt="Wifi Radio LCD Display" width="500" height="375" /></a></p>
<p>Here is a closeup of the serial port connection to the router, including the 4-pin female 0.1&#8243; header.  I soldered wires to the pins of the female header (not the pins on the board).</p>
<p><a class="tt-flickr tt-flickr-Medium" title="Wifi Radio LCD Display" href="http://www.flickr.com/photos/mightyohm/3114364910/"><img class="alignnone" src="http://farm4.static.flickr.com/3037/3114364910_c1e27c1bfa.jpg" alt="Wifi Radio LCD Display" width="500" height="375" /></a></p>
<p>Here is a closeup of the AVR, crystal, and the <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=8508">Sparkfun ISP breakout board</a> showing the pinout:</p>
<p><a class="tt-flickr tt-flickr-Medium" title="Wifi Radio LCD Display" href="http://www.flickr.com/photos/mightyohm/3114364680/"><img class="alignnone" src="http://farm4.static.flickr.com/3293/3114364680_972485237a.jpg" alt="Wifi Radio LCD Display" width="500" height="375" /></a></p>
<h3>Flashing the AVR:</h3>
<p>Once the circuit is assembled on the breadboard, we need to flash the AVR microcontroller with the main.hex file included with the firmware above.</p>
<p>If you&#8217;re using AVR MacPack and OS X, this should be easy (since that&#8217;s what I&#8217;m using).  PC guys will need to figure this out for themselves but hopefully the process is similar (please let me know if the Makefile works).</p>
<p>Connect the USBTinyISP to your computer with the USB cable and to the breadboard with the ISP cable.  The green light on the programmer should be on, indicating it is ready, and the backlight of the LCD should be lit, indicating that the breadboard is getting power.</p>
<p>Open a terminal window and create a new directory, I used ~/temp.  Unzip the firmware into a directory somewhere, and execute &#8216;make flash&#8217;, as shown:</p>
<blockquote>
<pre>macbook:temp jkeyzer$ unzip ./AVR_wifiradio_display.zip
Archive:  ./AVR_wifiradio_display.zip
  inflating: lcd.c
  inflating: lcd.h
  inflating: main.c
  inflating: main.hex
  inflating: Makefile
macbook:temp jkeyzer$ make flash
avr-gcc -Wall -Os -DF_CPU=16000000 -mmcu=atmega168  -c main.c -o main.o</pre>
<p>a few warnings later &#8230;</p>
<pre>avr-gcc -Wall -Os -DF_CPU=16000000 -mmcu=atmega168  -c lcd.c -o lcd.o
avr-gcc -Wall -Os -DF_CPU=16000000 -mmcu=atmega168  -o main.elf main.o lcd.o
rm -f main.hex
avr-objcopy -j .text -j .data -O ihex main.elf main.hex
avrdude -c usbtiny -p atmega168 -U flash:w:main.hex:i</pre>
<pre>avrdude: AVR device initialized and ready to accept instructions</pre>
<pre>Reading | ################################################## | 100% 0.01s</pre>
<pre>avrdude: Device signature = 0x1e9406
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "main.hex"
avrdude: writing flash (1326 bytes):</pre>
<pre>Writing | ################################################## | 100% 3.32s</pre>
<pre>avrdude: 1326 bytes of flash written
avrdude: verifying flash memory against main.hex:
avrdude: load data flash data from input file main.hex:
avrdude: input file main.hex contains 1326 bytes
avrdude: reading on-chip flash data:</pre>
<pre>Reading | ################################################## | 100% 0.68s</pre>
<pre>avrdude: verifying ...
avrdude: 1326 bytes of flash verified</pre>
<pre>avrdude: safemode: Fuses OK</pre>
<pre>avrdude done.  Thank you.</pre>
</blockquote>
<p>If everything went well, the LCD display firmware is now loaded into the ATmega168 and the circuit is ready to go.  If not, double check your connections and take a look at the <a href="http://www.ladyada.net/make/usbtinyisp/help.html">help! page for the USBTinyISP</a>.</p>
<h3>Testing the display:</h3>
<p>Telnet or ssh into the router.  Start mpd and connect to a stream using mpc (we covered this in <a href="http://mightyohm.com/blog/2008/11/building-a-wifi-radio-part-5-lets-make-some-noise/">part five</a>).</p>
<p>Once the stream starts playing, execute the display.sh script we created in <a href="http://mightyohm.com/blog/2008/12/building-a-wifi-radio-part-6-a-conversation-with-mpd/">part six</a>.  Within a few seconds, if everything is working, you should see the stream name on the display, followed by the artist and name of the current song.  Congratulations!</p>
<p>Here is a video of the LCD display in action, including the horizontal scrolling feature to show information that is too wide to fit within the visible area of the display:<br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="500" height="375" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="data" value="http://www.flickr.com/apps/video/stewart.swf?v=63881" /><param name="flashvars" value="intl_lang=en-us&amp;photo_secret=88e8f450f5&amp;photo_id=3113563145" /><param name="bgcolor" value="#000000" /><param name="allowFullScreen" value="true" /><param name="src" value="http://www.flickr.com/apps/video/stewart.swf?v=63881" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="500" height="375" src="http://www.flickr.com/apps/video/stewart.swf?v=63881" allowfullscreen="true" bgcolor="#000000" flashvars="intl_lang=en-us&amp;photo_secret=88e8f450f5&amp;photo_id=3113563145" data="http://www.flickr.com/apps/video/stewart.swf?v=63881"></embed></object></p>
<p>That&#8217;s it for part seven!  In part eight, we&#8217;ll start working on the input side of the user interface.</p>
<p>Like what you&#8217;re seeing?  Have suggestions about what could be improved?  Leave a comment or <a href="http://mightyohm.com/blog/contact/">contact me directly</a>.</p>
<p><strong>Update:</strong> <a href="http://mightyohm.com/blog/2009/02/building-a-wifi-radio-part-8-adding-a-tuning-control/">Part eight</a>, in which I add a tuning control to the radio, is now available.</p>
<p><strong>Update 2:</strong> There is a new <a href="http://mightyohm.com/forum/viewforum.php?f=2">Wifi Radio Discussion Forum</a>, hop over there to ask questions about the project or see what other people are working on!  (<em>4/12/09)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://mightyohm.com/blog/2008/12/building-a-wifi-radio-part-7-building-an-lcd-display/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>Building a Wifi Radio &#8211; Part 6, A Conversation with Mpd</title>
		<link>http://mightyohm.com/blog/2008/12/building-a-wifi-radio-part-6-a-conversation-with-mpd/</link>
		<comments>http://mightyohm.com/blog/2008/12/building-a-wifi-radio-part-6-a-conversation-with-mpd/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 23:28:15 +0000</pubDate>
		<dc:creator>Jeff</dc:creator>
				<category><![CDATA[Microcontrollers]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[busybox]]></category>
		<category><![CDATA[DIY]]></category>
		<category><![CDATA[Embedded Linux]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mpd]]></category>
		<category><![CDATA[OpenWRT]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[Streaming Radio]]></category>
		<category><![CDATA[UNIX]]></category>
		<category><![CDATA[wifiradio]]></category>

		<guid isPermaLink="false">http://mightyohm.com/blog/?p=712</guid>
		<description><![CDATA[This is the sixth part of an ongoing series about building a low cost, open source streaming internet radio.  If you haven&#8217;t already, check out the previous parts (see the links at the end of this article) for some background about the project. Let&#8217;s review&#8230; It&#8217;s been a few weeks since I posted part five, [...]]]></description>
			<content:encoded><![CDATA[<p><em>This is the sixth part of an ongoing series about building a low cost, open source streaming internet radio.  If you haven&#8217;t already, check out the previous parts (see the links at the end of this article) for some background about the project.</em></p>
<h3>Let&#8217;s review&#8230;</h3>
<p>It&#8217;s been a few weeks since I posted <a href="http://mightyohm.com/blog/2008/11/building-a-wifi-radio-part-5-lets-make-some-noise/">part five</a>, so let&#8217;s quickly review where we are with this project:</p>
<p>At this point we have a hacked <a href="http://www.kqzyfj.com/click-3238164-10440897?url=http%3A%2F%2Fwww.newegg.com%2FProduct%2FProduct.aspx%3FItem%3DN82E16833320023%26nm_mc%3DAFC-C8Junction%26cm_mmc%3DAFC-C8Junction-_-Network%2B-%2BWireless%2BRouters-_-ASUS-_-33320023&amp;cjsku=N82E16833320023" target="_top">ASUS WL-520gU wireless router</a><img src="http://www.awltovhc.com/image-3238164-10440897" border="0" alt="" width="1" height="1" /> running <a href="http://www.openwrt.org">OpenWrt</a> (Linux).   A <a href="http://www.jdoqocy.com/click-3238164-10440897?url=http%3A%2F%2Fwww.newegg.com%2FProduct%2FProduct.aspx%3FItem%3DN82E16812186035%26nm_mc%3DAFC-C8Junction%26cm_mmc%3DAFC-C8Junction-_-Adapters%2Band%2Bgender%2Bchangers-_-Syba-_-12186035&amp;cjsku=N82E16812186035" target="_top">cheap USB-audio adapter</a><img src="http://www.awltovhc.com/image-3238164-10440897" border="0" alt="" width="1" height="1" /> is connected to the router&#8217;s single USB port, and in <a href="http://mightyohm.com/blog/2008/11/building-a-wifi-radio-part-4-installing-openwrt/">part four</a> we installed kernel drivers for Linux USB and audio support.  In <a href="http://mightyohm.com/blog/2008/10/building-a-wifi-radio-part-3-hacking-the-asus-wl-520gu/">part three</a> we added a connection to the router&#8217;s internal serial port via a 4-pin header.  Wireless networking worked pretty much out of the box, and in <a href="http://mightyohm.com/blog/2008/11/building-a-wifi-radio-part-5-lets-make-some-noise/">part five</a> we used <em>opkg</em>, OpenWrt&#8217;s package manager, to install <em>mpd</em>, the Linux music player daemon, and <em>mpc</em>, a command-line-based mpd client.</p>
<p>This gives us a compact networked device that can wirelessly connect to streaming radio stations and play 16-bit 44kHz stereo audio on a pair of headphones or amplified external speakers.  Pretty impressive, given that this device started as an inexpensive wireless router!</p>
<h3>What&#8217;s missing?</h3>
<p>Something big is missing from the radio.  The original concept for this radio was that it would be a standalone device.  Shell access is cool, and <a href="http://mpd.wikia.com/wiki/Client:MPoD2">iPhone control</a> is even better, but ideally we&#8217;d like to be able to see what song and station are currently playing as well as change stations without the use of another computer or mobile client.</p>
<p>What we need is a user interface!</p>
<p>Based on our requirements, the user interface needs to do two things:</p>
<ol>
<li>Display information about what&#8217;s playing from mpd</li>
<li>Gather input from the user and tell mpd when to change stations.</li>
</ol>
<p>A volume control will be part of our finished user interface as well, but it will be simple enough to do this in hardware when we put the radio into an enclosure.  In this part, we&#8217;ll start work on the first requirement &#8211; the display.</p>
<p><em>Note: The following steps assume you are accessing the OpenWrt shell through a telnet or ssh connection, not using the FTDI USB-serial cable.  The reasons for this will become obvious later, when we start using the router&#8217;s serial port for other purposes!</em></p>
<p>First of all, how do we get information about what&#8217;s currently playing on our radio?</p>
<h3>Chatting with mpd:</h3>
<p>The command-line program mpc that we installed in part five will return information about the current song if we execute it without any options:</p>
<blockquote>
<pre>root@OpenWrt:~# mpc
SLAY Radio: Jogeir Liljedahl - Terra Cresta
[playing] #1/5  22:36/0:00 (100%)
volume: 60%   repeat: on    random: off</pre>
</blockquote>
<p>Mpc obtains playlist, volume, and settings information by sending queries to the <em>mpd</em> server running on the router.  The mpd site includes an overview of the <a href="http://mpd.wikia.com/wiki/MusicPlayerDaemonProtocolOutline">communications protocol</a> and <a href="http://mpd.wikia.com/wiki/MusicPlayerDaemonCommands">command set</a>.  By default, mpd listens for commands on port 6600.  You can access this port remotely by using one of many client programs, or locally by opening a telnet connection to port 6600 locally (the commands are in bold for clarity):</p>
<blockquote>
<pre>root@OpenWrt:~#<strong> telnet localhost:6600</strong>
OK MPD 0.13.0
<strong>status
</strong>volume: 60
repeat: 1
random: 0
playlist: 14
playlistlength: 5x
fade: 0
state: play
song: 4
songid: 4
time: 2348:0
bitrate: 192
audio: 44100:16:2
OK
<strong>currentsong
</strong>file: http://relay3.slayradio.org:8000/
Name: SLAY Radio
Title: Jogeir Liljedahl - Terra Cresta
Pos: 0
Id: 0
OK</pre>
</blockquote>
<p>The connection will timeout in about a minute if left idle.</p>
<p>As you can see, there is a lot of information available, including some of the same information mpc gave us earlier.  The advantage of directly accessing mpd is that we get the stream name (the Name: line) and the artist/title (the Title: line) broken down separately instead of on one continuous line, with handy labels that will make it easy for us to parse the data later.</p>
<p>We can also access mpd by using the <a href="http://en.wikipedia.org/wiki/Netcat"><em>nc</em></a> command, short for &#8220;network cat&#8221;.  Using nc allows us to easily pipe data from other commands to mpd and examine the results.</p>
<blockquote>
<pre>root@OpenWrt:~# <strong>echo "currentsong" | nc localhost 6600</strong>
file: http://relay3.slayradio.org:8000/
Name: SLAY Radio
Title: Jogeir Liljedahl - Terra Cresta
Pos: 0
Id: 0
OK</pre>
</blockquote>
<p>(As an aside, OpenWrt uses a program called <a href="http://www.busybox.net/">busybox</a> to emulate a UNIX-style shell environment &#8211; several common shell commands are included.  There is considerable documentation <a href="http://www.busybox.net/downloads/BusyBox.html">here</a>, but not all commands listed are actually included in the default OpenWrt busybox installation.)</p>
<p>If we just want the name and title of the current song, we can use the UNIX command <a href="http://en.wikipedia.org/wiki/Grep"><em>grep</em></a> to strip out just those two lines:</p>
<blockquote>
<pre>root@OpenWrt:~#<strong> echo "currentsong" | nc localhost 6600 | grep -e "^Title: " -e "^Name: "
</strong>
Name: SLAY Radio
Title: Jogeir Liljedahl - Terra Cresta</pre>
</blockquote>
<h3>Talking to external devices:</h3>
<p>Now that we have a way to get song information from mpd, we need a way to direct this information to an external display.  The router comes with a handy mechanism for doing this &#8211; the builtin serial port.  Linux makes it easy to direct the output of grep to the router&#8217;s serial port, just add a <a href="http://en.wikipedia.org/wiki/Redirection_(computing)">redirect</a> to /dev/tts/0 at the end of the command (all on one line, wrapped here to fit the page):</p>
<blockquote>
<pre>root@OpenWrt:~#<strong> echo "currentsong" | </strong><strong><strong>nc localhost 6600 | grep -e "^Title: "
-e "^Name: "</strong></strong><strong> &gt; /dev/tts/0</strong>
root@OpenWrt:~#</pre>
</blockquote>
<p>However, it turns out that the serial port&#8217;s default speed of 115200 baud is too fast for some external displays.  If we want to be able to talk to an <a href="http://en.wikipedia.org/wiki/Atmel_AVR">AVR microcontroller</a>, for example, we need to change the speed of the serial port from it&#8217;s default value of 115200 to 9600 baud.  This can be done easily with the <a href="http://www.freebsd.org/cgi/man.cgi?query=stty&amp;sektion=1"><em>stty</em></a> command.</p>
<p><em>Note: If you downloaded and installed OpenWrt prior to December 3rd by using the files on this site, stty is most likely missing from your installation.  Unfortunately, the only way I know of to easily fix this is to completely reinstall OpenWrt, since stty is part of busybox and included in the base firmware image.  You can check if you have it by executing &#8216;stty&#8217; from the command line of the router &#8211; if you get an error, you will need to reinstall.</em></p>
<p>You can change the baud rate of the serial port by executing:</p>
<blockquote>
<pre>root@OpenWrt:~#<strong> stty 9600 &lt; /dev/tts/0</strong></pre>
</blockquote>
<p>Connect your FTDI USB-serial cable to the router&#8217;s serial port and open a terminal program set to 9600 baud, 8N1. Execute the last mpd query again, you should see the name and title appear in your terminal window:</p>
<blockquote>
<pre>root@OpenWrt:~#<strong> echo "currentsong" | </strong><strong><strong>nc localhost 6600 | grep -e "^Title: "
-e "^Name: "</strong></strong><strong> &gt; /dev/tts/0</strong></pre>
<p>In the terminal window:</p>
<pre>Name: SLAY Radio
Title: Jogeir Liljedahl - Terra Cresta</pre>
</blockquote>
<p>Now we have a way to get information about the current song and direct it to the serial port.</p>
<p>We can do this is an automated way by using a shell script:</p>
<blockquote>
<pre>#! /bin/sh -
# display.sh - Wifi Radio LCD display routines
# 12/12/08    Jeff Keyzer    http://mightyohm.com
# This shell script queries mpd for current song information and sends
# relevant bits of it to the serial port, where an AVR-based LCD display
# is waiting.
#
# For more information, visit
# http://mightyohm.com/blog/
#
trap 'exit 1' SIGINT    # exit on ctrl-c, useful for debugging
stty 9600 &lt; /dev/tts/0  # set serial port to 9600 baud
                        # so we can talk to the AVR
while true        # loop forever
do
 echo "currentsong" | nc localhost 6600 | grep -e "^Title: " -e "^Name: " &gt; /dev/tts/0
 sleep 1
done</pre>
</blockquote>
<p>You can either copy and paste this script to a file on the router, or download it with <a href="http://en.wikipedia.org/wiki/Wget"><em>wget</em></a>:</p>
<blockquote>
<pre>root@OpenWrt:~# <strong>cd ~</strong>
root@OpenWrt:~# <strong>wget http://mightyohm.com/files/wifiradio/display.sh</strong>
Connecting to mightyohm.com (72.32.209.132:80)
display.sh           100% |*******************************|   668  --:--:-- ETA</pre>
</blockquote>
<p>Be sure to make the script executable by using <a href="http://en.wikipedia.org/wiki/Chmod"><em>chmod</em></a>:</p>
<blockquote>
<pre>root@OpenWrt:~# <strong>chmod ugo+x display.sh</strong></pre>
</blockquote>
<p>If you run the script you should see the name and title information update in the serial terminal once a second.</p>
<blockquote>
<pre>root@OpenWrt:~# ./display.sh</pre>
</blockquote>
<p>The script will loop forever &#8211; hit control-c in the router&#8217;s shell to exit.</p>
<p>That&#8217;s it for part six!  In <a href="http://mightyohm.com/blog/2008/12/building-a-wifi-radio-part-7-building-an-lcd-display/">part seven</a>, we&#8217;ll add an AVR-based serial LCD display to the router &#8211; stay tuned!</p>
<p><strong>Update:</strong> <a href="http://mightyohm.com/blog/2008/12/building-a-wifi-radio-part-7-building-an-lcd-display/">Part seven is now available.</a></p>
<p><strong>Update 2:</strong> There is a new <a href="http://mightyohm.com/forum/viewforum.php?f=2">Wifi Radio Discussion Forum</a>, hop over there to ask questions about the project or see what other people are working on!  (<em>4/12/09)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://mightyohm.com/blog/2008/12/building-a-wifi-radio-part-6-a-conversation-with-mpd/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

