Mopidy Pummeluff - A music box for kids – confirm blog

Mopidy is

an extensible music server written in Python. It offers a number of completely different music sources, corresponding to Spotify, SoundCloud, Google Play Music, and extra. It’s an ideal open-source resolution and different for SONOS, working on a Raspberry Pi.

It’s almost good for teenagers, and the one factor lacking is a kids-compatible interface. That’s the place my new plugin Pummeluff is available in place.

The interface

If you keep in mind your childhood, you would possibly keep in mind this gem:

Sony Walkman by way of Wikimedia Commons

Then you may additionally keep in mind the nice outdated occasions, while you had been in search of a freakin’ pen, to rewind and screw the tape again into your cassette tapes. Apart from that, the walkman was fairly superior! One cause why it was so superior was its simplicity. The interface was nicely designed, straight-forward and simply easy. There was no swipe-to-unlock, passcode immediate, bluetooth connectivity points or alike. It was lifeless easy: Put a cassette tape into the magic field, press play and also you’re good to go.

I’m positive, this was one of many keys for the success of the Walkman. And that is precisely what I’m making an attempt to realize with the on-going undertaking. I’m making an attempt to use cutting-edge know-how, corresponding to a Raspberry Pi, Debian Linux and the Mopidy server and connecting it with simplicity.

Instead of controlling Mopidy by way of internet interface and all that fuzz, I used to be in search of a less complicated resolution. Something that even the little ones can management with out being a grasp thoughts in know-how (but). That’s the place I got here up with RFID. An RFID interface may be one thing so easy, straight-forward and delightful. It even helps the human nature of grabbing one thing and placing it on a particular spot.


Having thought concerning the so necessary interface, I already had an enormous a part of my idea. And right here’s the remainder of it, or not less than what I used to be making an attempt to realize:

  • A small-ish all-in-one music field
  • It should be transportable and power-efficient
  • It should play native songs from the SD card
  • It should additionally help NAS techniques and combine Spotify
  • It should help RFID tags and buttons as interface
  • It needs to be developed in Python
  • Last however not least, it should be KISS

Because my sister and a few buddies of mine lately obtained offspring, I assumed this entire music-box-thingy could be a terrific reward. So the price ticket of the entire bundle was essential, thus I used to be in search of an reasonably priced resolution.


It was time to get some {hardware}. Here’s what I’ve obtained:

  • A Raspberry Pi 3 Model B (~ CHF/USD 40)
  • A USB energy financial institution with passthrough charging (~ CHF/USD 15)
  • A pair of USB powered audio system (on AliExpress for ~ CHF/USD 3)
  • An RC522 RFID module (on AliExpress for ~ CHF/USD 1)
  • ISO 14443A tags (on AliExpress for ~ CHF/USD 0.4 per tag)
  • Two push buttons (on AliExpress for ~ CHF/USD 1)
  • Female jumper wires (on AliExpress for ~ CHF/USD 1)

As you’ll be able to see, the most costly elements are the Raspberry Pi and the facility financial institution. So you find yourself with a bundle value of roughly CHF/USD 60, with out the RFID tags. I’d name that reasonably priced, and you may even get it cheaper for those who’re in search of a used RPi and energy financial institution.

The RC522 RFID reader is sort of small and may work with Mifare & 14443A tags. There are additionally starter packages with included tags accessible:

Mopidy / Pummeluff helps a standing LED, which lights up when its prepared. That turns into useful, particularly after we shutdown or restart the RPi. I didn’t need to have a separate standing LED, thus I made a decision to make use of buttons with built-in LED’s. There are loads of them accessible and I used these 5V momentary push buttons:

I used to be going with the RPi 3B as a result of there was one mendacity round on the workplace. However, a 3B+ also needs to work nice, because the GPIO pins are the identical. Unfortunately, I don’t know concerning the RPi 1, 2 and Zero fashions, however you can provide it a attempt.

Connecting the {hardware}

Now it’s time to attach the {hardware}. I’m a bit lazy, so I gained’t describe right here the way you’ve to conenct the items. Just head over to the GitHub repo or PyPi repo and join the elements like described within the Connecting… chapters.

When every part is linked, proceed to the following chapter.


First of all, we have to setup Raspbian on the microSD card of the RPi. I’m not going to clarify how one can set up Raspbian in your RPi, as there are already loads of glorious tutorials on the market. There’s additionally an official Raspberry Pi Installation Guide.

Boot your Raspbian and configure it by working the configuration utility:

sudo raspi-config

Configure the next choices:

  • 2 Networking Options
    • N1 Hostname: Enter your required hostname
    • N2 Wi-fi: Enter your WLAN settings
  • 4 Localisation Options
    • Change the specified settings
  • 5 Interfacing Options
    • P4 SPI: Enable the SPI interface (necessary for the RFID module)
  • 7 Advanced Options
    • A3 Memory Split: Set the CPU reminiscence to eight MB

Now, your RPi needs to be linked to the WLAN. Get the IP handle by working:

ip a s wlan0

Let’s change the password of the pi consumer, allow SSH, improve the system after which reboot it:

# Change the password.

# Enable SSH after boot and begin it.
sudo systemctl allow ssh
sudo systemctl begin ssh

# Update system.
sudo apt replace
sudo apt dist-upgrade

# Finally, reboot it.

Your RPi is now up to date and may come again up. This means, we’re able to go to put in Mopidy.


The set up of Mopidy is sort of easy. Just execute the next instructions:

# Install Mopidy apt GPG key & repository.
wget -qO -  | apt-key add -
wget -qO /and so forth/apt/sources.listing.d/mopidy.listing 

# Update sources.
apt replace

# Install mopidy and pip.
apt set up mopidy python-pip

This needs to be sufficient to put in Mopidy. However, there are additionally some extensions you is perhaps inquisitive about.

HTTP server

Mopidy comes with an built-in internet server referred to as Mopidy-HTTP. By default, the online server is simply listening on the native interfaces, so that you need to add the next config to the Mopidy configuration:

# /and so forth/mopidy/mopidy.conf

hostname =

You ought to now have the ability to hook up with Mopidy by way of IP}:6680/.

MPD server

Now, the online server itself has no internet interfaces to regulate Mopidy. It’s only a easy internet server. However, there are a number of internet UI’s which may do precisely that. The most of them are based mostly on MPD (Music Player Daemon). Fortunately, Mopidy additionally comes with an MPD server referred to as, guess what, Mopidy-MPD. Unfortunately, it’s additionally listening solely on localhost, so add the next bits to the Mopidy configuration as nicely:

# /and so forth/mopidy/mopidy.conf

hostname =

So, as we now have a HTTP & MPD server listening on all RPi interfaces, we will add an MPD internet shopper to regulate Mopidy.


Iris (previously referred to as Spotmop) is a very nice MPD internet shopper, which is working straight on the built-in Mopidy HTTP server. You can set up Iris by way of pip:

pip set up mopidy-iris

That’s it! Iris, the superior MPD internet shopper is put in and is accessible by way of the Mopidy HTTP server.


If you need to take heed to Spotify songs, you additionally want to put in the Spotify extension. To set up it, we will use pip once more, however we have to set up some apt dependencies first:

apt set up libspotify12 libspotify-dev libffi-dev 
pip set up mopidy-spotify

If you’ll be able to’t discover / set up libspotify, ensure you’ve configured Mopidy’s personal apt repo.

After you’ve put in the Spotify extension, you want to configure it in keeping with the official github repo and/or the Mopidy web site. The closing configuration appears like this:

username = … your username …
password = … your secret …
client_id = … client_id worth you bought from …
client_secret = … client_secret worth you bought from …


Developing Pummeluff

I used to be fairly amazed by Mopidy and the present extensions. Most of the options I used to be in search of had been already accessible in fantastically crafted PyPi packages.

So the final lacking bit was the communication with my {hardware} interface, referred to as RFID reader & push buttons. This is the place I began creating Mopidy Pummeluff, as I couldn’t discover something usable on the web.

Here’s what Pummeluff does:

  • Adding a internet UI which lets you assign actions to RFID tags
  • Reading RFID tags and executing the assigned actions
  • Reacting to button pushes and executing the assigned actions

The following actions may be assigned to RFID tags:

  • Replacing the tracklist with a brand new URI (e.g. Spotify observe or playlist)
  • Setting the quantity to a brand new degree
  • Pause, resuming or stopping the playback
  • Shutting down the system

Because I needed the facility financial institution to final for a really very long time, I did two issues:

  • I’m utilizing interrupts, which implies we gained’t have limitless CPU cycles wasted simply to learn RFID tags or ready for button pushes. Less CPU cycles equals much less energy equals extra battery life.
  • I’ve added a energy button to shutdown the RPi into halt state and wake it up once more.

Installing Pummeluff

First of all, we have to give our Mopidy consumer a bit bit extra permissions, so it will probably entry the SPi interface and GPIO pins:

sudo usermod -a -G spi,gpio mopidy

Because I additionally need to shutdown the entire RPi with a push on a button, I needed to create a sudo rule for that:

sudo echo "mopidy ALL = NOPASSWD: /sbin/shutdown" > /and so forth/sudoers.d/mopidy

Now it’s time to put in the Pummeluff extension:

sudo pip set up spidev
sudo pip set up mopidy-pummeluff

Last however not least, restart Mopidy:

sudo systemctl restart mopidy

And we’re able to go. Point a browser to the Mopidy Web UI, which by default is reachable like so:


In the browser you must now have the ability to management Mopidy by way of the execellt Iris Web UI, and register new card by way of Pummeluff’s easy (and never very shiny) frontend.

Proof of Concept

To take a look at when every part is linked collectively, I used an outdated wine field. And right here’s how my PoC field appears like:

It doesn’t win a design award, and I may’ve given it a pleasant end. But hey, it’s solely a proof of idea and I’m minimalistic, so no bending over backwards right here.

In the meantime, I’m already testing (used) toys, that are giant sufficient to suit every part into it. The RPi and energy banks are in all probability the biggest elements, however the RFID reader and buttons are fairly small (and there are smaller counterparts accessible). The audio system aren’t very high-quality, however they ship an honest sound for that value (it was approx. 3 USD). Thanks to their low cost casing, I also can take them aside and save a number of house there as nicely.

Of course I’ll add new pictures as quickly as I discovered a correct dwelling for these electronics.


I didn’t thought the undertaking goes to be so straight-forward once I began it. However, through the use of a Raspberry Pi and the superior Mopidy music server, I already had a strong base. With some further {hardware} and a little bit of programming, I achieved a very nice outcome. The Spotify integration can be an enormous plus, as Spotify has not solely music, but additionally a number of fairytales for the little ones. Of course you may as well add music on to the SD card of the RPi or join your NAS share to it.

As I like open supply and the group behind it, I assumed I’ll cowl the entire thought on this weblog submit and publish my supply on GitHub.

I hope any individual else can use this undertaking for his or her youngsters, and I’m at all times comfortable to assist. Feel free to contact me any time.

Source link