Building a Wifi Radio – Part 9, A Few Odds and Ends

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 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 part seven lets us know what stream we’re listening to and the artist and title of the current song.  This project is coming together very nicely!

Before we put the final touches on this project in part ten, there are a few miscellaneous chores to take care of:

Fixing /etc/config/wireless:

Last time, 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.

To fix this, modify /etc/config/wireless as follows (changes are in bold, use your wireless network information in place of my example):

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  wan
    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

The only change is to set “option network” to “wan” instead of “lan”.  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.

Launching mpd automatically at startup:

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:

root@OpenWrt:~# ln -s /etc/init.d/mpd /etc/rc.d/S93mpd

Now every time the router boots, mpd will be started automatically as part of the boot process.  (That was easy!)

Boot script for the user interface:

Assuming we want a dedicated internet radio that doesn’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.

First, we need to create a simple boot script.  Create the file /etc/init.d/AVR with the following contents:

#!/bin/sh /etc/rc.common
# Copyright (C) 2008 OpenWrt.org
START=99
start() {
sleep 5    # make sure boot process is done, no more console messages
/root/interface.sh
}

To launch the script at boot, create a symbolic link as follows:

root@OpenWrt:~# ln -s /etc/init.d/AVR /etc/rc.d/S99AVR

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.

Tweaking the firewall configuration:

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.

The file /etc/config/firewall controls the firewall settings.  We’ll be modifying this file.

Open the file in vi and scroll down to this section:

config zone
    option name        wan
    option input    REJECT
    option output    ACCEPT
    option forward    REJECT
    option masq        1

Edit the “option input” line so that it looks like this:

config zone
    option name        wan
    option input    ACCEPT
    option output    ACCEPT
    option forward    REJECT
    option masq        1

Now restart the firewall (or just reboot the router):

root@OpenWrt:~# /etc/init.d/firewall restart

You should now be able to ssh or telnet into the router over your wireless network.

Enable SSH:

By the way, if you want to access the router with ssh instead of telnet, just set a root password.  The telnet daemon will be disabled (for security reasons) and replaced with an SSH daemon instead.  You can do this with the “passwd” command.

root@OpenWrt:~# passwd
Changing password for root
New password: *****
Retype password: *****
Password for root changed by root
root@OpenWrt:~#

Log out of your telnet session and use ssh to log back in with your favorite ssh client (don’t forget to tell the client to use the username “root”).

Stay tuned!

Wifi Radio Enclosure - Google Sketchup Model

That’s it for now.  Stay tuned for the final part in this series, part ten, in which I’ll talk about what it took to turn this Sketchup model into a real wooden case for the radio!

Update: Part ten (the final part in the series) is now online.

My new oscilloscope – the Agilent DSO1014A

New Oscilloscope

Over the Memorial Day weekend I had a chance to spend a little bit of time with my new Agilent DSO1014A oscilloscope.

The Agilent 1000 family was just introduced on May 4th, 2009.  Since it’s a brand new model, I had to look around a bit to find one in stock at one of Agilent’s distributors.  Agilent quoted a 6-8 week leadtime and said I probably wouldn’t be able to find one anywhere before late June, but with a little searching I spotted one at Newark Electronics.  Two days later, it was running a self calibration in my lab.  Thanks, Newark!

The DSO1014A is a digital storage oscillscope.  The primary advantage of a digital oscilloscope over a traditional analog scope is that waveforms can be easily captured and analyzed even after the original signal is long gone.  Brief transients in the input signals can be viewed by carefully triggering a digital storage oscilloscope.  This is almost impossible to do with a simple analog scope.

Here’s a brief feature list for the DSO1014A along with some of my notes:

  • 100MHz bandwidth (the higher end DSO1024A has 200MHz BW)
  • 4 channels (most low cost scopes only have 2, this was a big selling point)
  • 1GS/s sampling rate per channel (pretty standard), 2GS/s in half channel mode (impressive!)
  • 10kpts/channel record length, 20kpts/s in half channel mode (another big selling point for me)
  • front panel USB connector for recording screenshots to USB stick (yes!!!)

This scope will be a huge upgrade from the analog scope I have been using (an ancient 20MHz Hitachi V212).  While it won’t be able to view USB 2.0 eye diagrams, it should be more than good enough for general purpose use around the lab.

To see more photos of the scope, check out the full album on Flickr.

New Oscilloscope
New Oscilloscope
New Oscilloscope
New Oscilloscope

New Oscilloscope
New Oscilloscope
New Oscilloscope
New Oscilloscope

Video of my NOTACON talk now online

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’t like either option, you can also download the m4v source file from here (thanks Vimeo!).

Special thanks to Media Archives for recording my talk!

NOTACON 6 – Hacking the Asus WL-520gU Wireless Router from MightyOhm on Vimeo.

Keith’s Hotplate and PID Controller Teardown Pics

Keith of Keith’s Electronics Blog made a PID-Controlled Soldering Hotplate based on the one I fabricated earlier this year.  He’s already using it to build the stepper controller PCB for the MakerBot CupCake CNC!

He also posted a bunch of teardown photos (like the one shown below) of the CD101 PID Controller from Sure Electronics.  I suspect the CD101 is a cheap knockoff of an RKC PID controller since I can’t find the part number on RKC’s website, even though the front panel clearly says RKC on it.  I guess at $40 you can’t ask too many questions, the price is right…

Copycat PID-Controlled Solder Hotplate « Keith’s Electronics Blog.