I find MightyOhm’s WiFi radio project really inspirational. It uses an Asus WL-520gu router, Arduino and a usb audio adapter to create a very low power consumption WiFi radio. It also makes use of small, yet powerful, open source software packaged by the OpenWrt distribution. It also introduced me to the awesome power and flexibility of Music Player Daemon (MPD). It’s a great project that even covers putting it all in a nice display case.
I also like listening to music while I fall asleep so last summer I decided to try making my own WiFi Radio. I considered making an Asus based WiFi radio but a reluctance to potentially damage the Asus router trying to hook up a serial connection and uncertainty about whether or not it would work with WPA2-AES protocol encouraged me to look elsewhere for my WiFi radio solution. I decided to try reusing things I already own as much as possible.
I used a trusty old 733 MHz, Intel 386 based computer and set it up with Ubuntu 10.04 LTS. I added a USB LCDSmartie display from Sure Electronics and set it up to run headless (no monitor or keyboard). To control it I plugged in a USB keypad and installed OpenSSH Server so that I could remotely connect to it through the LAN. I setup the BIOS to start the computer at 9:45PM every day and to shut itself down after running for 4 hours. The speaker was provided by the external input of my alarm clock/radio (with its annoying amber glow).
I changed the LCD display from the bluish one the LCDSmartie shipped with to a red one. I prefer red lighting since it doesn’t mess up night vision or bother sleep as much. I have described how I configured the LCD display in a previous post: http://www.seephar.com/2010/10/enable-sure-electronics-driver-in-lcdproc/ and how to control it using python: http://www.seephar.com/2010/09/python-gmail-lcdproc-client/.
The USB Keypad is a Belkin Nostromo N50 Speedpad but it could be any USB numeric keypad. I used EMPCd and Music Player Client (MPC) to control Music Player Daemon (MPD). The tricky part of configuring EMPCd is figuring out what device the USB Keypad is assigned. The EMPCd website mentions using using ‘/usr/sbin/empcd -K’ and ‘/usr/sbin/empcd -L’ respectively to determine which keys and functions are supported. I tried by process of elimination all the /dev/input/event* devices in the EMPCd configuration file /etc/empcd.conf and found that “eventdevice /dev/input/event3″ responded to presses on the speedpad. I then was able to figure out which key was which event and altered the EMPCd configuration file accordingly.
I used a script (mpdcurrent.tcl.gz) adapted from one of Jannis Achstetter’s lcdproc clients and written in tcl to display the current status of MPD such as what song was playing or whether it was stopped, etc… Most scripts are started in /etc/rc.local.
# Load script that displays current status of MPD using LCDProc
# Clear any currently loaded MPD playlist
# Load predefined MPD playlist called "sleep", filled with sleep condusive music
mpc load sleep
# Play MPD playlist in random order
mpc random on
# When it gets to the end of the playlist it starts over
mpc repeat on
# Starts playing currently loaded playlist
mpc play &
# Shutdown in 4 hours
/sbin/shutdown -P +240 &
# Start EMPCd to capture events from speedpad and control MPD
I use Gnome Music Player Client (GMPC) to name and configure the playlists on MPD remotely. The playlists with various internet radio station urls and/or music are loaded using bash scripts executed by rc.local at startup and by EMPCd in response to specific key presses on the speedpad.
# ldstream.sh loads MPD playlist containing Internet radio stations
# executed by EMPCd when correct button pressed on speedpad
mpc load stream
mpc random off
# Play first item in playlist
mpc play 1
I have 3 main playlist names: stream, sleep and elect. Here is a package (wifi_radio_files.tar.gz) of configuration files that may be helpful in understanding how I configured it. Each playlist can be loaded by pressing the appropriate button on the speedpad which executes a bash script which uses MPC to control MPD. Two more buttons select the previous or next item in the playlist and also stop and play the current item on MPD.
The 386 uses a low power consumption, DC to DC power supply and a Hitachi IC35L090AVV207-0 80GB Hard Drive that is fairly power efficient. The whole system idles at about 20 Watts and peaks at about 40Watts. It works very well. Admittedly the mini ATX case is not as small and elegant as MightyOhm’s project but it is quiet and can hide underneath the bed.
I have since replaced this “WiFi radio” and the clock/radio with the annoying amber glow with a Chumby like device called the Insignia Infocast 3.5 which I snagged on sale for $50. It is smaller, uses much less power, has a built-in speaker and is controlled with a touch screen. This machine currently resides in the basement shut down and waiting to be awaken with Wake On Lan (WOL) and act as an audio server once again.