RFID Jukebox




Introduction: RFID Jukebox

About: I fix things that aren't broken

This is my entry in the "Audio" contest - if you are interested by this then please throw me a vote!

This post will attempt to create a "scroll friendly" version of the how-to video included at the top of this post.

The video goes into great detail about the control flow and which software I'm using. Take a look at that if you would like to learn more.

The flow is as follows:

Normal Operation - Reading Cards and Triggering Spotify to Play Songs:

1) RFID tag is read by a compatible card reader

2) Card reader spits out serial data for each card to an Arduino

3) Arduino "Serial prints" the data it receives to a raspberry pi

4) Pi receives card ID from Arduino. Pi looks up the card ID in a table to find the corresponding Spotify URI

5) Pi calls Spotify API to play selected URI

Setup Phase: Associating RFID Tag with a Spotify URI

1) through 3) from above

4) Pi expects a command line arg with the specific Spotify URI you wish to associate with the card

5) Pi creates a new entry (or overrides if card ID is already found in table) for the cardID,SpotifyURI pair

So you are not "programming" these tags. These tags have their own build-in microcontroller that modulates the field coming from the reader's coil to the tune of it's specific ID. All you are doing is creating a dictionary of key,value pairs for the pi to read from.

For example, let's say I have a card with ID "2_54_57_53_23_33_3". I don't initially know what the ID is, but when I read the output from the Arduino after scanning it, this is what comes out.

Let's say I want to make this card play Al Green's greatest hits album when it is scanned. To accomplish this, I would go to Spotify and copy the album's URI, getting "spotify:album:6W0V8B0fJItvOwC8v114rZ". Now, as seen in the video, I supply this URI to a python program to associate the card ID of "2_54_57_53_23_33_3" with the spotify URI of "spotify:album:6W0V8B0fJItvOwC8v114rZ" in a table. The "Key" is the card ID, and the "value" is the URI.

Now, when I deploy the main program, and my pi receives a card ID of "2_54_57_53_23_33_3", it will look it up in the table, gather the URI associated with it, and supply the URI as an argument to the Spotify API.


Dedicated computer (raspberry pi is best for this tutorial)

RFID card reader module to connect to the dedicated computer

RFID Cards compatible with your reader

Optional but recommended: A spare Arduino as a middle-man between the reader and the computer to save development time

Step 1: Code Overview

The attached screenshots show the basic code structure for interfacing with Serial on the Arduino and pi. The advantage of using the Arduino as a middle man is that I can plug it directly into the Pi's USB port as a serial input. This saved me a ton of headache since now I don't have to know how to setup the GPIO pins as serial input.

My particular card/reader combination gives me the unusual result that all cards begin with a 2 and end with a 3. This gave me a quick and dirty way of knowing when a transmission is starting or ending. Depending on the cards/reader you have, your code will have to change.

Step 2: Spotify Integration

Now for the hard part - interfacing with Spotify. I relied heavily on 3 resources here:

1) The Spotifyd project, which allows your device to appear as an extra speaker to your Spotify account.

2) The Diskplayer project, in which some random guy wrote his own go scripts for interfacing with the Spotify API

3) This beautiful man who goes over OAUTH with Spotify. Without him I would have wasted so many more hours.

First install Spotifyd and test it to make sure the pi shows up as a speaker to your account.

Then, once that works, I used Diskplayer to test the spotify API. It is here that it will ask you to supply a Spotify API token. If you're running a headless setup like me, you will be unable to open it in a browser on the pi. For this reason, you will need to follow the steps listed in the video above in step 3). This project would not have happened without the man in that video!

Step 3: Making It Look Nicer!

Once everything works, you will be left with a mess of wires that plays anything you want from Spotify. To clean it up, put everything in a case, and print some labels for your cards! I used Avery 22822 labels (which come with a blank Photoshop template for printing at home). I was able to pull images from google, and slap them in the photoshop template as needed. After a few hours of learning Photoshop, I printed and stuck the labels on my blank RFID tags.

I had a lot of fun with this Project and will use it in the future to entertain people at my apartment. I\Let me know if you end up making it yourself!

I'm entering this in the "Audio" contest -- if you enjoyed it feel free to vote for this. Thanks!

Audio Challenge 2020

Participated in the
Audio Challenge 2020

Be the First to Share


    • Colors of the Rainbow Contest

      Colors of the Rainbow Contest
    • Stone, Concrete, Cement Challenge

      Stone, Concrete, Cement Challenge
    • DIY Summer Camp Contest

      DIY Summer Camp Contest



    11 months ago

    So you are using an arduino to read one byte from the serial line and put it back on the serial line? If all you wanted was a USB-UART converter.. Just buy it. No coding, no errors, no limitation on baud rate, and 1/10 of the cost.


    Reply 11 months ago

    As I mentioned in the instructible, I already had all the components collecting dust so figured I’d use them since it allowed me to whip this up super fast. No wiring to GPIO pins of the pi needed - just a no brainer USB right into the pi.


    1 year ago

    Like it a lot. Been trying to do something similar but using volumio to play the albums from my NAS as i dont use spotify. Still struggling to be honest but maybe this will help me.


    1 year ago

    A often cheaper way to go with the cards is RFID stickers and a few packs of printable business cards, as a side bonus nearly every printer can feed them unlike PVC/Plastic cards


    Reply 1 year ago

    The author also prints on labels. He mentions he uses the Avery 22822 labels for this project. But your suggestion is a good one too; wish I'd come across it before I ordered 100 RFID cards for a similar project. ;)


    Reply 1 year ago

    another option would be OpenCV with the PI Camera, then have QR codes on business cards with Spotify/Pandora/Youtube URLs... (something like QR > Youtube-DL > VLC) but I haven't researched that enough to be 100% that it would work, nor its reliability. there are also HATs for the pi that do nfc/rfid natively, and if you used a bluetooth speaker the card reader box could be a lot smaller (likely use a PI Zero W Even)