Integrating Pi Zero-W with Scroll-pHAT, pHAT DAC and Mopidy-Spotify


Hi there,

I have built a project with Pi Zero-W, Scroll-pHAT, pHAT DAC, and Mopidy-Spotify.
I am interested in taking the currently playing tracks from Spotify and displaying this information (any any other cool information) on the Scroll-pHAT.

I believe, from Tweeting Sandy and Phil, this functionality may be built into the pivumeter library:

I’d like to understand how I can get this up and going.
How do I integrate Mopidy and the Scroll-pHAT with this library?

Thanks in advance!


The will only work with Shairport-Sync, since it uses Shairport’s metadata to extract the currently playing songs.

To get it working with Mopidy would require a similar, but different, example.

Looks like the key is in the Mopidy WebSocket API documented here:

Making a client connection to this API will result in any change on the Mopidy end being pushed as a notification to the client, so Python could connect to the WebSocket API.

You can sudo pip install websocket-client on your Mopdify Pi and then run the below example to see what data you get out of your Mopidy install:

import websocket

def on_message(ws, message):

def on_error(ws, error):

def on_close(ws):
    print("### closed ###")

def on_open(ws):

if __name__ == "__main__":

    ws = websocket.WebSocketApp("ws://",
            on_message = on_message,
            on_error = on_error,
            on_close = on_close)

    ws.on_open = on_open

It’s looking promising, though, although in my experience getting Python’s WebSocket to run alongside anything else is tricky.


I’ll give this a go this evening and let you know how I get on.

Just as an aside, from watching some of the Bilge Tank episodes you guys seem to push Volumio a lot.
From purely a Spotify (and maybe connecting a NAS) perspective - what would you recommend for handling the audio?


Here’s a working implementation for Mopidy:

You’ll need to change the Mopidy host to reflect the IP and port for your configuration (probably

This requires the development version of Pi VU Meter which is, roughly, documented here:

Volumio was something we were playing with at the time, but it was a little too rough and ready for our radio kit. We’re keeping an eye on it though!

Mopidy + Spotipy is a really nice setup if you use Spotify. Just need to get the VU meter up and running properly, since I’ve been testing this code over the network rather than directly on the Mopidy Pi!


Hi @gadgetoid after a bit of playing about I did a fresh build of Mopidy again, I didn’t get to try the Python code yet.

Can you point me in the right direction to change the hostname of my Pi, in Sandys example he has it set to pirateradio.local:6680/iris, whereas I’m using my IP_address:6680/iris.



If you type sudo raspi-config, then select option 2, Hostname, then you’ll be able to change your hostname to whatever you’d like. You’ll need to reboot with sudo reboot after doing that.


Hi Sandy,
I’ve done that but and when I echo $HOSTNAME I get the correct hostname.
However, when I browse hostname:6680/iris or hostname.localhost:6680/iris I get an error saying the site can’t be reached…

Edit: Just to clarify, I’ve set the hostname to a unique name (no conflicts with other devices), I’ve also set the unique name in the [http] hostname = hostname then tried to connect to hostname.local on both my phone and laptop.
Ican connect via the IP but not the hostname.


I tried to clone the pivumeter and ran into a few issues:

  • How do I clone the development branch?
  • Do I need to clone the full pimoroni/pivumeter source code?

I tried cloning the master pimoroni/pivumeter branch and building but I ran into a few issues:

  • I tried to build by running source this crashed :( Not sure if it finished.
  • I tried running phatdac this gave me the following error: -bash: command not found

I’m sure this is documented somewhere but I’ve hit a bit of a roadblock…

Thanks again for the support :)


The development branch is undocumented at the moment, since it’s still being worked on so I’ll try and walk you through.

To clone the dev branch, or any branch for that matter, of a GitHub repository directly you can do:

git clone -b devel --depth=1

The -b devel part tells git which branch you want, and the --depth=1 tells it not to to clone any history.

Then to build pivumeter you need to:

cd pivumeter

Next to install the Python library for the VU server you need to:

cd python_server/library
sudo python install