Raspberry Pi Wifi Internet Radio Player


For my first project after getting the Raspberry Pi ($35 Linux computer) I wanted to extend on a very good blog post I read from MightyOhm about turning a cheap Wifi router into an internet radio:

http://mightyohm.com/blog/2008/10/building-a-wifi-radio-part-1-introduction/

In that article he also had a cheap Linux device (the router) and was able to stretch it to be a mucic machine. I had no previous experience with Linux, always used and programmed on Windows machines. So I wasn’t sure what to expect when my Raspberry Pi finally arrived. After some initial hickups, I was able to get the device running:


I installed MPD, MPC, and SSH on it so that it could be a headless (meaning no monitor) device. Linux has been an experience, its entirely to cryptic for my taste, too many blind alleys to get stuck down. I was able to get it to install a tiny nano Wifi and wrote a small python program that hold a list of internet radio streams (and executed MPC commands).

I control which stream the player is listening to using the Adafruit Cobbler to breakout the pins so that the python program is just listening for button presses. When the button is pressed the player moves on to the next stream in the list. I can SSH (remote command line access) into the Raspberry Pi using Putty on my PC and edit the list as much as I want remotely (I even have an SSH access as an app on my phone). Here it is in action:

These links are the documentation for how to setup and run the Raspberry Pi as a Wifi Internet Radio:

The Raspberry Pi and where to buy it

How to setup SSH on the Raspberry Pi

Edimax nano USB Wifi that worked great for me on the Raspberry Pi

Easy setup instruction for Edimax EW-7811Un Wifi

Adafruit Pi Cobbler

Adafruit instruction for buttons with the Pi Cobbler

Setting up MPD and MPC

Adding items to your MPC playlist – look under “installing mpd”

Streaming radio lists – the .pls have to be downloaded and opened in a text editor for the “http//” items to add to MPC

Here is the python file:
radio.py
you will need to call “sudo python radio.py” to run it (as well as have Python installed)

Here is the instructions on how I created the radio station list:
Radio Station List – includes 20 stations, just run this command “sudo mpc save mine” to save the list as the “mine” playlist used by the radio.py file

here are some of the recent hardware choices:

Here is the latest video going over all the parts I am using to make this happen.  You certainly don’t need all of these to get it to work, but the upgrades do make it very interesting :)

 

SSH connection over Wifi

this makes it very easy to add stations to the list or even adjust volume levels remotely

 

48 Responses to Raspberry Pi Wifi Internet Radio Player

  1. Pingback: Raspberry Pi Wifi Internet Radio Player – #piday #raspberrypi @Raspberry_Pi « adafruit industries blog

  2. Moses says:

    what breadboard are you using for the buttons? I looked on Adafruit but I dont see the one your using? will any board work?

  3. Any board will work as long as you are paying attention to the traces below (because some boards have traces already). I like to use the boards from radioshack that have only pads and no traces for projects that are simple like these. I try and use the ones with the square pads and bridge them with solder to create the traces I need. For longer traces I tend to cut some legs from resistors to makes the solder stretch better. Any proto-board would work though, just go with whatever makes most sense to you.

  4. j. spoon says:

    maybe you want to try to keep your board off of carpet. Otherwise, you risk the chance of bricking your Raspberry Pi. Google ESD protection and you’ll find a plethora of information on how to safely handle electronics.

    • Its in a case now, I didn’t have a wired connection in my home office so I had to plug it into the router hence the uncomfortable setup here. Had the monitor and keyboard on the floor as well just to download the drivers for the Wifi.

  5. greg says:

    Do You have any better instructions for adding the radio list? I just can`t get it work properly. (the file “sudo mpc mine” is a text file or python file?

    • Greg,
      ok, id love to help!

      mpc is a client that runs on the device and should be installed if you followed my directions carefully. go here for instructions on installing it:
      http://miro.oorganica.com/raspberry-pi-mpd/

      once it is up and working you can add playlist items to it by executing this command on the command line (all interaction with it is done through the command line):

      sudo mpc add http://relay3.slayradio.org:8000/
      (this will add the slayradio stream to your playlist.)

      once you have added all the stations you will need to save it so that you can access it by name later. to save the playlist (after you have added all the stations you want) execute this command:

      sudo mpc save mine

      saves the playlist under the name “mine” (give it any name you want, i used: mine). you can then later load that saved playlist by executing this command:

      sudo mpc load mine

      then you can play an item from your list like this:

      sudo mpc play 1
      (plays the first item on the list)

      look at the other mpc commands here:
      http://linux.die.net/man/1/mpc

      Let me know how it goes. Send me info on what you are trying and how far through the instructions you have moved. You might want to send me pics too if you are trying to put buttons on it.

  6. Pingback: Wifi radio | Massif Software

  7. Pingback: Raspberry Pi Wifi radio #piday #raspberrypi @Raspberry_Pi « adafruit industries blog

  8. Jim says:

    Found you blog from the RaspberryPi website. They mention you found “a nice little battery you can use to charge a micro USB device which he found at Radioshack (his Pi runs for a couple of hours on it)”. Can you post a link to that? Thanks!

  9. WildCoder says:

    Hello,

    It looks from the photo that you have a bluetooth keyboard connected to the Rpi. I got one almost like that today and I can’t get it to work. Would you have any pointers for bluetooth keyboard and mouse on the Rpi? Thanks.

  10. Kai says:

    Hey, I found a tutorial explaining how to use Wifi through GPIO. Have you tried that? http://www.cooking-hacks.com/index.php/documentation/tutorials/wifi-module-for-raspberry-pi-roving-rn-xvee

    • um, I already get great wifi through the USB nano device I use, I wouldnt prefer to do it by hand. I am sure its possible but not very practical since the Wifi Nano USB module was only $9.

  11. Derk says:

    Great project.
    I got my RPi to play wma format streams via mpd/mpc by using ffmpeg:
    sudo apt-get install ffmpeg

    Then changed the audio_output section in /etc/mpd.conf to use encoder “ffmpeg”:

    audio_output {
    type “alsa”
    name “My ALSA Device”
    device “hw:0,0″ # optional
    format “44100:16:2″ # optional
    mixer_device “default” # optional
    mixer_control “PCM” # optional
    mixer_index “0″ # optional
    encoder “ffmpeg”
    }

    Restart mpd and then add the URL to mpc as usual:
    mpc add [URL]
    mpc play

  12. Pingback: Guest blog #2: Near field communication by Donatien Garnier | Massif Software

  13. Pingback: ทำ Wi-Fi Internet Radio ด้วย Raspberry Pi | Raspberry Pi Thailand

  14. Pingback: » Linuxaria – Everything about GNU/Linux and Open source Raspberry Pi what is the secret of his success and what are its potential

  15. Pingback: Eine eigene Cloud auf Himbeerbasis « Hatori Kibble

  16. Pingback: Credit-Card Size Computer for $35 « California Online High School

  17. Pingback: raspberry wifi internet radio | Jakob'll Fix It!

  18. Mordecai says:

    Very nice work!

    But still wondering how you managed to execute the python-script on startup…?!

    Thanks in advance and best regards.

    • I found this: http://www.linuxquestions.org/questions/linux-newbie-8/how-do-i-run-a-command-at-every-boot-521372/

      and put the radio.py in the /etc/rc.local file and it runs on it boot. Means all I have to do is plug it in and 1 minute later its all up and running. I’m not a linux guy, I just keep googling until I found something that worked. Comment if that works for you.

      • Mordecai says:

        Thx for your quick reply.
        Tried your mentioned solution but getting this error-log:

        decoder_thread: curl failed: Couldn’t resolve host

        When executing

        mpc play

        It works…?!

      • I think what you are missing is the list item indicator. The full command should be something like this:

        mpc play 1

        The couldn’t resolve host usually means that it couldn’t find the address you provided. Either that or you don’t have a music station list, make sure you re-read all the steps and have everything.

  19. Pingback: Turn a Raspberry Pi Into an AirPlay Receiver for Streaming Music in Your Living Room

  20. Pingback: Turn A Raspberry Pi Into An AirPlay Receiver For Streaming Music | Lifehacker Australia

  21. Pingback: Turn a Raspberry Pi Into an AirPlay Receiver for Streaming Music in … | Acoustic Environments

  22. Pingback: Framboise sonore | Carnet

  23. Mordecai says:

    Hi
    I wanted to report the solution to my described problem:
    For I am using an external USB-soundcard I commented “snd_bcm2835″ in /etc/modules and modified “mpd.conf” as pulse-audio-output instead of ALSA.
    Now everything works fine.
    Best regards

  24. I got this site from my pal who informed me regarding this site and at the
    moment this time I am browsing this web page and reading very
    informative articles or reviews at this place.

  25. Ismael says:

    I like it when people get together and share ideas. Great
    blog, keep it up!

  26. Martha says:

    As a site owner. Do you truly feel like owning a web-site or blog site is profitable?
    Also how can you get visitors to visit your website or blog?

    • I do not do this site for profit (I make no money from it). The reason I post here is to document the projects I am working on to help others that may be working on similar projects or technologies. Hopefully my notes or diagrams will help them get past any roadblocks that they may be hitting, or inspire them to try new ideas. I get visitors by posting my projects to G+ communities and in my own circles of people who also work on Arduino or Raspberry Pi types of projects.

  27. Willy says:

    I really like your article. I just bought my first Raspberry Pi and I’m trying to play mms://eemsscan.dyndns.org:1877. This doesn’t work. The error message is: ERROR: problems decoding *mms://eemsscan.dyndns.org:1877/* When I try mms://196.35.64.36/highveld_22/ all works fine. What am I doing wrong? Can you help me out?

  28. Jake says:

    Will any bluetooth speaker work with this setup?

    • This is directly connected to the speaker, not using bluetooth (I know you can but ran out of USB slots) its just directly connected with a headphone type of cable to the Supertooth input.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s