Tag Archives: USB

David Nichols’ Tweetster, a wireless Twitter display

David Nichols made this awesome wireless twitter display by combining a hacked Asus WL-520gU wireless router with a Sparkfun serial-enabled LCD display.  The router is running the same OpenWrt distribution I used for my Wifi Radio project, plus a USB thumbdrive that provides some additional flash storage space.  I really like the custom laser cut base that holds the LCD display and the router!

For more pics and info, check out David’s flickr set for the project.

via Make: Online – Tweetster – Wireless tweets display

Building a Wifi Radio – Part 5, Let’s Make Some Noise!

This is the fifth part of an ongoing series at mightyOhm about building a low cost, open source streaming internet radio.  If you haven’t already, check out the previous parts below for some background about the project.

Building a Wifi Radio – Part 1, Introduction

Building a Wifi Radio – Part 2, Choosing an Embedded Platform

Building a Wifi Radio – Part 3, Hacking the Asus WL-520GU

Building a Wifi Radio – Part 4, Installing OpenWrt


The instructions that follow assume that you have an Asus WL-520GU wireless router with the following modifications: an externally accessible serial port, OpenWrt installed and working, and a configured network connection on the router.  If not, check out the previous parts of the series to learn more.

Using opkg to customize OpenWrt:

OpenWrt includes a utility called opkg that allows the end user to easily add and remove optional software packages.  These packages include functionality that is not a part of the OpenWrt base image, such as hardware drivers (including USB), optional software, and utilities.  Most packages are not installed by default (after all, the router only contains 4MB of flash storage).  The OpenWrt Community Wiki includes a very helpful page about Packages that contains a lot of useful information about configuring and using opkg.

Before we can use opkg we need to configure it.  The file /etc/opkg.conf contains a few options, including the URL of the server opkg uses to find and download packages.  We need to change this server from the default by modifying the config file:

root@OpenWrt:~# vi /etc/opkg.conf

Modify the first line to look like this:

src/gz snapshots http://mightyohm.com/files/kamikaze-2.4/packages/mipsel 
dest root /
dest ram /tmp
lists_dir ext /var/opkg-lists

You can also download the complete set of packages and set up a server of your own for opkg to access.  I have had great success using the apache server included with OS X, but I won’t cover the setup here.

The following command tells opkg to fetch a list of available packages from the server:

root@OpenWrt:~# opkg update

You should see the following response:

Downloading http://mightyohm.com/files/kamikaze-2.4/packages/mipsel/Packages.gz
Connecting to mightyohm.com (
Packages.gz          100% |*******************************|  8326  --:--:-- ETA
Inflating http://mightyohm.com/files/kamikaze-2.4/packages/mipsel/Packages.gz
Updated list of available packages in /var/opkg-lists/snapshots
Signiture check for snapshots skipped because GPG support was not enabled in this build

Now we can start installing packages.  To access our USB-audio converter, we need to install USB 1.1 (OHCI) support and some sound drivers:

root@OpenWrt:~# opkg install kmod-usb-audio kmod-usb-ohci

This should automatically install kmod-usb-core and kmod-sound-core, but if not you can also install them manually with the opkg install command.

At this point you should insert the USB-audio converter if you haven’t already.  Then reboot the router:

root@OpenWrt:~# reboot

As the router is booting again, watch for new status messages like these:

usb-ohci.c: USB OHCI at membase 0xb8003000, IRQ 6
usb-ohci.c: usb-00:03.0, PCI device 14e4:471a
usb.c: new USB bus registered, assigned bus number 1
usb.c: registered new driver audio
audio.c: v1.0.0:USB Audio Class driver
usbaudio: device 2 audiocontrol interface 0 has 1 input and 1 output AudioStreaming interfaces
usbaudio: device 2 interface 2 altsetting 1 channels 1 framesize 2 configured
usbaudio: valid input sample rate 48000
usbaudio: valid input sample rate 44100
usbaudio: device 2 interface 2 altsetting 1: format 0x00000010 sratelo 44100 sratehi 48000 attributes 0x01
usbaudio: registered dsp 14,3
usbaudio: constructing mixer for Terminal 6 type 0x0301

If you see this, the USB-audio converter is most likely working and the correct drivers have been loaded.  At this point the green LED inside the USB-audio converter should be lit, another sign that everything is working correctly.

Installing mpd:

To actually play some tunes we need to install some additional software.  We can use opkg to do this, as follows:

root@OpenWrt:~# opkg update

root@OpenWrt:~# opkg install mpd mpc

This command installs mpd, the music player daemon.  mpd is an open source music server that can be accessed locally or across a network by using a variety of clients, which are available for many different platforms.  This includes the command line client mpc which is also now installed on the router.

mpd requires some setup before we can use it:

root@OpenWrt:~# cd ~
root@OpenWrt:~# mkdir .mpd
root@OpenWrt:~# mkdir music
root@OpenWrt:~# mkdir .mpd/playlists
root@OpenWrt:~# vi /etc/mpd.conf

Scroll down and look for the audio_output section of the mpd configuration file, and change the reference to /dev/dsp to make it look like this:

# An example of an OSS output:
audio_output {
        type                    "oss"
        name                    "My OSS Device"
        device                  "/dev/sound/dsp"
        format                  "44100:16:2"

There are many other options you can play with; mpd is very powerful.  There is a list of features here and a lot more information on the mpd wiki.

Exit vi, saving the changes to mpd.conf.  Now launch mpd with the following command:

root@OpenWrt:~# mpd

The player should start silently, without errors.  Run mpc and verify that it can talk to the server:

root@OpenWrt:~# mpc
volume:100%   repeat: off   random: off

If you see this, good news, the server is running and we have the ability to control it with mpc!

Now would be a good time to connect speakers or headphones to the USB-audio adapter’s headphone output.  Warning – the initial volume can be VERY LOUD. Don’t wear headphones during testing!  PC speakers with a volume control are best.  Start at a low volume.  (My ears are still ringing!)

We can add a streaming radio server to the playlist by executing

root@OpenWrt:~# mpc add http://relay3.slayradio.org:8000/
adding: http://relay3.slayradio.org:8000/

And finally, the moment of truth:

root@OpenWrt:~# mpc play
[playing] #1/1   0:00/0:00 (100%)
volume:100%   repeat: off   random: off

If all goes well, within a few seconds you should hear Slay Radio playing on your headphones or speakers.  The Air light on the router should flicker as traffic crosses the WiFi interface, and the green light on the USB-audio converter should flash repeatedly to indicate that audio is being sent to the device.

If you’ve made it this far, I recommend celebrating with your favorite beverage and enjoying some tunes!  Congratulations!

You can add other servers to the playlist by executing the mpc add command again, and then play them with the mpc play n command, where n is the position of the server in the playlist.  mpc playlist will display the current playlist. mpc help will give you a list of available commands.

One very powerful feature of mpd is that it operates as a server on port 6600 of the router, so it can be controlled from any other device on your local network.  If you download an mpd client such as Theramin, you can control the router remotely from your desktop computer.  There is an excellent client for the iPhone too.

That’s it for part five.  I hope you have enjoyed the series thus far.  In part six, we’ll start writing some scripts to control mpd and talk about options for a user interface.  If you are building a Wifi Radio of your own, I’d love to hear about it – leave a comment below!

Update: Part six is now available.

Inside the SYBA SD-CM-UAUD USB Stereo Audio Adapter

SYBA SD-CM-UAUD USB Stereo Audio Adapter

I am using this tiny USB-audio adapter as part of my Wifi Radio project.  It’s a ridiculously cheap $8 at Newegg.com and contains a C-Media CM119 chip targeted at VoIP applications.  I have no idea why they chose to use a VoIP chip for this application because it contains a lot of bells and whistles that are not being used in this device, such as support for a matrix keypad!

SYBA SD-CM-UAUD USB Stereo Audio Adapter

Unfortunately, I have not been able to locate a datasheet for the CM119 so for now I will be using it only for it’s intended application – adding an audio output to a wireless router with USB.  Come to think of it, that is probably not it’s intended application, but it’s close enough.  Hooray for embedded Linux!

SYBA SD-CM-UAUD USB Stereo Audio Adapter