Introduction: Wireless Raspberry Pi Radio: Pianobar

* This entire process should take about 20 minutes

Pianobar is a free/open-source, console-based client for the personalized online radio Pandora.

Feature:
play and manage (create, add more music, delete, rename, ...) stations
rate songs and explain why they have been selected
upcoming songs/song history
customize keybindings and text output
remote control and eventcmd interface (send tracks to last.fm, for example)
proxy support for listeners outside the USA

Use your Raspberry Pi as a wireless Pandora Radio jukebox! You can  choose to add a display and controls to your Pi to set and navigate stations, however, this tutorial will use an SSH client and mobile devices (tablet or phone) to utilize pianobar's features. 

Step 1: Required Materials

- Raspberry Pi

- SD memory card (4GB or larger)

- Power adapter compatible with the MicroB connector on the Raspberry pi 

- USB Wi-Fi adapter

- Speakers or headphones

- Free or paid Pandora Radio account


Temporary Items for Initial Setup:

- HDMI compatible monitor and cable

- USB Keyboard (no mouse required, all steps done in a terminal environment)

Step 2: Preparation

The Raspberry Pi always needs to boot off of an SD card loaded with an operating system (OS) disk image.

You may buy an SD card that has already been made bootable complete with the Raspberry Pi OS or you may buy a blank card and 

There are many OS versions offered for the Raspberry Pi, however, in this example, I have chosen to use Raspbian “Wheezy”

Download the OS disk image and write it to your memory card. To write the image I used Win32 Disk Imager. Once the image is written to the card, plug the card into the Raspberry Pi's SD card reader and power on the device. (Be sure you have all the proper I/O devices plugged in, i.e., keyboard, USB wifi adapter, HDMI monitor.) 

Step 3: Initial Configuration

Keep in mind, if you mess up anything along the way, just reformat your card, reload the disk image and start again. No harm no foul. 

Upon powering the Raspberry Pi with the SD card plugged in, you will see the system automatically listing information about the operating system and peripherals. You do not need to know what it all means for this project, but I absolutely wouldn't discourage you from reading it and learning a little bit about your Raspberry Pi for your own benefit!

After the boot information is complete, you will be prompted with the raspi-config window. Here you should make the following changes:

- Expand root partition so all space on the SD card is usable.
- Set timezone.
- Enable SSH server (so you can control pianobar with your mobile device as well as continuing this installation on your desktop or laptop via SSH).
- Disable boot to desktop, we want to configure this program using only the terminal environment. 
- Do not update your Raspberry Pi at this point (we need to configure the wireless USB module first) 
- Do not restart your Raspberry Pi at this time.
* I also do not recommend overclocking your Pi for this project, the default setting works perfectly and overclocking will reduce the overall lifetime of the hardware.

Step 4: Configure Wireless USB Module

Navigate to your network interfaces with the following command:

sudo nano /etc/network/interfaces

Erase all the text and copy and past the code you see below:

auto lo
    
iface lo inet loopback
iface eth0 inet dhcp
    
allow-hotplug wlan0
auto wlan0
    
    
iface wlan0 inet dhcp
    wpa-ssid "ssid"
    wpa-psk "password"


*it should appear as the image below. Change the wpa-ssid value in the quotes to your network's ssid (your wireless network name) and be sure it is still surrounded by quotes.  Do the same with the wpa-psk, change it to the password for your personal wireless network, again, make sure the text is surrounded by quotes. 

To save this edit, hit ctrl+x, you will be prompted if you would like top keep the change, type Y and hit enter for yes and hit enter again to confirm the path of the file. 

Reboot the system with the following command:

sudo shutdown -h now

unplug the Raspberry Pi, wait 30 seconds and then reconnect the power supply.

You should see the Raspberry Pi attempting to join the network during the initial boot process in a series of DHCPDISCOVER messages. If it cannot connect, use sudo nano /etc/network/interfaces to recheck your network settings and reboot the Pi one more time. 

Step 5: SSH Into and Update Your Pi

Now you can SSH into your Raspberry Pi to finish the installation on your desktop or laptop. 

first you need to get the IP address of your Pi. Do this with the following command:

ifconfig

once you run that command, look for the inet addr: value. This is your Raspberry Pi's IP address. You will use this when trying to connect to the device.

If you are on a windows machine, I would advise that you download putty as your ssh client. If you are on a mac or linuix system, use the following command:

ssh pi@10.10.10.10

where pi is the name of your Raspberry Pi (by default the name is pi) and 10.10.10.10 is the inet addr value that you got when you ran ifconfig

If prompted for a password and you have not changed it on your own, the default password for the Raspberry Pi is "raspberry" (without quotes)

Once logged on, update your device with the following command:

sudo apt-get update

*this may take some time




Step 6: Installing Pianobar

To install pianobar use the following command:

sudo apt-get install pianobar

the pianobar installer will ask if you would like to continue. Type "y" for yes and hit enter to continue.

The installer will run automatically after you confirm the install. 

Step 7: Configure Pianobar

Create the config directory for Pianobar:

mkdir -p .config/pianobar

Navigate to the new directory:

cd ~/.config/pianobar

Once in the newly created directory, create a configuration file called "config":

sudo nano config

copy and paste the following into the GNU nano editing window:


# This is an example configuration file for pianobar. You may remove the # from
# lines you need and copy/move this file to ~/.config/pianobar/config
# See manpage for a description of the config keys
#
# User
user = YOUR_EMAIL_ADDRESS
password = YOUR_PASSWORD
# or
#password_command = gpg --decrypt ~/password

# Proxy (for those who are not living in the USA)
#control_proxy = http://127.0.0.1:9090/

# Keybindings
act_help = ?
act_songlove = +
act_songban = -
act_stationaddmusic = a
act_stationcreate = c
act_stationdelete = d
act_songexplain = e
act_stationaddbygenre = g
act_songinfo = i
act_addshared = j
act_songmove = m
act_songnext = n
act_songpause = p
act_quit = q
act_stationrename = r
act_stationchange = s
act_songtired = t
act_upcoming = u
act_stationselectquickmix = x
act_voldown = (
act_volup = )

# Misc
#audio_quality = low
#autostart_station = 123456

#event_command = /home/pi/.config/pianobar/scripts/eventcmd.sh
#fifo = /home/pi/.config/pianobar/ctl
#sort = quickmix_10_name_az
#love_icon = [+]
#ban_icon = [-]
volume = -30

# Format strings
format_nowplaying_song = SONG: %t | %a | %l
format_nowplaying_station = STATION: %n | %i
format_msg_time = TIME: %s
# No special prefix on songs, stations or info
format_msg_nowplaying = %s
format_msg_info = %s

# high-quality audio (192k mp3, for Pandora One subscribers only!)
#audio_quality = high
#rpc_host = internal-tuner.pandora.com
#partner_user = pandora one
#partner_password = TVCKIBGS9AO9TSYLNNFUML0743LH82D
#device = D01
#encrypt_password = 2%3WCL*JU$MP]4
#decrypt_password = U#IO$RZPAB%VX2

tls_fingerprint = 2D0AFDAFA16F4B5C0A43F3CB1D4752F9535507C0



Look for the following lines in the text you just copied into the GNU nano editing window. Change the text to your respective email and password you use for your free Pandora Radio account. 

user = YOUR_EMAIL_ADDRESS
password = YOUR_PASSWORD.
 

hit ctrl-x to exit the editor, type "y" to save the changes and hit enter one more time to confirm the file name.

You may not launch the Pianobar application by simply typing the following in your terminal window (once you are out of the GNU nano editor):

pianobar


*if you cannot hear any music, use ) to turn up the volume and use ( to turn it down. Again, to turn up the volume shift+0 increases volume, shift+9 decreases it

Step 8: Download an SSH for Your Mobile Device and Control Pianobar Remotely

I use my iPhone to control my wireless Pandora Pi using a mobile SSH client called ServerAuditor. It allows you to set up multiple devices and pre-configure the settings for quick connections.

(If you are going to attempt to configure settings for your devices so you connect to them quickly, I would suggest giving the devices a static IP address so you do not have to change the IP setting in the app every time you want to connect to the device)  

Now you are all set to control your music from anywhere in your house!

Step 9: Keyboard Controls

act_help = ?
              Show keybindings.

       act_songlove = +
              Love currently played song.

       act_songban = -
              Ban  current  track.  It  will  not be played again and can only
              removed using the pandora.com web interface.

       act_stationaddmusic = a
              Add more music to current station.  You  will  be  asked  for  a
              search  string. Just follow the instructions. If you're clueless
              try '?' (without quotes).

       act_bookmark = b
              Bookmark current song or artist.

       act_stationcreate = c
              Create new station. You have to enter a search string and select
              the song or artist of your choice.

       act_stationdelete = d
              Delete current station.

       act_songexplain = e
              Explain why this song is played.

       act_stationaddbygenre = g
              Add genre station provided by pandora.

       act_history = h
              Show history.

       act_songinfo = i
              Print information about currently played song/station.

       act_addshared = j
              Add shared station by id. id is a very long integer without "sh"
              at the beginning.

       act_songmove = m
              Move current song to another station

       act_songnext = n
              Skip current song.

       act_songpause = p
              Pause/Continue

       act_quit = q
              Quit pianobar.

       act_stationrename = r
              Rename currently played station.

       act_stationchange = s
              Select another station.

       act_songtired = t
              Ban song for one month.

       act_upcoming = u
              Show next songs in playlist.

       act_stationselectquickmix = x
              Select quickmix stations.

       audio_format = {aacplus,mp3,mp3-hifi}
              Select audio format. aacplus is default if both libraries (faad,
              mad)  are  available.  mp3-hifi  is  available  for  Pandora One
              customers only.

       autostart_station = stationid
              Play this station when starting up. You can get the stationid by
              pressing i or the key you defined in act_songinfo.

       control_proxy = http://host:port/
              Non-american  users  need  a  proxy to use pandora.com. Only the
              xmlrpc interface will use this  proxy.  The  music  is  streamed
              directly.

       event_command = path
              File that is executed when event occurs. See section EVENTCMD

       history = 5
              Keep a history of the last n songs (5, by default). You can rate
              these songs.

       password = plaintext_password
              Your pandora.com password. Plain-text.

       proxy = http://host:port/
              Use  a  http  proxy.  Note  that  this  setting  overrides   the
              http_proxy environment variable.

       sort  =  {name_az,  name_za,  quickmix_01_name_az, quickmix_01_name_za,
       quickmix_10_name_az, quickmix_10_name_za}
              Sort station list by  name  or  type  (is  quickmix)  and  name.
              name_az   for   example   sorts   by   name   from   a   to   z,
              quickmix_01_name_za by type (quickmix at the  bottom)  and  name
              from z to a.

       user = your@user.name
              Your pandora.com username.

*taken from http://manpages.ubuntu.com/manpages/maverick/man1/pianobar.1.html

Comments

author
jfrost11 (author)2015-06-08

https://www.instructables.com/id/Raspberry-pi-Pandoras-Jukebox/

author
RuiB2 (author)2015-04-12

Hi, I'm from Portugal and I can't get acess or account on www.pandora.com .

Is there any chance for use www.groovesark.com or www.groovesark.com services ?

If yes, can explain me how can i add and configure it ? Thank you ALL !!

author
jeremyeaton89 (author)2015-03-26

can't we do `sudo reboot` instead?

author
saifA (author)2014-10-30

free account with the Pandora

I can't get an account at this website, because I'm from Saudi Arabia.

Is there any soultions for my problem ?

author
derekiswise (author)saifA2014-11-28

Yes, if you look up "free vpn for usa" or you get a proxy server this would work. With a bit of google searching about how to setup a proxy on your router you should be able to get this to work :)

if you have a more specific question like how to set it up on your router or computer i can help if you contact me

derekiswise@gmail.com

author
Gingerific (author)2014-11-21

Would a Spotify account be a okay substitute?

author
The Expert Noob (author)2014-08-29

raspbian repository updated piano bar to the latest version on Aug 26, 2014 and matches the git version 2014.06.08
http://archive.raspbian.org/raspbian/pool/main/p/p...

However after and apt-get update, its still choosing the older version (2012.05.06).
How can I change this?

author

I even tried this because that repository wasen't showing up in apt-get update:
add this repository to /etc/apt/sources.list (sudo nano /etc/apt/sources.list)

deb http://archive.raspbian.org/raspbian wheezy main contrib non-free

save

sudo apt-get update
sudo apt-get install pianobar=2014.06.08-1

should install the latest version, however, it giving me the error

Version '2014.06.08-1' for 'pianobar' was not found
author
comjosh64 made it! (author)2014-08-18

Ah, the dreaded TLS error! I gave up on this problem a few months ago and finally came back to it when I picked up a Raspberry Pi B+. I have an Adafruit LCD keypad kit and had completed the Python Wifi Radio project found here ->

https://learn.adafruit.com/pi-wifi-radio on a Pi Model B.

I had hoped that starting from a clean, updated image of Raspbian would fix the problem. Nope.

I followed the troubleshooting instructions for updating the tls_fingerprint to no avail. The problem for me wasn't that the fingerprint had been updated, it was that the repository available through apt-get for Raspbian it not up to date (as of 8/17/14) so you must re-compile pianobar from the source-code.

Wait. Don't freak-out!

Re-compiling is a long process, but with a good walk-through you're just copying commands. Your best bet is to remote in through an SSL connection to make it easy to copy and paste and so you're not dedicating a monitor to the task. I took it a step further and used Screen:


sudo apt-get update && sudo apt-get install screen


to monitor the progress on a few machines, just start

screen

and log into the raspberry pi from another machine and using the

screen -x

command you can view the same command line on as many computers as you like!

Why do you need to monitor it on multiple machines? Because it will take all day. Even using the "Medium" overclock settings on the new Pi (900Mhz) it took over 6 hours to complete. I'm not sure exactly how long it took because I was doing other things around the house while I waited.
This tutorial -> http://www.lanmaster53.com/2014/05/raspberry-pi-p... is the best I've found, I was able to bring my Wifi Radio back to life using it!

Best of luck!

P.S.

As a side note regarding the Raspberry Pi Model B+: The hardware changes (extra USB, power management, and combined audio / composite video jack) break the firmware on the old distributions of NOOBS. You will not have a keyboard / mouse until Raspbian boots. So go ahead and download the newest version. You'll need it to play with Sonic Pi ->http://www.cl.cam.ac.uk/projects/raspberrypi/sonicpi/ anyway.

PiPlate.jpg
author

is there enough space to build ffmpeg and pianobar on a 4Gb SD card? I guess we will find out.

author
idyll23 (author)2014-05-13

I've been fighting with my install of pianobar since I received a TLS Read error/handshake error (depending on how I approach it) a couple of weeks ago. I've added a script to check and update TLS to the latest version for handshake, but it still doesn't function correctly. I removed (apt-get remove) pianobar and moved on to the next step.

I checked the Github reports regarding this issue and they recommend compiling from source to resolve the issue but now I'm fighting with an issue with the makefile for Pianobar. It requests a specific version of libav but after installing ffmpeg (libav) none of the options for libav at the top of the makefile allow for a working compile.

Please tell me someone else has run into this issue and has a working solution.

author
GraziCNU (author)idyll232014-07-27

the pianobar 'executable' was placed into /usr/local/bin. move it to /usr/bin so you can use it as the default pi user. (this is what fixed my issue at least)

author
GraziCNU (author)idyll232014-07-27

Just followed my own walk through a few minutes ago. I get the error as well. I'll look around for an answer and edit accordingly. Stay tuned.

author
viragored (author)2014-07-10

I've got the same issue, installed pianobar, run it and get the "TLS read failed" message. Any help would be appreciated!

(PS - I think there's a typo near the end of step 7, which says, "You may not launch the Pianobar application by simply..." Should that be "You may now..."?)

author
Tinker_001 (author)2014-05-14

Really cool Idea but having issues at: pi@raspberrypi ~ $ pianobar (enter)

I get:

Welcome to pianobar (2012.05.06) ! Press ? for a list of commands. Login... Network error: TLS read failed.

Any ideas?

author
viragored (author)Tinker_0012014-07-10

I've got the same issue, installed pianobar, run it and get the "TLS read failed" message.

I've checked that the TLS fingerprint in the steps above still matches Pandora's - it does.

Any help would be appreciated!

author
GraziCNU (author)2013-09-09

Ignore the fact that one of the windows is an OS X terminal window. I was going back and forth between my two computers. The process will be the same regardless of window appearance :)

About This Instructable

83,775views

137favorites

License:

More by GraziCNU:Motion Activated LEDsSound Reactive LED StripTurning your Raspberry Pi into a personal web server
Add instructable to: