Pandora's Box - An Internet Radio player made with a Raspberry Pi!

FeaturedContest WinnerContest Winner
Picture of Pandora's Box - An Internet Radio player made with a Raspberry Pi!
Plug in this internet radio player and listen to your favorite stations on Pandora Radio. Six pushbuttons control the music, while an LCD gives feedback on the song, artist, and other useful information. All of this is housed in a custom acrylic case with access to the Raspberry Pi's ports.

Special thanks to LVL1 Hackerspace ( for use of their laser cutter!

Raspberry Pi is a trademark of the Raspberry Pi Foundation.
Remove these adsRemove these ads by Signing Up

Step 1: Parts List

In order to build the system, you will need several things. The main piece is a Raspberry Pi Model B with a 5V, 1A power supply. This Instructable is based on a Revision 2 board, but will work on earlier boards with minimal changes. 

Next, you will need an SD card with a Raspbian Wheezy image. Instructions for this process found at:

Electrical hardware needed:
1) Solderless breadboard (and wire)
2) Serial LCD module (3.3V module from Sparkfun was used:
3) Ethernet Cable
4) USB Keyboard and mouse (necessary for setup, not the final product)
5) Pushbuttons (6) -  "Normally Open" type with threaded mounts
6) 3.3V Regulator (LM1117T-3.3 from Texas Instruments in the TO-220 package type used here)
7) Resistors: (7) ~10kOhm, (6) 1 kOhm
8) Capacitors: (2) 10 uF tantalum (as recommended by TI for 3.3V regulator
9) Pi T-Cobbler from Adafruit (not necessary, but makes GPIO access much easier)
10) Auxiliary audio cable

Other equipment needed:
1) Soldering Iron and solder (for the T-Cobbler breakout board)
2) 1-Minute Epoxy (for the acrylic case)
3) Acrylic (and a means of cutting it)
4) Nylon Standoffs and Screws
5) Velcro strips (with sticky sides)

The acrylic used in this project was 0.08" thick and can be found at Lowe's in 8"x10" sheets. This was great for cutting with a laser-cutter. Other thicknesses can probably be used - this will be left up to your discretion (and experience).

The standoffs used were a combination of (3/8"  - hex -  1.25" -  4-40 thread) and (3/8" - hex - 0.375" - 4-40 thread) nylon male/female standoffs. 4-40 fillister flat head nylon screws were used with these standoffs.

Although this Instructable includes directions for the custom case, this is probably the trickiest part of the design. Familiarity with a laser-cutter is necessary, since every laser cutter and design software package is different.

Step 2: Setting up the Pi

Picture of Setting up the Pi
After getting Raspbian Wheezy up and running on the Pi, the OS will need to be configured. Four changes need to be made.

1) In LXTerminal, run the following:

sudo raspi-config  

The SD partition should be expanded to fit the entire SD card, and the boot_behavior option should be set to boot to the desktop on startup. Also, enabling the SSH server will let us work on the Pi on a separate computer, without a keyboard and mouse plugged into the Pi.

2) Next, follow the instructions here to stop the OS from writing to the UART, which we will use to drive the LCD:

3) Adding Serial Communication to Python:
The OS comes with Python installed. We need to add the serial module in order to drive our LCD module. Run the following in LXTerminal:

sudo apt-get install python-serial

Documentation for the Pyserial module can be found at:

4) Enhancing BASH's GPIO Capabilities:
Now, in order to access the GPIO pins in a more user-friendly manner, we will install the wiringPi library. Instructions are available here:

However, to simplify these instructions, we only need to run:

sudo apt-get install git-core
git clone git://
cd wiringPi
git pull origin

Now simply wait for the build to finish, and the operating system is ready to install Pianobar, an open-source program running Pandora Radio.

Important warning: All of the work in this Instructable assumes you are working as the "pi" user. If not, the file locations used later on will need to be altered. Either work as the "pi" user, or be prepared to alter some scripts later.

Step 3: Installing Pianobar

Picture of Installing Pianobar
Pianobar is an open-source, lightweight terminal program which runs Pandora Radio. Although the Pi is limited in resources, a lightweight application like Pianobar is right at home.  Setup is simple - run the following from a terminal:

sudo apt-get install pianobar

After entering "y" to all the prompts, Pianobar should be successfully installed. By entering pianobar in a terminal, the program begins. Log into your  Pandora account, and get a feel for the program. (Hint: typing "?" will give a list of keybindings for controlling Pianobar)

This installation has a directory for configuration files located in /home/pi/.config/pianobar. Our next step is setting up configurations for Pianobar, an example of which is given below. (Note that the login information needs to be replaced with your own Pandora account information).

Copy the following into a new file "config" in the /home/pi/.config/pianobar directory, changing the login information:

# 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 =
password = password
# or
#password_command = gpg --decrypt ~/password

# Proxy (for those who are not living in the USA)
#control_proxy =

# 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/
fifo = /home/pi/.config/pianobar/ctl
#sort = quickmix_10_name_az
#love_icon = [+]
#ban_icon = [-]
#volume = 0

# Format strings
#format_nowplaying_song = %t by %a on %l%r%@%s
#format_nowplaying_station = Station %n
#format_list_song = %i) %a - %t%r

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

After setting the configuration file, restart pianobar from a terminal. It now automatically logs us into Pandora, and ask what station to play. After selecting a station, an 18 letter number will appear in parenthesis. By copying this number into the config file under autostart_station, Pianobar will automatically start playing that channel once it is opened.

If you are a Pandora One subscriber, additional settings in this config file will let you access high-quality streaming.

Step 4: Setting up the fifo

The fifo lets a script send commands to Pianobar. This is useful for sending button-based commands from a BASH script. In the last step, we configured Pianobar to look in the /home/pi/.config/pianobar directory for a fifo named “ctl”, which still needs to be created. In LXTerminal, the following command makes a fifo:

mkfifo /home/pi/.config/pianobar/ctl

To test that everything is working correctly, restart Pianobar. In another terminal window, enter:

echo 'n' >> /home/pi/.config/pianobar/ctl 

This should change the song being played by Pianobar. If so, we are now able to control it from another terminal (and by extension, a BASH script). All of the commands from Pianobar can work this way - and some interesting combinations can be made. Try “))))))” to increase the volume a lot at one time, or check out the difference between “s” and “s2”. Experimenting with this now will help our scripts make sense later.

Step 5: Setting up the Hardware

Picture of Setting up the Hardware
There are four main components that need to be connected: the Raspberry Pi, the T-Cobbler breakout board, the serial LCD module, and the six pushbuttons. The Pi should not be connected to the power supply during these steps in case any wires get crossed.

Although it is not absolutely necessary, the T-cobbler makes working with the Raspberry Pi's GPIO pins much simpler. Some assembly is required for the breakout board (instructions for this are available at:

It is important to connect the ribbon cable the proper direction. On the Pi, the red line of the ribbon cable should be attached closest to the SD card (away from the yellow composite video connector).

Once the ribbon cable is connected to the Raspberry Pi, the T-Cobbler should be placed on a breadboard as shown in the second image.

Step 6: Connecting the LCD

Picture of Connecting the LCD
The LCD module from Sparkfun accepts serial input, making it simple to communicate with on the Raspberry Pi's UART Transmit (TX) pin. 

This circuit uses three pins on the T-Cobbler breakout board - 5V, GND, and TX. For more information about the GPIO pins, refer to:

Be careful about running wires next to the 3.3V regulator - it will be producing a modest amount of heat.

Bonus: Now that the LCD module is connected, some quick Python scripting will let us control it. Try the following Python "Hello World" script:

import sys, serial, time
global serialport
LCD = serial.Serial('/dev/ttyAMA0', 9600)
LCD.write('\xFE\x01')      #CLEARS THE LCD

Step 7: Connecting the Pushbuttons

Picture of Connecting the Pushbuttons
Each of the six pushbuttons needs a GPIO pin connection. The schematic shows a circuit that needs to be duplicated for each pushbutton. This circuit is useful since when the pushbutton is open, this arrangement does not drain any power. However, a logic "1" will be read on the GPIO pin, which is important to note. Also, the 1kOhm resistor on the GPIO pin is important in case the pin is set to output mode when the button is pressed. This would overdraw current on the pin, possibly burning it out. 

On the Revision 2 Pi, the six pushbuttons will connect to GPIO pins 2 (SDA), 3 (SCL), 4, 17, 27, and 22 (in order of vertical appearance on the Pi T-Cobbler). These pins are different for the Revision 1 boards; the pin changes can be found at the low-level peripherals link from the previous step.

EDIT: Since pins 2 and 3 on the Revision 2 board have pull-up resistors on them, the circuit I have shown is unnecessary (and may not function properly). You can simply connect the pushbutton between the GPIO pin and GND. 

The box has six buttons. In the picture, they they are attached from left to right in the pin order given above. The functions are:
1) Change Song
2) Change Station
3) Volume Down
4) Volume Up
5) Pause/Play
6) Menu/Shut Down

Button six has a dual function. If pressed momentarily, it brings up a Menu. If held for more than two seconds, it shuts down the Operating System. Once the Menu is open, new button functions are available. They are:
1) Like the current song
2) Dislike the current song (also skips to the next song)
3) Display the Pi's IP
4) Nothing (yet...)
5) Nothing (yet...)
6) Exit the Menu

Displaying the IP was added to make SSH access easier.

Step 8: Putting it Together with BASH and Python

Now that the hardware is connected, some custom scripts will give us control over Pianobar, the LCD, and the buttons. Programmers will probably cringe, but for simplicity's sake I gave each of these files full permissions for each user (in the terminal, enter "chmod 777 x.xx" where x.xx is the filename). This lets a BASH program execute a Python script, for example.


The first step to creating these scripts is to edit the autostart file in the LXDE directory. Edit this file with:

sudo nano /etc/xdg/lxsession/LXDE/autostart

Now add two lines to the end:

bash /home/pi/.config/pianobar/scripts/

Save and exit, and your OS is configured to start pianobar at startup. It will also begin continuously polling for pushbuttons. 

The scripts used to control the LCD and buttons are hosted in a Github repository. They can be retrieved through the following:

cd /home/pi/.config/pianobar
git clone git://
cd Pandoras-Box
git pull origin
cd ..
cp -r /home/pi/.config/pianobar/Pandoras-Box/scripts/ .

Now that the scripts have been retrieved, only one step remains to create a working system. 

Final Step: Since one of the options is to randomly select a new station, the main script needs to know how many stations are on a user's Pandora account. (To figure this out, start Pianobar and press "s". This will list all the available stations). Now open the file /home/pi/.config/pianobar/scripts/ and change the "n=" value to the number found above.

Your system should be complete! Please comment on this Instructable with any issues you have, and I will try to address them. The next step talks about making a case, but the system should be fully functional before this step.

Step 9: Custom Box Design

Picture of Custom Box Design
Top Plate.JPG
Side Plates.JPG
Middle Plate.JPG
Bottom Plate.JPG
Back Plate.JPG
A nice custom box is a great way to finish any project! Unfortunately, fabricating custom boxes is no cake walk. Plans for the box are attached, however should only be used as a general basis for your work. Verify the measurements (and puzzled edges) before starting the laser.

Note: The images attached are not to scale. They give dimensions for a box made from 0.25" acrylic. After a trip to Lowe's, I decided to use 0.08" acrylic instead, so the dimensions were adjusted accordingly when sent to the laser-cutter. Unfortunately, these plans are lost in the ether. You will have to use your judgement with the box design. Access to a drill (or drill press) and a tap set help tremendously. I do not recommend you attempt to cut the smaller holes (3/32") with the laser-cutter - they should be drilled instead.

In the six images provided, seven box pieces are given. One piece is for a horizontal divider inside the box, which is used to stack the Raspberry Pi above the breadboard. Once all seven pieces were cut, the holes should be drilled to the appropriate pilot size and then tapped as noted on the diagrams. Note that the LCD's holes are missing from the face plate, and will need to be added.

Before assembling the sides and bottom, connect the pushbuttons and LCD to the front plate. After this, the four sides and bottom can be assembled using 1-Minute epoxy. I did not use epoxy on the top piece, since I like being able to open the box (hinges or clear tape are both would be a nice choice to connect the top).

Once the sides are assembled, the breadboard should be attached to the bottom using velcro. 1.25" standoffs should be added, then the center piece screwed into these. After connecting the ribbon cable, the Pi should be mounted to the smaller 0.325" standoffs and screwed in place. Secure the top, and the system is complete! Photos of the final product are given in the last step.

Step 10: Final Product

Picture of Final Product
Finished, assembled product for reference. I hope you enjoyed!
1-40 of 153Next »
gbovee2 years ago
Can someone explain to me the point of using 5v and a regulator to get to 3.3v when there is a 3.3v supply from the pi. I am fairly new to this stuff and am just trying to learn. Thanks.
NickD4 gbovee19 days ago


Ayy (author)  gbovee2 years ago
That's a really good question. The answer has to do with the current limit on the Raspberry Pi's 3.3V line. According to the link below, the 3.3V line can output up to 50 milliamps current. Meanwhile, the 3.3V LCD module I used can draw up to 60 mA.

While LCD may never draw that full 60 mA, it has the potential to cause issues. Since the 5V supply can supply over 300 mA (when using a 1A power supply), I chose to add the 3.3V regulator.  

RPi electrical specs:
gl0rious2 years ago
Could i get an estimate of the cost? i really would like to do this project, and i am a beginner..
Ayy (author)  gl0rious2 years ago
This depends on what equipment you already have. For example, I already had soldering equipment, drill and tap set, standoffs, SD card, and resistors. I'll give some prices for the bigger items:

Raspberry Pi: $35 + shipping
Power Supply: $8 + shipping
T-Cobbler: $8 + shipping
Serial LCD Monitor: $25 + shipping
Buttons: $7
Acrylic Sheets: $8
Epoxy: $5
Capacitors: $2
Velcro: $5

The small things tended to add up quickly - like the bits I had to get from Radioshack and Lowes (buttons, capacitors, velcro, etc). I probably could have gotten some things much cheaper online, but I didn't have the patience to wait for the velcro to ship. All the parts were around $110 with shipping - but since I plan on reusing most of the stuff for future projects, the cost felt reasonable.

Hope that helps.
akcook Ayy2 years ago
gl0rious Ayy2 years ago
thats very helpful thanks
Ayy (author) 2 years ago
Note: On the box plans, the center piece has an issue with the spacing of the raspberry pi's holes. If you are making the same box, double check the holes (I don't have the original files to correct the images...)
reterpoca1 month ago

The apt-get version of pianobar is out of date I believe, which is the reason it doesn't work. You'll have to install from github

neodnoc made it!3 months ago

Pretty neat project. I added an Adafruit 20W stereo amp and a couple scavenged speakers from an old iHome iPod dock that died. Now I just need a case.


yieldlymph4 months ago


amerigoh7 months ago

Question for a beginner :

Can someone tell me if this lcd module could work instead of the Sparkfun :

paverphalange8 months ago

Its magnificent

motherprune9 months ago

Its sweet

cobbledbeard9 months ago

Its cooler

mousepaper9 months ago

Extremely good

Its splendid :)



amazedgreen9 months ago


fastbobble9 months ago

Thats impressive

gorgeddamp9 months ago

Very good

clearedeager9 months ago

Its awe-inspiring :)

illrings10 months ago

Its stunning :)

airbugger10 months ago

Could i get an estimate of the cost?

Thats trendy...

headlymph10 months ago


thatsawesome6410 months ago

could you connect this to iheartradio or spotify?

tealrink10 months ago


grousebandit10 months ago

Its cooler

harechubby11 months ago


jiffymanager11 months ago


mike-house11 months ago

So everything works but when the script runs to watch the GPIO pins it peaks the cpu to 100%. This wouldn't be a problem I guess but it causes a pause from then I push a button to getting the pi to respond.

calmlunch11 months ago


spewlocks11 months ago


clapfilk11 months ago



spongeraffle12 months ago

Its magnificent :)

lack3r1 year ago

Hi guys. This is actually a great post. However, Pandora cannot be used outside US :(. Is there a way to do the same project but with another online radio provider, let's say TuneIn? Because this cannot be used outside US...

Its cooler :)

1-40 of 153Next »