Music Cards: RFID cards + Spotify + Raspberry Pi

I first saw the Spotify Box project a couple of years a go, even before the Raspberry Pi was released to the market. Since then, I have been trying to replicate this idea of using physical objects to select the music that you want to listen.

After a couple of attempts, by the end of 2014, I was able to have a working version and it turned out to be very simple. Just a few lines of python code and usb connected hardware (not even soldering!). The idea is to use RFID cards that are associated to a Spotify URI to start playing a song, album, playlist, etc… in a Raspberry Pi.

So, here’s what you will need if you want to create your own version:

Hardware (~80 USD)

  • Raspberry Pi (any version, as long as you are able to connect it to the internet). Don’t forget the power supply!
  • An 125 kHz RFID card reader. This one is incredibly cheap and it works perfectly.
  • 125 kHz RFID cards. This is the best deal I have found.
  • (Optional) A sound card. The Raspberry Pi has audio output, but the quality is not very good. For less than 10 USD you can get a decent result, like this one. There are better options as well, like the hifiberry.
  • A speaker, receiver, headphones or whatever you want to use to listen to the music.

The connections are pretty obvious. Just connect the RFID reader to the USB port and the sound card too.


To handle the connection to Spotify, I use the image from Pi Musicbox. You can follow the instructions in their website to install the image to the Raspberry Pi. Remember to enable the SSH connection in the settings. Now, if you want to use another board (Beagle Board Black, for example), you can just install Mopidy, which is the base of Pi Musicbox. It creates a music player daemon (MPD) and a web server, so it also provides a web interface to control your music.

To read the cards and control the MPD, I wrote a script that can be found here. The dependencies are listed there. First run ‘python’ to configure the card reader. Then run the script called, where you can assign an Spotify URI to a card number using the reader. You can get the Spotify URI in the Spotify desktop app by right-clicking any song, album, playlist or radio station that you want. After adding some cards and playlists, run ‘python’ and you are all set. All the code is open source and you are more than welcome to contribute!

Last thing is that you may want to include the script to the startup. You can do so by following this tutorial for example.

If you have any questions, comments or improvements I am more than happy to hear them!