Raspberry FM Part 2, the sequal
Nearly a year ago I wrapped up a project I called “Raspberry FM“: A Raspberry Pi based internet radio streamer coupled with a MaKey MaKey as the interface. Why the name Raspberry FM? It’s a mashup of a Raspberry Pi, and my favorite internet radio station, Soma FM. It worked, but had a few problems:
- There was no visual feedback, the MaKey MaKey was purely an input.
- I was having a hard time getting Python to interface with with MPlayer (probably due to my own ignorance), the audio player I had chosen, so everything was done via bash.
Fast forward nearly a year: After learning about the Mpd audio player/server, and (one of) its clients Mpc, it re-piqued my interest in programming a Python app to play music on the Pi. Second time around, it all turned out really well: New software combined with new hardware and a 3d-printed case turned it into a good looking compact unit.
Overview of the whole process below (pic on top, video on bottom). During the development I decided to write my own Python music player around mpc & Adafruit’s LCD library. At this point there are several others online, but I enjoyed coding it from scratch.
Raspberry FM Features:
- Auto-on with the Pi
- If no internet is present or it drops out, app will go into holding pattern until it returns.
- Can change between any number of stations. (left\right buttons).
- Stations are easy to add via the commandline: No need to update Python source: SSH into the Pi, and add\remove what you need.
- Increase\decrease volume (up\down buttons).
- Station and song info is displayed and auto-scrolls.
- Shutdown Pi (select+left) or turn off program (for debugging, select+right)
- Lots of color changing when buttons are pressed!
Hardware needed:
- Raspberry Pi (I used a B model)
- Adafruit RGB 16×2 LCD+Keypad Kit : Solder and install!
- Optional: Custom 3D printed case I designed (well, I designed the top part), download on Thingiverse. Print & install! Took me about an 1:20 on my Makerbot Replicator (1).
- I stream the internet radio over cat5, but I’ve also had success with wifi.
- I use the headphone jack for audio out.
Software needed:
- This was all done on the Raspbian distro via NOOBS.
- My “Raspberry FM” Python program. Find on Bitbucket.
- You’ll need Adafruits CharLCDPlate library.
- FYI, I coded this all via the Adafruit WebIDE, I’d recommend anyone else to use it as well to help manage the various Python modules on the Pi.
- MPD & MPC:
sudo
apt-get
install
mpc mpd
Steps:
- I presume you already have your Pi setup. If not, see my notes here on the general steps needed to get a Pi live and kicking.
- Setup Pi to auto-login. See notes here.
- Download the Raspberry FM Python program to a folder of your choosing. Since I coded this via the WebIDE, both the creation of my code and the integration of the Adafruit LCD modules was all handled via the WebIDE. Make sure you download all the Adafruit CharLCDPlate modules as well and put them in the same directory.
- Install MPD & MPC.
- Add stations to MPC. This is super easy on the commandline. May I recommend anything from SomaFM?
mpc add http://ice.somafm.com/groovesalad
- Setup Pi to auto-run a program on start. See notes here. You will point that script to wherever you saved the Raspberry FM Python script. For example, my startup.sh script looks like:
-
#!/bin/bash echo startup.sh : Launching raspberryFm.py sudo python /usr/share/adafruit/webide/repositories/my-pi-projects/Adafruit_CharLCDPlate/raspberryFm01.py
- Restart the Pi and listen to the music!
The final result in action: