Speaker phat help


trying to get this to work how do I play music through the speaker phat


Hi David. Have you tried our one-line installer? There are some details in GitHub repo. readme file here -> https://github.com/pimoroni/speaker-phat

Let us know how you get on!


Hi thanks for the reply. I have installed the software ok but r forgive my ignorance but what do I do next to play music. As you may have guessed that am pretty new at this just need a few step by steps please.


What sort of music do you want to play? There are loads of choices. Probably the easiest is just to use YouTube, or YouTube playlists through the Chromium browser in Raspbian. If you’re on a Pi Zero, you might struggle a little with this as the weight of Chromium can cause the Zero to struggle a bit, although a Pi 2 or Pi 3 should give much better performance.

If you have an iPhone, we’ve just published a tutorial on how to stream music to your Pi (using a Speaker pHAT, pHAT BEAT, pHAT DAC, or just the built-in audio) using AirPlay - https://learn.pimoroni.com/tutorial/sandyj/streaming-airplay-to-your-pi

We should have a tutorial coming in the next few days on how to set up something called Mopidy, which has a bunch of plugins that let you do things like stream music from Spotify, Soundcloud, Google Music, internet radio, or just local mp3 files and such.

Hope that helps a little.


Got the sound working on the speaker Phat but no led,s any ideas


what are you using to play music back, airplay? is this on Raspbian Jessie Lite or full Pixel?


If you are doing airplay then I can’t get the leds going either and let me tell you I have been on a bit of a journey with rogue to get to that stage. My theory is that is something to do with i2c (as rogue has apa102s working fine (which run of a different protocol) ) and being unable to use it when connected ( my evidence for this is that when I change the vu output to a scroll phat hd, which uses i2c, I can not get that showing anything through airplay but works fine as a vu meter through mp3s. As I say I am no expert but that is the conclusion I have come to.


i2c permissions are handled by a different group than gpio I believe, which would certainly cause that problem.

One, probably overly-permissive, solution to giving PiVUMeter i2c access is to set up the /etc/udev/rules.d/60-i2c.rules file as documented in the top of this gist: https://gist.github.com/Gadgetoid/375f9dc0089f8518262dffb5179a56f7

KERNEL=="i2c-1", GROUP="i2C", MODE="0777"

The rest of the gist is irrelevant, ignore it!

Edit: I’m tentatively working on a Client/Server implementation of Pi VU Meter that hands the actual GPIO access off to another process to avoid all of these user context problems. Other suggestions welcome :D ALSA turned out to be more painful than I’d expected.


I don’t think that the issues from last week are due to user-context personally. I think there was a number of issues with sample rate handling, which I believe are in control now, that could well have cured other seemingly unrelated VU issues.

… I would encourage whoever has not ran the speakerphat installer in the last 24 hours to do so, and see if things have improved in their particular environment.

I’m also about to set up a full Raspbian Pixel to see what evil lurks in the background and may (still) cause problem… pretty icons don’t make a desktop experience necessary great ;-)


I can’t get the LEDs to work when used in AirPlay mode.
I tired the 60-i2c.rules tip but that didn’t work either.
I am using it on PiZero-W. Latest Jessie Build
$uname -a
Linux raspberrypi 4.4.50+ #970 Mon Feb 20 19:12:50 GMT 2017 armv6l GNU/Linux


The client/server implementation I was working on above has come a long way since then, but it’s still very much in development and there’s not much in the way of documentation for getting it up and running.

If you’re comfortable cloning the devel branch from GitHub and making a config tweak, you should check it out: https://github.com/pimoroni/pivumeter/tree/devel/python_server


Thank you. I just did.

git clone https://github.com/pimoroni/pivumeter.git
cd pivumeter/
git checkout devel
sudo nano /etc/asound.conf   #change output-device from speaker-phat to socket

Unfortunately, this did not work. Not only that, but it broke the existing LED lights functionality so that even locally played files don’t work. Opening an mp3 using vlc displays this error during startup:

[b4100e08] core input debug: `file:///home/pi/music/VPPP.mp3’ successfully opened
[b4100e08] core input debug: Buffering 0%
[b4100e08] core input debug: Buffering 8%
[b3c034d8] mpeg_audio decoder debug: MPGA channels:2 samplerate:44100 bitrate:192
[002dd178] core playlist debug: reusing audio output
[b4100e08] core input debug: Buffering 17%
[b4100e08] core input debug: Buffering 26%
[b4100e08] core input debug: Buffering 34%
[b4100e08] core input debug: Buffering 43%
[b4100e08] core input debug: Buffering 52%
[b4100e08] core input debug: Buffering 60%
[b4100e08] core input debug: Buffering 69%
[b4100e08] core input debug: Buffering 78%
[b4100e08] core input debug: Buffering 87%
[b4100e08] core input debug: Buffering 95%
[b4100e08] core input debug: Stream buffering done (313 ms in 43 ms)
Using device: socket
connect() failed
[001fc3f0] alsa audio output debug: using ALSA device: default
[001fc3f0] alsa audio output debug: Plug PCM: Meter PCM
Slave: Soft volume PCM
Control: PCM
min_dB: -51
max_dB: 0
resolution: 256
Slave: Direct Stream Mixing PCM
Hardware PCM card 0 ‘snd_rpi_hifiberry_dac’ device 0 subdevice 0
Its setup is:
stream : PLAYBACK
format : S16_LE
subformat : STD
channels : 2
rate : 48000
exact rate : 48000 (48000/1)
msbits : 16
buffer_size : 8192
period_size : 1024
period_time : 21333
tstamp_mode : ENABLE
period_step : 1
avail_min : 1024
period_event : 0
start_threshold : 1
stop_threshold : 1073741824
silence_threshold: 0
silence_size : 1073741824
boundary : 1073741824
appl_ptr : 0
hw_ptr : 0
[001fc3f0] alsa audio output debug: device name :
[001fc3f0] alsa audio output debug: device ID : HifiBerry DAC HiFi pcm5102a-hifi-0
[001fc3f0] alsa audio output debug: subdevice name: subdevice #0
[001fc3f0] alsa audio output debug: initial hardware setup:
FORMAT: S8 U8 S16_LE S16_BE U16_LE U16_BE S24_LE S24_BE U24_LE U24_BE S32_LE S32_BE U32_LE U32_BE FLOAT_LE FLOAT_BE FLOAT64_LE FLOAT64_BE MU_LAW A_LAW IMA_ADPCM S24_3LE S24_3BE U24_3LE U24_3BE S20_3LE S20_3BE U20_3LE U20_3BE S18_3LE S18_3BE U18_3LE U18_3BE


You need to also run the relevant Python code/library for the ALSA plugin to connect to.

Drop into “python_server/library” and run:

sudo python setup.py install

Then go to the “examples” folder and try: ./speakerphat-server.py


Thank you. I ran those commands. When I run the speakerphat-server in the background (./speakerphat-server.py &), and then run VLC to play a local file, it seems to see the ‘socket’ device and works normally. However, AirPlay still doesn’t light the LEDs when I play from my iPhone so I am back where I started. Am I missing something?


does adding user shairport-sync to the i2c group help? well, I am assuming you are using shairport-sync. If so, how did you install it, from source or via our convenience installer?


Tested here for sanity’s sake- I can get AirPlay lighting the LEDs using this setup. But you must make sure speakerphat-server.py is running at all times. I plan to rewrite it into a daemon at some point so it can be customised and installed properly and become one less thing to worry about.

You may need to pause/resume audio to ensure ALSA connects to speakerphat-server.py if you’ve just fired it up.


I am not sure what shairport-sync is. All I did was install the convenience installer:
curl https://get.pimoroni.com/airdac | bash
In any case, I checked and shairport-sync is already in the i2c user group:

$ groups shairport-sync
shairport-sync : shairport-sync audio i2c

I don’t see how your setup would be different than mine. I simply installed Jessie (2017-04-10-raspbian-jessie) from scratch, ran the convenience installer, then added the steps you outlined above. I am also running speakerphat-server.py in the background with the & operator

I’ve tried starting and stopping, connecting and reconnecting several times but the result is always the same. I can get audio via AirPlay but no LEDs light up unless it is a local file/stream on the pi zero.

I am using a Pi Zero Wireless if that makes a difference.

Incidentally, your instructions above about making a change to the 60-i2c.rules, has the “GROUP” set to “i2C” with an uppercase ‘C’. Is that right? On my pi, when I type “groups”, I see “i2c” with a lowercase ‘c’. In any case, I changed that line to use the lowercase “i2”, rebooted, and reran the python server script “speakerphat-server.py” in the background but no change.


I think the trouble is that I was testing on a lightning quick Pi 3, versus you testing on a Pi Zero. I ran into problems getting lights to show up on the Pi 3, and within the output of ./speakerphat-server.py (or in my case it was ./phatbeat-server.py) I was seeing Client connected and then Client disconnected before any audio started playing.

You might be having the same problem. I’ve pushed up a fix for it: https://github.com/pimoroni/pivumeter/commit/cf95c8b7b1d53124b1dea8afd231c9ea4ad0a62c

Try running a git pull then re-running sudo python ./setup.py install in the library dir.


Can you please clarify your post on March 7th.
Is GROUP in /etc/udev/rules.d/60-i2c.rules supposed to be i2C or i2c ?


It doesn’t matter for Pi VU Meter’s “socket” interface, it doesn’t use i2c directly at all, so those rules wont make any difference. Still it’s most probably supposed to be i2c and the uppercase c would be a typo