pimoroni-dashboard
On Raspbian, you can download the pimoroni-dashboard
and install your product by browsing to the relevant entry:
sudo apt-get install pimoroni
(you will find the Dashboard under ‘Accessories’ too, in the Pi menu – or just run pimoroni-dashboard
at the command line)
If you choose to download examples you’ll find them in /home/pi/Pimoroni/phatbeat/
.
Pirate Radio – Pi Zero W Project Kit
Build your very own internet-connected radio with the Pirate Radio Kit!
This kit has everything* you’ll need, including a Pi Zero W, our flash new pHAT BEAT DAC and stereo amp, a 5W speaker, and a beautifully retro acrylic enclosure to make it look the business. It’ll take you around 30 minutes to assemble everything** (check out our assembly guide for details).
Kit contents*
- Pi Zero W
- pHAT BEAT DAC and stereo amp. with VU meter and six buttons
- Male and female 2×20 pin headers
- Single 5W 4Ω speaker
- Blue acrylic enclosure***
- 50cm USB A to micro-B cable
- USB A (female) to micro B (male) adaptor
- Mini to full-size HDMI adaptor
- Sticker sheet (personalise your Pirate Radio!)
- Comes in a reusable kit box
*Just add your own micro-SD card
**Note that this is a soldering project, although you could use one of no-solder hammer headers!
***We’ve tweaked the design of the back layer and legs recently, and have updated the build guide with extra instructions for these new pieces.
Pirate Radio uses our new pHAT BEAT DAC and stereo amp. to drive the single speaker (left and right channels are mixed when you flip the DIP switch on the underside to mono mode). pHAT BEAT uses the same I2S mono DAC and amplifier that we use on Speaker pHAT and Picade HAT and… adds a second one for stereo goodness! The two rows of 8 APA102 RGB LEDs make the perfect VU meter, and there are 6 buttons along the edges to control your audio.
This kit takes advantage of the built-in wireless LAN and Bluetooth on the Pi Zero W, meaning that there’s no longer any need for a USB Wi-Fi dongle.
We’ve put together three different software projects for your Pirate Radio: an internet radio, a Spotify streaming box, or an AirPlay speaker.
Features
- Dual I2S DAC/amplifiers (MAX98357A)
- 3W per channel
- 2x push fit speaker terminals
- DIP switch to select blended mono or stereo modes
- 16 RGB LED pixels (APA102) in 2 rows of 8
- 6 edge-mounted push buttons
- Software installer and ALSA VU meter plugin
- 5W 4Ω speaker with pre-soldered wires
- 3-layer blue acrylic enclosure
- Pi Zero W with single core CPU and built-in wireless LAN and Bluetooth
- Adaptor kit
- 50cm USB A to micro-B cable (power your Pi from an existing charger or computer)
- Python library
- Female and male headers require soldering
Software
Our nifty one-line installer will get your pHAT BEAT configured and install our VU meter plugin for ALSA that uses the RGB LEDs on pHAT BEAT to display sound levels.
We’ve also put together a Python library to allow you to control the LEDs independently, if you wish, and to program the buttons to do whatever you wish.
Notes
Assembled size of Pirate Radio is 135x85x70mm (WxHxD).
https://shop.pimoroni.com/products/phat-beat
Stereo amplifier, buttons and dual RGB VU meter for your Pi.
Installing
Full install (recommended):
We’ve created an easy installation script that will install all pre-requisites and get your pHAT BEAT up and running with minimal efforts. To run it, fire up Terminal which you’ll find in Menu -> Accessories -> Terminal on your Raspberry Pi desktop, as illustrated below:
In the new terminal window type the command exactly as it appears below (check for typos) and follow the on-screen instructions:
curl https://get.pimoroni.com/phatbeat | bash
Alternatively, on Raspbian, you can download the pimoroni-dashboard
and install your product by browsing to the relevant entry:
sudo apt-get install pimoroni
(you will find the Dashboard under ‘Accessories’ too, in the Pi menu – or just run pimoroni-dashboard
at the command line)
If you choose to download examples you’ll find them in /home/pi/Pimoroni/phatbeat/
.
Manual install:
Library install for Python 3:
on Raspbian:
sudo apt-get install python3-phatbeat
other environments:
sudo pip3 install phatbeat
Library install for Python 2:
on Raspbian:
sudo apt-get install python-phatbeat
other environments:
sudo pip2 install phatbeat
Development:
If you want to contribute, or like living on the edge of your seat by having the latest code, you should clone this repository, cd
to the library directory, and run:
sudo python3 setup.py install
(or sudo python setup.py install
whichever your primary Python environment may be)
Documentation & Support
- Guides and tutorials – https://learn.pimoroni.com/phat-beat
- Function reference – http://docs.pimoroni.com/phatbeat/
- GPIO Pinout – https://pinout.xyz/pinout/phat_beat
- Get help – http://forums.pimoroni.com/c/support
Third Party Libraries
Easy VLC Radio
The easy VLC Radio set up is a small pre-built image with all the things needed to make your pHAT BEAT-powered Pirate Radio work out of the box.
It’s not designed to be highly interactive or customisable, but is great if you want to get a simple radio up and running quickly.
It’s still in beta testing, but it works well in many cases. Read more about it, and find the latest download link here: https://forums.pimoroni.com/t/piratepython-pirate-radio/7058
Raspbian VLC Radio
This project rolls a VLC radio onto your Pi, complete with controls via the buttons on pHAT BEAT.
Check out the full tutorial on our learning portal!
Installing:
The recommended way to install this project is using our one-line-installer, as this will ensure the pHAT BEAT is properly set up for playback:
curl https://get.pimoroni.com/vlcradio | bash
Alternatively, if you are sure you have a working setup and just want to refresh this project to get all the latest improvements, you can run:
setup.sh
Using:
After install you should be asked to reboot. If not, reboot 🙂
When the VLC Radio is ready to rock, the VU should flash once briefly. Press FF or REV to start playback.
You can also access the VLC server via http on port 8080 if you’d like to add streams or control playback and volume if you are not right next to the radio (leave username blank and use password raspberry
).
Playlist:
A default playlist is supplied with the project, but you can (and probably will want to) tune in your favorite stations, of course.
You can either create a playlist.m3u
and drop it in your home folder (in /home/pi/.config/vlc/
), or if you don’t feel like logging in via ssh you may also drop the playlist.m3u
in the /boot
partition of your SD from another computer and the VLC daemon will copy it in place for your convenience.
Reboot (or restart the vlcd
service) after editing or creating the file for it to take effect.
https://github.com/pimoroni/phat-beat/tree/master/projects/vlc-radio
Streaming Airplay to your Pi
We’ve put together a really easy little installer to set up your Pi as an Airplay speaker, letting you stream music from your iPhone (sorry Android users). The installer gives you the choice of setting it up with support for three of our pHATS – pHAT BEAT, pHAT DAC, or Speaker pHAT – or just with the standard audio through the Pi’s 3.5mm stereo jack.
This tutorial is perfect for the Pirate Radio Kit, or if you want to use our Speaker pHAT board to give new life to an old radio by wiring it up to the radio’s existing speaker.
We’ll cover preparation that’s needed for each device, and then go through how to run the installer. Note that you’ll need a keyboard, mouse, and display connected to your Pi for this.
Installing Raspbian
We recommend using the very latest version of Raspbian Lite, and you’ll need an internet connection to install the Mopidy packages later. We’d recommend using either the NOOBS installer, which you can find here (ensure that you select Raspbian Stretch Lite when installing), or downloading Stretch Lite from here and then using the Etcher tool to burn the image to your SD card.
Currently, our airdac installer is best supported by Stretch Lite, and may not work properly in the full version of Raspbian. Because Stretch Lite is… liter (sic) it should also run a bit more snappily than the full Raspbian.
Using the Pi’s built-in 3.5mm stereo jack
If you’re using the built-in audio on your Pi model B+, 2, or 3, then there’s no other preparation needed other than popping in your SD card and making sure that you have an internet connection, either from wired ethernet or by connecting to Wi-Fi (more on how to connect to Wi-Fi in Stretch Lite below).
Using pHAT DAC
If you’re using our pHAT DAC board, then you need to solder the 2×20 pin female header (that comes with it) to your pHAT DAC (and also solder a 2×20 pin male header to your Pi Zero or Pi Zero W, if you’re using one). We have a guide on how to solder headers to pHATs here.
Using pHAT BEAT or the Pirate Radio Kit
If you’re using the Pirate Radio Kit and haven’t already built it, then follow our guide here to learn how to put it all together.
If you’re just using pHAT BEAT, then make sure that you’ve soldered the 2×20 pin female header to it. Again, you can follow our guide to soldering pHATs. Connect a couple of speakers (or just one) to your pHAT BEAT’s push fit speaker terminals.
Using Speaker pHAT
If you’re using Speaker pHAT, then follow our guide to soldering it here.
Running the installer
Just to reiterate, you’ll need an internet connection to run this installer. Pop the SD card into your Pi, make sure that the audio board that you’re using is attached to your Pi (on its GPIO pins) if you’re using one, and then plug in the power and boot up your Pi. Because you’re using Stretch Lite, your Pi will boot straight to a terminal, but don’t be scared!
You’ll need to connect to Wi-Fi. To do this, you need to edit a file called wpa_supplicant.conf
. Type the following:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Use the arrow keys to move to the bottom of the file, and add the following, replacing the parts that say “YOURSSID” and “YOURPASSWORD” with the SSID and password for the Wi-Fi network to which you’d like to connect.
country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="YOUR_SSID"
psk="YOUR_PASSWORD"
}
Once you’ve made those changes, press control
and x
, then y
, and then enter
to save and close the file.
Now, type sudo reboot
and press enter
to reboot. Your Pi should now be connected to Wi-Fi.
To run the installer, type the following:
curl -sS get.pimoroni.com/airdac | bash
The installer will prompt you several times, and you should type y
for all of these, with the exception of the device selection. When it prompts you to select a device, then type the number of the device that you’d like to install. Note that if you’re using the built-in audio through the 3.5mm jack then you should select option 0 here.
The installer should also ask if you’d like to reboot once the installation is complete. If it doesn’t, then restart by typing sudo reboot
again.
What the installer does
The installer will do several things, that you don’t necessarily have to worry about, so stop reading this section now if that’s the case!
First, if you’re using one of our audio boards like pHAT DAC, pHAT BEAT, or Speaker pHAT, then the installer will configure your Pi’s ALSA audio to route audio out through I2S, the interface used by these boards.
Second, it will install any additional software required, like the software that controls the LEDs on Speaker pHAT and pHAT BEAT. These both use an ALSA audio plugin that actually processes the audio data (using FFT) and displays it on the LEDs. It’s called pivumeter.
Third and last, it will install the shairport-sync software that allows you to stream via Airplay to your Pi. This will be set to run at boot, so as soon as the installer is finished and your Pi has rebooted it should automagically appear as an Airplay device.
Streaming Airplay
Assuming that worked, you should now be able to stream to your Pi from your iPhone. Start your music playing, and then tap on the Airplay icon and select the device that will have the name “Raspberrypi”, unless you have changed the hostname on your Pi.
Note that if you’re using on of our I2S devices with an amp. (Speaker pHAT or pHAT BEAT), you may hear a slight pop when the device connects and disconnects the audio stream. This is due to the way that the Raspberry Pi and ALSA cut the audio stream when audio is not being output, to prevent overheating of your connected speaker.
Streaming Spotify to your Pi
This tutorial will guide you through all the steps necessary to stream Spotify to your Pi, using Mopidy, Mopidy-Spotify, and the Iris web interface. The end result will be a streaming Spotify box that you can control remotely from another computer in your house or from your phone (Android or iOS) or tablet.
We’ve put together a neat little one-line-installer to make this whole process really easy, but we’ll also explain what it does later, because you wouldn’t be learning otherwise, huh?
It will work either with the built-in 3.5mm stereo jack on your Pi model B+, 2, or 3, or with our audio boards – pHAT BEAT, pHAT DAC, or Speaker pHAT. It’s also perfect for the Pirate Radio Kit, turning it into a neat little streaming audio box.
Note that you’ll need a Spotify Premium account for this, although you can use this setup to play local music files, like MP3s, as well.
We recommend using the very latest version of Raspbian Lite, and you’ll need an internet connection to install the Mopidy packages later (we’ll explain how to do that in Raspbian Lite below). We’d recommend using either the NOOBS installer, which you can find here (ensure that you select Raspbian Stretch Lite when installing), or downloading Stretch Lite from here and then using the Etcher tool to burn the image to your SD card.
Currently, our spotipy installer is best supported by Stretch Lite, and may not work properly in the full version of Raspbian. Because Stretch Lite is… liter (sic) it should also run a bit more snappily than the full Raspbian.
Using the Pi’s built-in 3.5mm stereo jack
If you’re using the built-in audio on your Pi model B+, 2, or 3, then there’s no other preparation needed.
Using pHAT DAC
If you’re using our pHAT DAC board, then you need to solder the 2×20 pin female header (that comes with it) to your pHAT DAC (and also solder a 2×20 pin male header to your Pi Zero or Pi Zero W, if you’re using one). We have a guide on how to solder headers to pHATs here.
Pop the pHAT DAC onto your Pi’s GPIO pins.
Using pHAT BEAT or the Pirate Radio Kit
If you’re using the Pirate Radio Kit and haven’t already built it, then follow our guide here to learn how to put it all together.
If you’re just using pHAT BEAT, then make sure that you’ve soldered the 2×20 pin female header to it. Again, you can follow our guide to soldering pHATs. Connect a couple of speakers (or just one) to your pHAT BEAT’s push fit speaker terminals.
Pop the pHAT BEAT onto your Pi’s GPIO pins, if you haven’t already.
Using Speaker pHAT
If you’re using Speaker pHAT, then follow our guide to soldering it here.
Pop the Speaker pHAT onto your Pi’s GPIO pins.
Running the installer
Just to reiterate, you’ll need an internet connection to run this installer. Pop the SD card into your Pi, make sure that the audio board that you’re using is attached to your Pi (on its GPIO pins) if you’re using one, and then plug in the power and boot up your Pi. Because you’re using Stretch Lite, your Pi will boot straight to a terminal, but don’t be scared!
You’ll need to connect to Wi-Fi. To do this, you need to edit a file called wpa_supplicant.conf
. Type the following:
sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
Use the arrow keys to move to the bottom of the file, and add the following, replacing the parts that say “YOURSSID” and “YOURPASSWORD” with the SSID and password for the Wi-Fi network to which you’d like to connect.
country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="YOURSSID"
psk="YOURPASSWORD"
}
Once you’ve made those changes, press control
and x
, then y
, and then enter
to save and close the file.
Now, type sudo reboot
and press enter
to reboot. Your Pi should now be connected to Wi-Fi.
To run the installer, type the following:
curl https://get.pimoroni.com/spotipy | bash
You’ll need you Spotify username and password handy for this part. The installer will ask you to enter your username and password and will use this to configure the Mopidy-Spotify plugin. Note that your username and password will be stored in plain text so it’s a good idea, for safety’s sake, to have a unique password (i.e. to make sure it isn’t the same as any other passwords that you use), and that you don’t have any open, insecure ports on your local area network.
The installer will prompt you several times, and you should type y
for all of these, with the exception of the device selection. When it prompts you to select a device, then type the number of the device that you’d like to install. Note that if you’re using the built-in audio through the 3.5mm jack then you should select option 0 here.
The installer should also ask if you’d like to reboot once the installation is complete. If it doesn’t, then restart by typing sudo reboot
again.
What the installer does
If you’re not concerned with what the installer does, then stop reading this section now! If you are, then read on! It’s good to know exactly what it does in case you want to pull down our installer script and modify it for your own purposes (which you’re very welcome to do!)
Our installer installs Mopidy, and a bunch of plugins to add functionality to it. Mopidy is a network music server, that allows you to stream music over your local network or, in this case, from internet music sources like Spotify.
Here, we’re using Spotify as our music source, so we’re installing the Mopidy-Spotify plugin, which allows you to play songs, albums, playlists, and your own saved music on Spotify.
The Mopidy-ALSAMixer plugin allows you to control the system volume level straight from Mopidy, and will also allow us to hook it into our physical buttons on pHAT BEAT (if you’re using it).
The physical buttons on pHAT-BEAT are hooked up straight to the GPIO on your Pi. There’s a handy Mopidy plugin called Mopidy-TTSGPIO that lets you assign functions to buttons connected to GPIO pins; functions like play/pause, forward, back, volume up and down, and shutdown. Fortunately, the buttons on pHAT BEAT and the front panel on Pirate Radio are labelled up with those exact functions!
As well as allowing the use of GPIO-linked buttons, this plugin also allows text-to-speech to announce track and playlist names, and to confirm button presses, amongst other things, although we don’t enable this as part of the installer script.
The Iris web front-end provides a really slick-looking interface to control your Pi running Mopidy. It caters specifically for Spotify, so it’s set up with menu options for playlists and latest releases, etc. If you’re not using Spotify and instead are using local music, then it might be best to look into one of the other Mopidy web front-ends.
Our installer will also install and configure the software for your chosen music output device, be it pHAT DAC, pHAT BEAT, Speaker pHAT, or just the Pi’s built-in audio.
As we mentioned previously, the installer adds your Spotify credentials to the Mopidy configuration file (/etc/mopidy/mopidy.conf
). It also enables the appropriate plugins mentioned earlier, sets up the correct functions for the buttons on pHAT BEAT (if you’re using it), and makes the Pi’s IP address visible on your local area network, so that you can control it remotely on your PC/Mac/phone/tablet via the web front-end.
Lastly, it runs Mopidy as a system service, meaning that it will fire everything up automatically when your Pi boots.
Booting for the first time, and using Mopidy
As we said, now that everything is installed and set up, Mopidy should fire itself up when your Pi boots. If your Pi rebooted after the installer ran, then Mopidy may well be running already! It takes a couple of minutes to fire everything up, and maybe a little longer on a Pi Zero or Pi Zero W, so once you’ve plugged the power into your Pi, or rebooted it, then wait for a few minutes before following the steps below.
You’ll need to know your Pi’s IP address to access the web front-end remotely. If you have a display and keyboard attached to your Pi (we’ll assume you do, since you ran the installer), then type ifconfig
in the terminal to find your IP address. If this is the only Raspberry Pi on your network, and you haven’t changed the hostname of your Pi, then you will be able to use raspberrypi.local
instead of the IP address.
Open a browser window on your PC/Mac/phone/tablet and enter the following URL:
http://192.168.0.2:6680/iris/
where 192.168.0.2
is the IP address of your Pi, or if you’re going to use raspberrypi.local
then enter:
http://raspberrypi.local:6680/iris/
Your browser should have loaded up the Iris web interface. It’s fairly self- explanatory to navigate, but one important thing you’ll have to do is to go to the settings page and log in to Spotify, to authorise it, if it’s the first time you’re using it.
Click “log in”, and it should pop up a new window to authorise Spotify. If it doesn’t, then you might need to switch off any pop-up blockers that might be active. Now that you’ve authorised Spotify, you should have access to your playlists, and saved albums and artists, featured Spotify playlists, and more.
Because Iris is responsive, it looks really good on mobile as well, resizing and changing context to work on smaller displays. And because it’s just a regular web front-end it will work equally well in iOS or Android.
With the Mopidy-TTSGPIO installed and active, you should be able to use the buttons along the side of pHAT BEAT to control your music. Try them!
Taking it further
Why not try some of the Mopidy web front-ends, or some of the other plugins to use services like Google Play Music, SoundCloud, TuneIn radio, and YouTube. Or try to add an OLED display to show track and artist information? You could try to make your Pi music player Twitter or Slack controlled, turning it into a collaborative music player!