This is how I got Pirate Radio to Work with Radio and Spotify

Pirate Radio

Hi guys:

I thought I’d buy a Pirate Radio as an Xmas Present for various nephews and a daughter who are doing coding. But first, to see whether it was the right thing and easy to set up, I thought I’d build the first one myself.

I’ve had some experience in UNIX and DOS and can do more than wire a plug. It should be easy although I don’t have much experience with Pi’s.

The headline is that it took me twelve hours by the time I’d tried three bare-metal installs without too many instructions to follow and loads of googling around on the interweb.

Once I’d done three reinstalls, the last one took about an hour so I’d thought I’d write down to benefit those who want to have it up and running for Xmas lunch on 25th December. It’s a great product but it needs all the steps written down in one place for newbies.

Assembly

Putting the components together was pretty straightforward and took an hour including the secondary stereo speaker and the ‘hammered’ non-solder connectors. The instructions at
learn.pimoroni.com/tutorial/sandyj/assembling-pirate-radio
were alright but could have benefitted from some more front & side-on pictures.

I’d plugged in the NOOBS micro-CD, turned it on and expected it to work. Call me naïve!

So, the first decision to take is whether you want to

  • Use the Pirate Radio to listen to a limited number of Radio Station mp3 streams that you’ll copy-and-paste enter into a config file on the pi
  • Use the Pirate Radio to listen to Spotify Radio – but only if you have a premium account.
    I tried both methods before deciding the Spotify variant was better for me…

Set-up

So, this is what I did to get it working

Burn the MicroSD Card

Get Ready for First Time Switch On

  • Put the SD card in the Pi
  • Connect using the Pi to a TV using a HDMI cable [using the adapter provided in the kit]. You’ll need a TV that has a HDMI slot and a HDMI cable]
  • Connect a USB keyboard to the Pi using the adapter cable provided. [You’ll need a USB Keyboard]
  • When all of this is done, switch on and see the boot-up text to roll up the screen

Log On and start the config

When you see the prompt, logon with username: pi password: raspberry

Connect to Wifi

Use the command sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Edit country=GB

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

update_config=1

network={

ssid="MyNetwork"

psk="NetworkPassword"

}

Make sure you include the double-quotes

Save the file using Ctrl-X, [Y]es, Return

Now turn on SSH

sudo raspi-config

In interfaces, select SSH and use the cursor buttons to turn it on

At the prompt, reboot,

sudo reboot

Your Pi should now be connected to Wifi

Logon

Find the IP address using

ifconfig

Look for the IP address in wlan

Connect to the Pi using SSY

Download putty from here www.putty.org/

Start a new session connecting to the IP address

Logon to the raspberry

If you’ve chosen the Radio Option

##in radio mode

curl https://get.pimoroni.com/vlcradio | bash

It takes some time. Press the play button. Cycle through the four pre-selected stations using the fast-forward button.

If you want to change station list to listen so something you might prefer

I googled “bbc radio mp3 streams” and found some here www.suppertime.co.uk/blogmywiki/2015/04/updated-list-of-bbc-network-radio-urls/

Comment out the ones you don’t want by prefixing the line with a # symbol

cd /etc/vlcd

sudo nano default.m3u

Ctrl X, Y, return

Hint: If you have copied the URL, position the cursor in the file and paste using the right-click button on the mouse.

sudo reboot

when the radio reboots, you can cycle through YOUR stations.

## in spotify mode

Remember that you need to have a paid-for spotify premium account to use the mopidy server and spotify add-on. Make sure you have your Spotify username and password to hand.

So I started here learn.pimoroni.com/tutorial/sandyj/streaming-spotify-to-your-pi

curl https://get.pimoroni.com/spotipy | bash

It takes about 30 minutes to download and install. It’s an attended install because you’ll need to press [Y]es and [R]eturn at several steps during the process.

Whilst this is going on, you must visit https://www.mopidy.com/authenticate/ to get some tokens that you’ll need to copy and paste into the mopidy.conf file when the Pi install is completed.

When the install is complete you’ll need to edit /etc/mopidy/mopidy.conf file

cd /etc/mopidy

sudo nano mopidy.conf

Use the down cursor to find the [http] block. Comment-out the line that says 127.0.0.1 and replace with a new line 0.0.0.0

[http]

#hostname = 127.0.0.1

hostname = 0.0.0.0

That’s a really important bit. I wasted hours doing bare-metal installs without knowing to change the hostname.

In the Spotify Block….

[spotify]

username = myusername

password = 4qFZ0thH

Paste-in the text you were given when you logged into the [https://www.mopidy.com/authenticate/ website](https://www.mopidy.com/authenticate/ website)

client_id = b229b207-f3e4-9af1-7a1cf45a96fe

client_secret = CZVGX050b7UCBQ8t-UJLJo1y3etk5K637aPk4=

Save the file, Ctrl-X, Y, [R]eturn

Reboot

sudo reboot

You can check everything using mopidyctl status found here https://docs.mopidy.com/en/latest/service/

sudo mopidyctl config

sudo systemctl status mopidy

Now you can listen from your web browser

raspberrypi.local:6680/iris

or

192.168.0.112:6680/iris or whatever your IP address is using the ifconfig command

Hope this is helpful. Happy Xmas.

2 Likes

Nice detailed post there. That should help a lot of first time users.
It can be a bit tricky to setup depending on how you go about it.
I’m not saying anything you did was wrong, just that there are usually more than one way to get there.

I personally avoid NOOBS, just my personal preference because I almost always only ever run Raspbian.
I get the latest image from the Pi foundation site and use Etcher to image my card.

On a lot of my installs even headless setups I install the full Raspbian. Some would call it cheating as it lets me avoid most of the command line stuff. It’s what I used for my Prate Radio setup. All the language, location, and WIFI setup is done from the quick setup GUI menu. When I’m all done with that I set it to boot to command line instead of the desktop.

For the Pirate Radio I just run the one line installer and reboot.

A quick a dirty way to get you playlist in there is to take your SD card and plug it into another PC. Then just drag and drop your playlist.m3u file to the Boot partition. When you boot the Pi up it then gets copied / moved and becomes the new default playlist. You can edit the default one too. I have the path to that someplace, will post it when I can find it. I didn’t do much beyond the stock install.

Again nice detailed post, just thought I could add some of my experience to it. ;)

EDIT: To edit the default playlist its sudo nano /etc/vlcd/default.m3u.

Just remembered one more tweak I do to mine. I had an issue where it wouldn’t always start up on the last channel / station I left it on when I shut down. Sometimes it would skip to the next station or just not play any music. I’d have to hit the play pause or channel up down to get it to play. In Raspbian I went into the configuration menu and set it to “wait for network”. It takes a little longer to boot up but always starts up and remembers what station it was on. Down side is I’m not sure what happens if you lose your Internet connection? Best guess is it eventually moves on and boots up anyway.

i think Noobs is suggested because it easier to get to the sdcard ,just copy past the download to the sdcard ,not need for 2nd piece of software to burn to sdcard

Good point Jack, you can just copy and past it over to a formatted SD card. Still not a big fan of it though, but thats just me. ;) One down side to Noobs is it changes the file structure around a bit. That file you want to edit isn’t where it normally would be in a stock Raspbian install. Not a big deal as long as your aware of the differences.

Awesome written article which must be published as official guide for pirate radio. I struggled a lot to set it up till I found your this article. Thanks a lot. Everything worked out flawlessly after following it step by step. :)