Inspired by several others who have done the same, I have been using several Asus routers running the MPD music server on top of OpenWRT as networked music players for some time now, both for streaming radio and for playing my own MP3 collection. So far, I was content with doing the software conversion only, and leave the routers in their original case. This meant I always needed external amplification/speakers to hear anything at all, and a remote MPD client such as the browser based PhpMp or the Android app MPDroid to control the player.
Recently, I decided I wanted to delve a little bit into the electronics side of microprocessors. I am a professional software engineer, and I usually write software that controls some kind of machine, but my area of interest normally stops at the OS level. I thought it would be interesting to broaden my horizon by diving into the electronics side of the products I work on.
Looking for an interesting project, I quickly realized that taking one of my MPD players and using it in combination with my old Logitech speaker set to build a standalone WiFi capable networked boombox would be an excellent way to learn about microcontroller electronics.
MightyOhm’s “Building a WiFi Radio” series of articles is a great and very detailed build log, and it has served as an invaluable starting point for my own build. But while borrowing heavily from him, my goals are a bit different. I decided early on that in addition to being a WiFi radio, my player should also be able to play my MP3 collection, which is located on my NAS. This meant a single pot-meter as a tuning knob wasn’t going to cut it. The solution is a more extensive control method with a total of 6 push buttons (up, down, left, right, enter and mode switch). The current setup looks like this:
And here is a close-up of the breadboard:
You can see breadboard is getting rather crowded. In addition to the massive 20x4 display, it has a corner dedicated to the power supply (top left) and holds the Atmega328 which controls everything, including its peripherals (crystal, push-buttons, ISP breakout board and some more odds and ends). The power supply circuit is from the outstanding SparkFun tutorial on beginning embedded electronics, which really helped get me up to speed.
The splash screen mentions my employer as sponsor, since they decided this project was relevant enough to count as education. This meant I could finance most of the parts, including things like the Atmel ISP programmer, from my education budget, which significantly lowered the barrier to start.
The router runs the Backfire (10.03.1) version of OpenWrt. Since the Asus WL-500G deluxe comes with 2 external USB ports, I decided to use a USB memory stick for additional storage. This greatly simplifies installation, since everything that does not fit on the router’s internal flash can simply go on the memory stick. This means I can use all the default packages from the OpenWrt repository, and do not need to build my own packages optimized for size.
The MPD version is 0.15.8, and it includes the mad, vorbis, flac and ffmpeg decoders, which means it can decode pretty much everythin, including (theoretically anyway) mms streams.
The code running on the Atmega328 is a mashup of MightyOhm’s serial communication code, the Makefile from the SparkFun tutorial and my own code for parsing and showing the data coming from the router and handling the pushbuttons (using one of the timers this MPU has). I’ll put it up for download once the project is a bit further along.
The way the control system is going to work is that the player will be in one of two modes: WiFi radio streaming mode or MP3 playing mode. The mode switching button controls which mode the player is in.
Upon entering the MP3 playing mode, the user can select what music they want to play by navigating the directory structure as stored in the MPD database and selecting a specific directory. This bit is still in development, so I can’t show it yet, but playing an MP3 looks like this:
This shows how long the song has been playing, where in the current playlist the player is, the track’s artist/title information and a progress bar showing how much of the song has been played.
A single press of the mode switching button will clear the playlist, and repopulate it with a default list of internet radio stations. This looks a bit differently, since there is a different set of information available for streams compared to MP3’s:
In this case, the progress bar has no function (although it can be used to visualize changes in volume), and the radio station name is shown instead of the track’s artist.
This is pretty much the state of the project at this point. The next step is wiring up the remaining push buttons and developing the software (both on the controller and on the router) to navigate the MP3 collection. After that, there’s the big job of integrating everything, including the speakers and power supplies, into a nice, portable case.