I've been working on this project for some time, I had originally read about the concept of hacking the Asus WL-520GU to use as a base for a wifi radio over at MightyOhm.com. In fact, I was so taken by the concept I decided I wanted to build my very own. That was nearly eight months ago....
Jeff over at MightyOhm.com has written a highly detailed step-by-step guide for building a wifi radio just like his and I followed his guide to build mine, with a few major exceptions. First, I wanted to use the Arduino development board. Secondly, I didn't quite like the feel of the user controls with the original design. My goal was to make this really amazing project even easier for folks to build and modify, I figured releasing an Arduino port of his code would accomplish that. If your interested in building one of these radios, I would first suggest you read through his guide and familiarize yourself with the overall concept of how the radio works. Once you have a good understanding of that, you'll be able to better understand my deviations from his project.
The first major change from Jeff's radio is the fact that I used the Arduino development board (with an ATmega328) for my radio and he uses just the bare brains of the Arduino, the ATmega168. While the chips are nearly identical, I've chosen to write all the code in the native Arduino coding language and he's using WinAVR and C to program the chip. The second major change is the fact that Jeff's radio has the LCD display the radio station information on a 20X2 LCD display with data coming from the router. I've opted to use a 20X4 LCD display and have the station information statically coded in the Arduino sketch.
The reason behind the first deviation from his project, is that I felt it would be easier for folks to build off the project if I used the standard Arduino development board. I also wanted to simplify the logistics of all the auxiliary electronics in the radio by utilizing a custom-built shield for the Arduino. The rational behind my second deviation to have the radio stations statically coded in the Arduino sketch was driven by the fact that I felt like the user interface was too slow to update the LCD with information for the user. It felt sluggish to me and tedious. I wanted something snappier and with a bit more tactile feel to it. Switching his 10k potentiometer to a 12 position rotary switch and utilizing some nifty voltage dividers on the shield, I was able to accomplish what I wanted.
The code has been through quite a few revisions, it taught me alot about the importance of minimizing your use of SRAM in a micro-controller, the Arduino (ATmega328) only has 2k so it's a precious commodity and I didn't appreciate that in the first few revisions of the code. It left me with a radio that would randomly crash, once I developed an appreciation for the use of SRAM and rewrote the code to eliminate my wasteful use of it, I was awarded with a rock solid radio. Be very careful when working with strings especially, you'll use up the RAM and it'll cause your code to behave in some really weird ways. I found a few great blogs about the subject which I think anyone who is serious about the Arduino should read and FULLY understand.
Also you should be aware that I've changed the two router scripts that Jeff used, I did this to facilitate the Arduino already having the station names and I wanted to offload some of the work to the Arduino from the router. They are included in the zip file I've attached to this post. Just replace his with these if you decide to use my Arduino sketch.
The Radio Box
I purchased my radio box on eBay for approximately $30 US. It was a destroyed 1940's era portable radio which looked much smaller in the pictures, thus the "Retro" in the "Retro Wifi Radio". As you can see from my pictures of the completed radio, it's actually quite large. I'd suggest you find something a bit smaller, although the roominess is nice since I didn't have to worry about squeezing in the speakers and electronics. My primary search criteria for the radio enclosure was one that would allow me to fit the 20x4 LCD in without modifying the box, I'm handy with electronics and mechanical things, not so much with the wood working! Thankfully my father is and he was able to refinish this radio, it looks brand new now and I couldn't have done this project without him, he is after all the man who taught me the basics of mechanics and electronics.
I decided very early on that I wanted to build a custom shield for this project. I've since built numerous shields for the Arduino and some day I'll go back and tweak this one with what I've learned. For now, however, this shield works perfectly. The primary purpose of the shield was to allow me to easily connect the LCD and rotary wires to the Arduino, it also helped to keep things a bit more organized. First, the rotary switch; I decided I wanted tactile feedback when switching stations, the rotary switch was my first pick and the 12 position switch was the largest number of positions I could find so that determined the number of radio stations I could have. It also meant that I'd need a few voltage dividers so I could tell which position the switch was at. Tying up 12 pins on the Arduino was out of the question since I had to use 8 pins for the LCD. The voltage divider concept allowed me to only tie up four of the analog pins. Basically each of the four analog pins has three voltage dividers which are easily differentiated using the ADC values. You can refer to the code to see that I look through the four pins to see if they are within one of the three voltage ranges, based on this, I know exactly which position the rotary switch is at.
The shield also has the LCD contrast trim pot, the router serial connection, 5V power in and I brought out a few other pins for future use in addition to a reset button. Like I said, I'd do things a bit differently with this shield given the knowledge I have today but the shield works without issue.
The LCD Display
The LCD display is nice, having the four rows of display makes the information easier to read, I think. I also opted to truncate the data if it's too large to fit on the LCD rather than having it scroll. I personally never liked scrolling text but perhaps someone will take this project and add that feature. I've broken the four rows into:
- Station Name
- Song Name
- Pre-set radio station number (from 1 to 12 of 12 possible stations)
The idea is that with the Arduino already knows the radio station based on the preset station number so the user gets to see the station names immediately upon changing the rotary switch. Once they leave the switch on a station for a second, the Arduino will display the "Refreshing info" text on the LCD until it can acquire the information from the router. I felt like this makes the interface super intuitive and overall I'm very satisfied with the results.
The Speaker and Audio Amp
For the speaker and audio amp, I decided to hack up some existing speakers I had laying around. The speakers had a volume/on-off switch control had a built-in audio amp and required 12V DC power. This was perfect since the power supply they used was rated for 3.5 amps and I wouldn't have to worry about building an audio amp. I tore out the audio amp board and desoldered the volume control, I used this as the left control knob on my radio to turn the whole system on and off in addition to adjusting the volume. Since I was having a shield manufactured, I decided I'd build a power break-out board with switch control, this way I could have 12V DC coming in to power the speakers and then I could use separate voltage regulators to get the other voltages I needed. Overall, I'm quite happy with the quality of the sound from this setup.
Powering the beast
The speakers that I chose came with a nice power supply that had a current rating that exceeded my calculated requirements by more than 30% which is a design rule I try to use as a minimum. I knew I needed 5V DC for the Arduino and looking at the router's power supply it required 5V DC as well. I measured the current requirements of both the Arduino and the router with my multimeter and decided to use some 5V 1.5A power supply boards I had built for an earlier project. Since I was already using a linear power supply I really could have just used a couple of 5V 1.5A voltage regulators with a heat sink. As I found out after the whole radio was built and used for a few hours, however, some active cooling is necessary for those heat sinks. I had some 5V 40mm fans on hand so I just installed one of those after the fact. You may be wondering why I didn't just use a single regulator setup for both the Arduino and the router? Well, I knew the router would hit ~800mA when streaming and I knew that the Arduino's requirement for ~500mA would push a single 1.5A regulator too hard, besides I have tons of them already and since I had to boards, I used them. If I ever build another one, I'll build a single board with all the regulators and hookups for the different components, I think it'd be cleaner looking and easier to cool with passive cooling.
The Radio in Action
Here is the radio booting up (the router does take that long to boot and start talking to the Arduino) and listening to a few radio stations....
Now that I have my working radio I've had time to dream up some enhancements that I think would make it even neater.
1. I want a web interface to change the radio stations that are preset. Would be able to set the station name and enter the URL for the audio stream.
2. Update the shield to put the incoming power on the VIN pin and not the 5V pin.
3. Design build a single board for all the regulators, power requirements of the components. Eliminate the need for active cooling.
4. Perhaps add the option for scrolling text on long artist/song titles.
5. Add an AM/FM tuner chip to shield to allow internet streaming or local radio.
6. Change left knob from a rotary switch to a rotary encoder.
As always, I've included all the schematics, hi-res photos and the Arduino sketch in the attached zip file.
I completed a new controller board which includes all the enhancements above and built a PDU (Power Distribution Unit) board as well. I've uploaded all the design files which you can download below. Download "UpdatedWIFIRadio" below.
Retro Wifi Radio by Jay Collett, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.