{"id":1872,"date":"2009-05-27T08:31:19","date_gmt":"2009-05-27T15:31:19","guid":{"rendered":"http:\/\/mightyohm.com\/blog\/?p=1872"},"modified":"2022-12-28T13:13:13","modified_gmt":"2022-12-28T21:13:13","slug":"building-a-wifi-radio-part-9-a-few-odds-and-ends","status":"publish","type":"post","link":"https:\/\/mightyohm.com\/blog\/2009\/05\/building-a-wifi-radio-part-9-a-few-odds-and-ends\/","title":{"rendered":"Building a Wifi Radio &#8211; Part 9, A Few Odds and Ends"},"content":{"rendered":"<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\" rel=\"noopener\">ASUS WL-520gU Wireless Router<\/a><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.ftjcfx.com\/image-3238164-10440897\" border=\"0\" alt=\"\" width=\"1\" height=\"1\" \/>.\u00a0 If you haven\u2019t already, check out the previous parts (see the links at the end of this article) for some background about the project.<\/em><\/p>\n<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.\u00a0 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. \u00a0 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.\u00a0 This project is coming together very nicely!<\/p>\n<p>Before we put the final touches on this project in part ten, there are a few miscellaneous chores to take care of:<\/p>\n<h3>Fixing \/etc\/config\/wireless:<\/h3>\n<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.\u00a0 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.\u00a0 Unfortunately, I made an omission in the setup instructions which may prevent this from working correctly.<\/p>\n<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>\n<pre style=\"padding-left: 30px;\">config wifi-device\u00a0 wl0\r\n\u00a0\u00a0\u00a0 option type\u00a0\u00a0\u00a0\u00a0 broadcom\r\n\u00a0\u00a0\u00a0 option channel\u00a0 3\r\n\r\n\u00a0\u00a0\u00a0 # REMOVE THIS LINE TO ENABLE WIFI:\r\n\u00a0\u00a0\u00a0 # option disabled 1\r\n\r\nconfig wifi-iface\r\n\u00a0\u00a0\u00a0 option device\u00a0\u00a0 wl0\r\n\u00a0\u00a0\u00a0 option network\u00a0 <strong>wan<\/strong>\r\n    option mode     sta  # configures the router to connect to your network\r\n    option ssid     MyNetwork # the SSID of your network\r\n    option encryption wep  # the encryption mode of your network\r\n    option key\tXXXXXXXXXX  # add this line with your WEP key in place of X...X<\/pre>\n<p>The only change is to set &#8220;option network&#8221; to &#8220;wan&#8221; instead of &#8220;lan&#8221;.\u00a0 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>\n<h3>Launching mpd automatically at startup:<\/h3>\n<p>Manually launching mpd every time the router boots is a drag.\u00a0 You can automate this by creating a symbolic link to \/etc\/init.d\/mpd from the \/etc\/rc.d directory, as follows:<\/p>\n<pre style=\"padding-left: 30px;\">root@OpenWrt:~# ln -s \/etc\/init.d\/mpd \/etc\/rc.d\/S93mpd<\/pre>\n<p>Now every time the router boots, mpd will be started automatically as part of the boot process.\u00a0 (That was easy!)<\/p>\n<h3>Boot script for the user interface:<\/h3>\n<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.\u00a0 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>\n<p>First, we need to create a simple boot script.\u00a0 Create the file \/etc\/init.d\/AVR with the following contents:<\/p>\n<pre style=\"padding-left: 30px;\">#!\/bin\/sh \/etc\/rc.common\r\n# Copyright (C) 2008 OpenWrt.org<\/pre>\n<pre style=\"padding-left: 30px;\">START=99\r\nstart() {\r\nsleep 5\u00a0\u00a0\u00a0 # make sure boot process is done, no more console messages\r\n\/root\/interface.sh\r\n}<\/pre>\n<p>To launch the script at boot, create a symbolic link as follows:<\/p>\n<pre style=\"padding-left: 30px;\">root@OpenWrt:~# ln -s \/etc\/init.d\/AVR \/etc\/rc.d\/S99AVR<\/pre>\n<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>\n<h3>Tweaking the firewall configuration:<\/h3>\n<p>This is actually optional, but it can be pretty useful while hacking on the router.\u00a0 As presently configured, the router blocks incoming requests on the WAN, which now includes the wireless interface.\u00a0 This prevents us from using ssh or telnet to log into the router over our wireless network.\u00a0 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>\n<p>The file \/etc\/config\/firewall controls the firewall settings.\u00a0 We&#8217;ll be modifying this file.<\/p>\n<p>Open the file in vi and scroll down to this section:<\/p>\n<pre style=\"padding-left: 30px;\">config zone\r\n\u00a0\u00a0\u00a0 option name\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 wan\r\n\u00a0\u00a0\u00a0 option input\u00a0\u00a0\u00a0 REJECT\r\n\u00a0\u00a0\u00a0 option output\u00a0\u00a0\u00a0 ACCEPT\r\n\u00a0\u00a0\u00a0 option forward\u00a0\u00a0\u00a0 REJECT\r\n\u00a0\u00a0\u00a0 option masq\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 1<\/pre>\n<p>Edit the &#8220;option input&#8221; line so that it looks like this:<\/p>\n<pre style=\"padding-left: 30px;\">config zone\r\n\u00a0\u00a0\u00a0 option name\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 wan\r\n\u00a0\u00a0\u00a0<strong> option input\u00a0\u00a0\u00a0 ACCEPT<\/strong>\r\n\u00a0\u00a0\u00a0 option output\u00a0\u00a0\u00a0 ACCEPT\r\n\u00a0\u00a0\u00a0 option forward\u00a0\u00a0\u00a0 REJECT\r\n\u00a0\u00a0\u00a0 option masq\u00a0\u00a0\u00a0 \u00a0\u00a0\u00a0 1<\/pre>\n<p>Now restart the firewall (or just reboot the router):<\/p>\n<pre style=\"padding-left: 30px;\">root@OpenWrt:~# \/etc\/init.d\/firewall restart<\/pre>\n<p>You should now be able to ssh or telnet into the router over your wireless network.<\/p>\n<h3>Enable SSH:<\/h3>\n<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.\u00a0 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.\u00a0 You can do this with the &#8220;passwd&#8221; command.<\/p>\n<pre style=\"padding-left: 30px;\">root@OpenWrt:~# passwd\r\nChanging password for root\r\nNew password: *****\r\nRetype password: *****\r\nPassword for root changed by root\r\nroot@OpenWrt:~#<\/pre>\n<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>\n<h3>Stay tuned!<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone\" src=\"http:\/\/mightyohm.com\/files\/flickr\/3306019406_7879de7ace_m.jpg\" alt=\"Wifi Radio Enclosure - Google Sketchup Model\" width=\"240\" height=\"161\" \/><\/p>\n<p>That&#8217;s it for now.\u00a0 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>\n<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>\n","protected":false},"excerpt":{"rendered":"<p>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.\u00a0 If you haven\u2019t 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 &hellip; <a href=\"https:\/\/mightyohm.com\/blog\/2009\/05\/building-a-wifi-radio-part-9-a-few-odds-and-ends\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Building a Wifi Radio &#8211; Part 9, A Few Odds and Ends<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[5,10,443],"tags":[61,66,97,68,165,162,73],"class_list":["post-1872","post","type-post","status-publish","format-standard","hentry","category-electronics","category-microcontrollers","category-projects-2","tag-avr","tag-linux","tag-mpd","tag-openwrt","tag-shell-script","tag-wifiradio","tag-wireless"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pioCd-uc","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":2081,"url":"https:\/\/mightyohm.com\/blog\/2009\/07\/building-a-wifi-radio-leave-a-comment-here\/","url_meta":{"origin":1872,"position":0},"title":"Building a Wifi Radio?  Leave a comment here!","author":"Jeff","date":"July 7, 2009","format":false,"excerpt":"Did my Wifi Radio project inspire you to buy a wireless router and start hacking?\u00a0 If so, I'd like to hear from you! Leave a comment below and let me know how your project is coming along.\u00a0 Even if you're not building a Wifi Radio but used my firmware or\u2026","rel":"","context":"In &quot;Projects&quot;","block_context":{"text":"Projects","link":"https:\/\/mightyohm.com\/blog\/category\/projects-2\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":367,"url":"https:\/\/mightyohm.com\/blog\/2008\/10\/building-a-wifi-radio-part-2-choosing-an-embedded-platform\/","url_meta":{"origin":1872,"position":1},"title":"Building a Wifi Radio &#8211; Part 2, Choosing an Embedded Platform","author":"Jeff","date":"October 17, 2008","format":false,"excerpt":"This is the second part of an ongoing series about building a low cost, open source streaming internet radio.\u00a0 if you haven't already, check out part one for some background about the project. Onward... In part one, I discussed the merits of streaming internet radio and the motivations for my\u2026","rel":"","context":"In &quot;Electronics&quot;","block_context":{"text":"Electronics","link":"https:\/\/mightyohm.com\/blog\/category\/electronics\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mightyohm.com\/blog\/wp-content\/uploads\/2008\/10\/hammer_01-large-150x150.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":333,"url":"https:\/\/mightyohm.com\/blog\/2008\/10\/building-a-wifi-radio-part-1-introduction\/","url_meta":{"origin":1872,"position":2},"title":"Building a Wifi Radio &#8211; Part 1, Introduction","author":"Jeff","date":"October 9, 2008","format":false,"excerpt":"This article is the first of a series that will document the development of a low cost, open source wireless streaming internet radio receiver.\u00a0 All construction details, including schematics, source code, and even the design process itself will be documented on this blog. Comments and (constructive) criticism are welcome. Click\u2026","rel":"","context":"In &quot;Electronics&quot;","block_context":{"text":"Electronics","link":"https:\/\/mightyohm.com\/blog\/category\/electronics\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mightyohm.com\/blog\/wp-content\/uploads\/2008\/10\/3567609195_26d2582df5_o.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/mightyohm.com\/blog\/wp-content\/uploads\/2008\/10\/3567609195_26d2582df5_o.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/mightyohm.com\/blog\/wp-content\/uploads\/2008\/10\/3567609195_26d2582df5_o.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/mightyohm.com\/blog\/wp-content\/uploads\/2008\/10\/3567609195_26d2582df5_o.jpg?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/mightyohm.com\/blog\/wp-content\/uploads\/2008\/10\/3567609195_26d2582df5_o.jpg?resize=1050%2C600&ssl=1 3x, https:\/\/i0.wp.com\/mightyohm.com\/blog\/wp-content\/uploads\/2008\/10\/3567609195_26d2582df5_o.jpg?resize=1400%2C800&ssl=1 4x"},"classes":[]},{"id":1902,"url":"https:\/\/mightyohm.com\/blog\/2009\/05\/sneak-peak-at-my-finished-wifi-radio-project\/","url_meta":{"origin":1872,"position":3},"title":"Sneak peek at my finished Wifi Radio project!","author":"Jeff","date":"May 28, 2009","format":false,"excerpt":"While I'm busy working on part ten of my series on building a wireless router-based DIY streaming internet radio, I couldn'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\u2026","rel":"","context":"In &quot;Electronics&quot;","block_context":{"text":"Electronics","link":"https:\/\/mightyohm.com\/blog\/category\/electronics\/"},"img":{"alt_text":"Finished Wifi Radio","src":"https:\/\/i0.wp.com\/mightyohm.com\/files\/flickr\/3567609195_79760d88fe.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1887,"url":"https:\/\/mightyohm.com\/blog\/2009\/05\/building-a-wifi-radio-part-10-building-the-box\/","url_meta":{"origin":1872,"position":4},"title":"Building a Wifi Radio &#8211; Part 10, Building the Box","author":"Jeff","date":"May 29, 2009","format":false,"excerpt":"This is the tenth and final part of a series about building a low cost, open source streaming internet radio based on the ASUS WL-520gU Wireless Router.\u00a0 If you haven\u2019t already, check out the previous parts (see the links below) for some background about the project. Wow, we've come a\u2026","rel":"","context":"In &quot;Electronics&quot;","block_context":{"text":"Electronics","link":"https:\/\/mightyohm.com\/blog\/category\/electronics\/"},"img":{"alt_text":"","src":"http:\/\/www.ftjcfx.com\/image-3238164-10440897","width":350,"height":200},"classes":[]},{"id":480,"url":"https:\/\/mightyohm.com\/blog\/2008\/10\/building-a-wifi-radio-part-3-hacking-the-asus-wl-520gu\/","url_meta":{"origin":1872,"position":5},"title":"Building a Wifi Radio &#8211; Part 3, Hacking the Asus WL-520GU","author":"Jeff","date":"October 30, 2008","format":false,"excerpt":"This is the third part of an ongoing series about building a low cost, open source streaming internet radio.\u00a0 If you haven\u2019t already, check out part one and part two for some background about the project. Hacking the Asus WL-520GU Wireless Router: In the last part of this series, I\u2026","rel":"","context":"In &quot;Electronics&quot;","block_context":{"text":"Electronics","link":"https:\/\/mightyohm.com\/blog\/category\/electronics\/"},"img":{"alt_text":"","src":"http:\/\/www.awltovhc.com\/image-3238164-10440897","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/posts\/1872","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/comments?post=1872"}],"version-history":[{"count":19,"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/posts\/1872\/revisions"}],"predecessor-version":[{"id":15850,"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/posts\/1872\/revisions\/15850"}],"wp:attachment":[{"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/media?parent=1872"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/categories?post=1872"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mightyohm.com\/blog\/wp-json\/wp\/v2\/tags?post=1872"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}