I’m trying to start blogging more of my projects, and this seemed like a good first one to start. We recently bought some raspberry pis, and I had the broad ambition to pair mine with a Griffin Powermate to turn it into some sort of amazing mood machine, which plays Pandora stations on demand.
I’ve gotten about halfway there, so I thought I’d share a quick tutorial:
- Raspberry Pi ($35)
- Case ($5)
- USB Wireless Adapter ($15)
- MicroUSB cable (free, had around the house)
- Speakers (free, using DVD/surround sound system for house)
- 1/8” headphone connector (free, had around the house)
Set up your Raspberry Pi & install Raspbian.
Plug in your raspberry pi, connected with the wireless USB adapter, keyboard (for setup), and hdmi cable. You’ll also want to plug in your audio jack to the speaker you’ll be using to output the sound.
I followed this Raspberry Pi Overview Tutorial to install Raspbian and my wifi card. Everything was pretty straightforward, except that I was using a hidden network SSID and the pi wouldn’t connect to it. I had to unhide the network, connect the pi, and then rehide the network. I also assigned the pi a static IP so I could SSH to it easily.
Once you’re up and running, make sure to run your updates before moving forward. It’s super easy, just run:
sudo apt-get upgrade
sudo apt-get update
Again, this is super easy. Just SSH into your machine, and enter
sudo apt-get install pianobar
Then, you can run pianobar by just typing
Pianobar should prompt you to enter your username and password. When I did this, I got an error "Network Error: TLS Handshake Failed". After a bit of investigation, I found I had to do a bit of editing to the config file. Unfortunately, that config file didn’t exist!
Create & Set Up Pianobar Config File
Get to your /home/pi/.config/ and see if the folder “pianobar” exists. If not, create that directory and then create a file named config. I did this by entering:
Then, you need to paste this data into your file, with a few edits (example config file from Instructables) For the record, I am TERRIBLE at vi or any of those types of text editors, so this was the most painful part of the process. Alot of mashing keyboards and referencing this. After all this, EJ told me that running nano to edit the file would have been much better/easier. The more you know!
# 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 = email@example.com
password = password
#password_command = gpg --decrypt ~/password
# Proxy (for those who are not living in the USA)
#control_proxy = http://127.0.0.1:9090/
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 = )
#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 = 0
# Format strings
#format_nowplaying_song = [32m%t[0m by [34m%a[0m on %l[31m%r[0m%@%s
#format_nowplaying_station = Station [35m%n[0m
#format_list_song = %i) %a - %t%r
# 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 = B0A1EB460B1B6F33A1B6CB500C6523CB2E6EC946
Change the user and password to your information. I also had to update the tls_fingerprint to "2D0AFDAFA16F4B5C0A43F3CB1D4752F9535507C0" to fix the TLS handshake error.
I booted up pianobar again, and was auto logged into the system. I selected the correct station, and a song began playing—but no audio yet.
Setting up audio on raspberry pi
sudo apt-get install alsa-utils
sudo apt-get install mpg321sudo modprobe snd_bcm2835
This got HDMI sound running. BUT, I wanted the sound to come out of my audio jack, so I had to run:
sudo amixer cset numid=3 1
Where “1” represents the audio jack . Then, I ran speaker-test to see if it was all working, which it was!
Run Pianobar from terminal, like a dork
Now, I can SSH into my raspberry pi, which is across the room, and play any of my set up Pandora stations, without having to run flash or anything else annoying. Also, I get major nerd-cred for having a pandora player look like this:
For the record, those “Cannot start eventcmd” errors have not impacted me at all, so I did what anyone would and ignored them.
Next, I’ll talk about how I set up a fifo to control my stations from scripts, and delve into the adventure that is trying to get the Powermate set up as an input device.