Setting up the PhatBeat buttons to be automatically available


Apologies if this is a duplicate, I did do a search.

I just bought a PhatBeat which eventually I intend to hook up to a spare Pi Zero, but for the moment I attached it to a Raspberry Pi 3 Model A. This Pi is running the lite version of Raspbian Buster to which I installed Mopidy and has been running nicely for a couple of weeks, via the Model A’s audio jack.

I added the PhatBeat to my Pi and ran the one-line installer from Yarr-niversity and everything went smoothly as far as I know; I’m sitting listening to music via the PhatBeat at the moment after wiring in a set of hi-fi speakers.

However, what isn’t working is the hardware buttons. The Getting Started page describes how to use some Python decorators but doesn’t explain how to make them go without you needing to type into an IDE. From searching this forum I find references to a service called phatbeatd which apparently makes the buttons work, but this isn’t installed on my Pi and I can’t seem to find any references for how to install this service.

Can anyone offer suggestions on how to install this service or otherwise get something that will auto-start and listen for button presses? I’m mainly interested in the shutdown button - I’d previously followed a tutorial for listening for the GPIO pins 5 and 6 to be shorted in order to do a controlled shutdown, and given the GPIO pins are now used by the PhatBeat I need another solution other than yanking the plug out.

Hope this isn’t too much of a noob question and I haven’t missed out anything dumb.

Richard Moss

I have a pirate radio setup using the phat Beat.
If memory serves me I followed this guide.
My buttons work as advertised.

Enabling i2c kills the default dtoverlay=gpio-shutdown . You can still use it you just have to map it to another GPIO pin. On my fan Shim I use the following
The Fan shim grounds GPIO 3 (pin 5) and GPIO 17 (pin 11). 17 is the BCM number not the physical pin number.

EDIT: If you get those buttons working with their defaults, pressing the power button on the pHat Beat will have it do a proper shutdown. It maps out to GPIO 12 (pin 32).

Or try dtoverlay=gpio-shutdown,gpio_pin=12,active_low=1,gpio_pull=up


Thanks for the reply. I just tried the curl | bash command referenced in the article you linked - aside from the VLC Radio program it seems to be pretty much the same as the core installer. It did give a warning that the VLC Radio Installer can’t be installed on this version of Raspbian, which is actually totally fine as I don’t want it.

Regretfully however, even after rebooting the buttons still don’t do anything. Running sudo service --status-all doesn’t show anything Phat (assuming the phatbeatd is something real).

A little puzzling if it is supposed to “just work”.

Richard Moss

I do believe the buttons work in / from VLC radio? It’s whats running on boot up for me. My Pirate Radio isn’t running Buster though. Jessie I believe, I haven’t had to reinstall in ages and, “if it ain’t broke, don’t fix it”. ;) So I just leave it as is as long as its working.

I just did a test where I ran python and added a decorator to print a message when the power button was pushed - said message was printed when I pressed the button. So it looks like things are installed and working. And the VDU meter works perfectly well, although I wish I could change the scale as I have it running at about 20% of volume which means pretty much only the first two lights actually come on.

So it’s just something that stays resident that is missing I guess. If the phatbeatd service is part of VLC then that’s a little annoying if it won’t install on buster, but I suppose there’s probably something else that can be done. My goal was to test it on this pi and then doing a fresh install for a Pi Zero, perhaps I could downgrade to Jessie but I’d rather be running the latest version of things as I’m not as familiar with the Linux world as I am with Windows.

Richard Moss

Going by the product page the pHat Beat installer sets up the DAC as the audio source and adds a Alsa plugin for the VU meter.
Best Guess is you have to setup the Buttons for what ever Audio program you want to use?
How to make use of the buttons from python is documented here.

There is a fix for the VU meter.
You can increase the sensitivity on the Phat Beat VU Meter by doing the following:
cd Pimoroni/pivumeter
nano src/devices/phat-beat.c
Change line 88 to:
int bar = (meter_level * (meter_level / 8) / 131071.0f) * (brightness * (NUM_PIXELS/2));
Recompile the library:
sudo make
sudo make install
Sudo reboot

Now your VU meter is more sensitive! Tweak the values to your liking.

1 Like


Thanks for the tip re changing the source for the VDU meter, I’ve tried a few values and it definitely works, just need to try and find something pleasing!

Richard Moss

Another forum member figured that out. I just clipped and pasted into a text file for future reference.
I set my volume at my usual level and went for about 3/4 of the way up. That way I can go a little louder or lower and still get something view-able that’s not pegged fully in the red or completely blank. Before the tweak I got maybe 2 LED’s showing.