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. 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.

Posted in Raspberry Pi | Tagged , , | Leave a comment

10 fun things to do with a Raspberry Pi

Got a Raspberry Pi? Not sure what to do with it? Here are some cool things I’ve done with mine to get you thinking:

Some of these posts are old and the precise details of what you need to do may be out-of-date, but I hope this list gives you some ideas.

Posted in Raspberry Pi | Tagged , , | Leave a comment

RaspberryPi media server

It’s been a long-time goal of mine to have all my music in a central place so I can access it from all over the house. I can’t afford Network Attached Storage (NAS) at the moment, and I got a bit confused and distracted about what it was I really wanted – there are loads of guides to making media players (including Airplay receivers), but I was struggling to find how to make a media server. I wanted to use a RaspberryPi because its low power consumption means I can leave it turned on 24/7, and I already have one running all the time as a wifi print server.

I think MiniDLNA may be the answer – this is a lightweight media server that can run on the RaspberryPi and stream audio (and video, but I’m only interested in music) to DLNA clients on your network; this can include things like smart TVs, my Humax PVR (itself a DLNA server, but it’s not left on all the time), a tablet, laptop or smartphone running a DLNA-aware client (like VLC), or another RaspberryPi running a media centre like XBMC.


Browsing audio files on a Raspberry Pi using the OS X version of Boxee on a hackintosh netbook. Boxee was a lovely implementation of XMBC before it got bought by Samsung.

There are several guides to installing MiniDLNA on the RaspberryPi: http://www.megaleecher.net/DLNA_Streaming_From_Raspberry_Pi#axzz39J5Ol3ZF and http://everbit.wordpress.com/2013/04/01/minidlna-on-the-raspberry-pi/ for example (the latter looks pretty good). I mostly followed this guide: http://bbrks.me/rpi-minidlna-media-server/. This last guide explains how to get a USB drive (I’m using a 16GB memory stick at the moment) to mount, though I did get confused because the magic sudo word is missing from the start of each command line. If you follow this guide, you should also check out what others say about file permissions, or MiniDLNA won’t be able to create its database of media files. My music files are on that 16GB USB stick, which I formatted as FAT32, rather than Linuxy formats like EXT3 or EXT4 so I can easily transfer files onto it from another computer, Mac or Windows. (16GB isn’t quite big enough for my music, so I’ll swap this for a 64GB USB stick soon – this would easily be large enough as I’m not serving video files.)


Using VLC on an iPhone to browse and play music from the RaspberryPi

I’m still having a few teething problems, but I’m a step closer to realising my dream of playing music anywhere in the house from a central pot of tunes. Next I need to modify my kitchen PiRadio so it can play my own music as well as internet radio stations.

Posted in iPhone, music, Raspberry Pi | Tagged , , | Leave a comment

Adding RTÉ and Resonance FM to PiRadio

Just added 2 more stations to my PiRadio. Here’s the command line code for each.

RTÉ Radio 1:

mpc add http://icecast2.rte.ie/radio1

and Resonance FM:

mpc add http://radio.canstream.co.uk:8004/live.mp3

Posted in radio, Raspberry Pi | Tagged , , , | Leave a comment

The Amazing Random Possessive Book Title Generator

Yes, there are random book title generators out there on the internet, but what I really wanted was one that would generate possessive book titles.

You know the ones: Flaubert’s Parrot, Hemingway’s Chair, Milton’s Custard. (I may have made the last one of these up).

So, unwrap a teacake, get out a notepad and get writing! I should warn you that if you use one of these titles and win the Booker Prize, I want an invite to the do.

Jane Eyre’s Camera, Karl Marx’s Custard and Chomsky’s Underpants – they are all here for the taking.

Click here to go to the generator.

(It’s written in bodgy Javascript – next steps: re-write it in PHP. Then re-write it in Python and get it to automatically tweet a new random book title twice a day…)

Posted in Uncategorized | Leave a comment