Raspberry Pi internet radio with web interface

Having made a bare-bones Raspberry Pi internet radio and one with an LCD display with push buttons to change channel, I decided that it would be nice to be able to control it from my smartphone, as well as displaying ‘now playing’ track information.

This was a fun challenge that kept me busy in the summer… I got distracted dreaming of different RaspberryPi shields (see below) with little speakers, buttons and LCD displays that would make nice Kickstarter projects, and I’ve been so busy since that I never wrote it up. So here, from memory and a few scribbled notes, is how you might do it…

In brief, you install mpd and mpc music players, add some internet radio stations, install a simple web server and add a bit of PHP code to dish up a web page that controls the radio and displays tracklistings. It was the latter that was an especially tough nut to crack. The BBC, despite being funded from public subscriptions, does not seem to freely syndicate its ‘now playing’ data, and I have had to get it via a commercial third party’s RSS feed (last.fm). Madness. (Or possibly The Specials. Without the now playing data, I’m not sure.) For my favourite radio station, fip, I used its Twitter feed to display the last 3 tracks played.

How to build one (very) roughly

1) Start with a vanilla RaspberryPi running Raspbian OS ‘headless’ so it doesn’t boot into a GUI. Adding wifi and giving it a static IP address is a good idea (in my experience, most wifi routers allow you to give devices the same IP address each time they start up). Enable SSH so you can log into your PiRadio remotely.

2) Install MPD and MPC music players as per http://www.suppertime.co.uk/blogmywiki/piradio/

3) Add internet radio stations of your choice as per http://www.suppertime.co.uk/blogmywiki/piradio/

4) Plug in some headphones, powered speakers or an amp into the analogue audio output of the RaspberryPi to test it works when you type
mpc play 1

5) Optional: add a line to /etc/rc.local to play the radio station of your choice at boot-up.

6) Install nginx web server and PHP.

6.5) Install SimplePie to handle the RSS feeds that give ‘now playing’ data for BBC Radio.

7) Add my index.php and shutdown.php file (code here) to /usr/share/nginx/www – there was probably a whole mess of permissions horror here that my notes glide over. It looks like I had fun making the shutdown work, I probably had to give the nginx user sudo rights or something horribly ill-advised.

8) You should now have a radio you (or your children! such hilarity!) can remotely control from a web-browser on any smartphone, computer, tablet – or indeed eBook reader. The stylesheet is optimised for an iPhone, but this easily be tweaked.

To do:
- enable recording (I did make some headway with this using streamripper but ran out of time).
- have a nice HTML5 volume control slider (this was beyond me).
- find a better way of setting it up so you can configure the wifi from a simple command line in a KanoOS-style.
- make it so you can easily edit the station list from web interface or command line.
- mesh in better with my Arduino-driven LCD display (at the moment if you change the channel using the web interface, the LCD shows the wrong station name).
- find someone to help me build my Kickstarter radio shield/widget. Adafruit do an LCD screen with buttons like my Arduino one, but it’s a kit. I’d like a cute little box with a screen, buttons and a speaker or two, powered by USB.


Controlling an early version of PiLittleRadio from an old Kindle 3G.

This entry was posted in Raspberry Pi and tagged , , . Bookmark the permalink.

4 Responses to Raspberry Pi internet radio with web interface

  1. Pavel says:

    Hello, I would like to ask you for correction of the link to download pilittleradio.zip
    Thank you.

  2. dilettante says:

    Please could you detail how to install simplepie ?
    This package seems not to be available for the raspberry ?
    Thanks
    JCB

    • blogmywiki says:

      To be perfectly honest, I can’t remember how I installed it. I didn’t take proper notes when I was building it, and it was a couple of years ago now. I may well have just downloaded it from http://simplepie.org and installed it manually. On my summer to-do list is to revive this project and document it properly!

Leave a Reply