Making a Raspberry Pi-based RFID Music Player

Charles Vestal
8 min readFeb 16, 2022

I love music. And I love records. I had a nice collection of a few hundred of my favorite records, but when I moved across the globe, I sold them. Apple Music and Spotify offer great access to near unlimited albums, but that ease of access changes how you relate to them.

Without getting too hipster, physical albums force you to listen with intent, prioritize listening to an album over the single, and become, temporarily, a little work of art you can relate to. Vinyl snobs will tell you they sound better, but who cares: pretty pictures go sparkle.

So, I set out to try and recreate this experience in the most small-apartment who-knows-where-we’ll-live-in-5-years way. The idea: use a raspberry pi and RFID tags to create miniature representation of my favorite records and create a music player that lets me get a little closer to them.

Requirements:

  • Place a card, and an album plays
  • Remove it and it stops
  • You can see the album art
  • Doesn’t look like a raspberry pi

Parts:

Raspberry Pi: I used a 3 because I had it lying around, but this should work on a 3, 3B+ or a 4, or even a 2 or a zero, if you’re willing to add your own hardware. These are hard to come by now with everyone doing pandemic projects *cough*, but ask your friends. The nerds probably have an extra.

Micro SD Card: Big enough to store your software and some music. I used a 128GB.

Waveshare PN532 NFC Hat (€22,50) : There are a number of different ways to get RFID capabilities onto your Pi. One requirement I had was to detect when a card was removed, so I could easily “turn off” an album. There are a few that are what’s called “place capable” to enable this, but I found the PN532 had the best combination of ease of use and range to read through an enclosure.

Some sort of enclosure (€11,07): My requirements were to be compact, and display the album art. I looked for pre-made enclosures that might have an angled surface to hold and display an album. This one is, I think, for medical devices, or display prototyping. But it’s a nice size, a decent angle, and if put on its end, can show off some album art.

NFC Stickers (€20-ish, or €0,20 per): Any should do. Here are a couple I tried.

That’s the bare minimum. Here are some additional pieces I added:

Surface mount audio extension (€9,89): This let me have an audio jack in the back, instead of a headphone cable hanging out the side.

Surface mount micro-USB extension (€11,22): This let me have a micro-usb jack in the back, instead ofa micro-USB cable hanging out the side. If you’re using a Pi 4, you’d want a USB-C version.

Felt furniture pads (€13,64): The lip that holds the card up is made of some felt pad I had lying around. You might find something else, like adhesive rubber.

Rubber bumpers (€2,29): To keep from sliding around.

Adhesive weights (€7,00): These are silly, but make it feel less like it’s hollow plastic, and more like it’s something you might keep on a console. It also helps it from sliding around.

All told, it’s about a hundred euros of parts, not including the Raspberry Pi or SD card, and assuming you don’t have any of these pieces lying around. Now we can put it together:

Assembly:

First, write the raspberry pi software to your SD card. I use the Raspberry Pi Imager, specifically because it lets me do things like easily set up wifi, username, ssh, etc. before I ever even boot up.

For ease in identifying your Pi, I use a hostname “pibox”, but this can be whatever you like.

We want to install the “buster” version of raspiOS, rather than the latest, as it’s what’s compatible with the latest stable version of the jukebox software we’ll be using. Download that here 2020–12–02-raspios-buster-armhf-lite.zip.

Use the Imager, select a custom OS, the above zip file, configure your settings and write it to your SD card. Good to go!

Now, attach the PN532 HAT to your Pi. It should just slide on the GPIO pins. The end!

Inser the SD card into the Pi and place it in your enclosure where you want, and attach with a mounting screw, if possible. Otherwise uhhhh duct tape. If possible, get as close to the front as possible, to ensure good RFID signal

If you’re using surface mount cable extensions, now’s a good time to figure out their placement and drill their holes. The audio cable I used needed a 6mm drill bit, the micro-USB was 16mm. Drill, mount, and attach the cables.

I put the weights in at this point now that everything’s laid out. You’ll want to place weights toward the “bottom” to give it a low center of gravity.

Before we close everything up, boot up the pi. After a minute or two, try to connect. If your wifi was configured correctly, you should be able to ssh with the username and password you configured. On MacOS, for example, open the terminal and type “ssh pi@pibox.local”, put in the password you set when writing the image, and you’re logged into your Pi.

Install software

There’s a great opensource project called RPi-Jukebox-RFID, which we’ll be using. It’s intended to emulate the Toniebox, a german kids audio player that sells DRM-enabled NFC amiibo-likes with stories and songs. But, the software will also play yacht rock.

After logging into your pi, the first thing we want to do is update the system software:

sudo apt update
sudo apt upgrade

Now we’ll install the RPi-Jukebox-RFID software. They’ve helpfully provided a script that does all the heavy lifting.

cd; rm buster-install-*; wget https://raw.githubusercontent.com/MiczFlor/RPi-Jukebox-RFID/master/scripts/installscripts/buster-install-default.sh; chmod +x buster-install-default.sh; ./buster-install-default.sh

Run through the prompts. We don’t need to setup wifi or spotify, so we can say no to those. When it asks you for your rfid reader say it’s connected and choose PN532.

Say no to reboot, we’re going to do one more thing:

The LEDs on the Pi are BRIGHT, so I disable them so we don’t see them through the plastic. type

sudo nano /etc/rc.local

And add the following lines just before the last line of “exit 0”

sudo sh -c ‘echo none > /sys/class/leds/led0/trigger’
sudo sh -c ‘echo none > /sys/class/leds/led1/trigger’
sudo sh -c ‘echo 0 > /sys/class/leds/led0/brightness’
sudo sh -c ‘echo 0 > /sys/class/leds/led1/brightness’

now reboot with

sudo reboot

Configure the software

Now, if you open a web browser to http://pibox.local you should see the Pibox interface. Head to settings and change the following options:

  • Change “Swipe or place the card?” to “Placing the card starts player, removal stops it”
  • Set all the volumes to 85%
  • Scroll down to second swipe and change what happens to “Resume playback”

You’re not ready to start setting up some albums! RPi-Jukebox-RFID has helpfully enabled samba, but with a default password. Nevertheless, you can connect on a mac by hitting command-K in the finder and entering “smb://pibox.local”, the username will be “pi” and the password “raspberry”. Connect to the “phoniebox_audiofiles” share.

Copy some folders of music over. In my case, I chose about 130 of my favorite albums and put some FLACs on there to ensure hipster cred. But you can play MP3s and any number of other formats. You can even configure Spotify streams, but that’s outside the scope of this tutorial.

Once you have a couple of folders copied, try out an NFC sticker. Head to the “Card ID” tab, then place the sticker near the reader. If everything is hooked up you’ll see the “last used chip ID” field populate with some numbers. This is the ID of that sticker, and unique to it. You don’t need to remember it. But, under “Link card to existing audio folder” choose an album you want it to play, then click submit.

Now, remove the sticker and bring it back — if you have audio hooked up, you should hear it begin to play (if not, check the player tab). Remove it, and you’ll see it pause. Success!

Close up your enclosure, since you nowknow the hardware is working.

Now you can attach the bumpers and the lip to hold the cards up.

Make your cards

It was important to me that the album art was part of this experience. I printed out the albums I wanted to have on the device in a small form factor, 95x95mm, on 300g cardstock. I had them printed at an online print shop, around 20 euros for 25 pages in full color.

Depending on how your Pi is mounted in your enclosure, the RFID reader is likely not in the middle of the face. You’re going to want to find the spot where a sticker is read, and line up a card to see where it would fall on one when the card is in the middle of the device. For me, it was in the middle of the lower left quadrant of the back of a card. Do one test fit with a card to make sure it reads before assembling the rest. It’s not a bad idea to test each tag before attaching too, since sometimes you can get a dud.

Assuming it works, you’re good to create the rest of your cards, assign them to folders, and have fun. If you want to make more, just add a folder, print a new card, add a sticker and assign it in the same way. You can even assign other commands like “play a random folder” or going forward/back to cards.

Next steps

There’s lots of other stuff you could do to improve this:

  • Add a usb audio card for better sound quality
  • Enable bluetooth or airplay
  • Make it look like a minidisc player
  • Add physical buttons for controlling tracks or volume
  • You can use anything, not just cards! Add stickers to books, forks, pillows, whatever
  • Paint it something other than BEIGE

Have fun! Make it your own! Enjoy!

--

--