Introduction: Retro CD/Spotify/Alexa Player
What do you do with all of your old CDs that are just collecting dust? Well, turn them into an overly complex system to play music on Spotify of course.
I wanted to find a clever way to use my old CDs that were just collecting dust since I listen to all of my music via Spotify. I had some NFC stickers laying around just waiting to be used in a project, so I thought, why not slap them onto some CDs and see what we can make? And like that, a new project was born. All that was missing was an understanding of the Spotify API which did not take long to learn. I wired a NFC reader to an ESP32 microcontroller and wrote some code to call the Spotify APIs to play music on an Echo Dot. The final piece was a wooden case to hold it all. It turned out awesome and even gives off an unexpected retro vibe. Check out my videos below for all the details of how I made it.
Supplies
- ESP32 Microcontroller (Amazon Affiliate Link)
- NFC Reader - RFID-RC522 (Amazon Affiliate Link)
- NFC Tags/Stickers (Amazon Affiliate Link)
- Amazon Echo Dot
Step 1: Assemble the Electronics
There are just two pieces that make up the electronics for this project, the ESP32 Microcontroller and RFID-RC522 NFC reader. We use SPI interface of the RFID-RC522 to communicate with it.
There are seven connections we need to make to wire the NFC reader to the ESP32. See the wiring diagram above.
VCC supplies power for the module. It is connected to the 3.3V (pin 1) on the ESP32.
RST is an input for Reset and power-down. It is connected to GPIO 22 (pin 14) on the ESP32.
GND is the Ground Pin and needs to be connected to GND (pin 2) on the ESP32.
IRQ is an interrupt pin that can alert the microcontroller when RFID tag comes into its vicinity. I don't use this pin, therefore it is left unconnected.
MISO pin acts as Master-In-Slave-Out when SPI interface is enabled. It is connected to SPI_MISO (pin 10) on the ESP32
MOSI (Master Out Slave In) is SPI input to the RC522 module. It is connected to SPI_MOSI (pin 15) on the ESP32
SCK (Serial Clock)accepts clock pulses provided by the SPI bus Master. It is connected to SPI_CLK (pin 9) on the ESP32
SDA pin acts as Signal input when SPI interface is enabled. It is connected to GPIO 21 (pin 11) on the ESP32
Step 2: Create NFC Tags With Spotify Links
A key part of the design of this project is the data that is read from the NFC tag. Other projects like this tend to simply use the unique ID that comes prewritten on every NFC tag. This means that there is nothing they have to do to the tags, instead they create a lookup in their source code to map the NFC tag ID to the Spotify album ID. The upside of this approach is you never have to write any data to the NFC tag. The downside of this approach is you have to update your source code or lookup table each time you want to add a new NFC tag and album.
I took the approach that I wanted my source code to not need a lookup table, but instead it would get all the data it needs to play the Spotify album from the NFC tag. Therefore I store the Spotify shareable link to the NFC tag. When I want to add new NFC tags and albums I don't have to change my source code or worry about updating a lookup table, I simply write a Spotify link to a new NFC tag. This also has the benefit that I can use these tags with the NFC reader on my phone to open those albums in the Spotify App.
I created a YouTube video short that walks through these steps, so watch it as well.
Steps:
- Purchase some NFC Tags.
- I used Mifare Ultralight C 192 bytes. The Spotify links are only about 50 bytes, so you don't need much space on the NFC tags.
- Install NFC Tools app on your phone.
- You need an App on your phone that will write data to the NFC Tags. I used "NFC Tools" on my Android phone.
- Copy your Spotify link onto your clipboard
- Opening Spotify
- Select the album or playlist
- Open the menu for the selected item
- Select share,
- Select copy link
- Write Spotify link to tag
- Open NFC Tools on your phone.
- Select the write tab
- Select add a record
- Select URL.
- Select "https://"
- Paste the Spotify URL into edit box for example https://open.spotify.com/album/5IJm0boSQuEBLiYNZJKV2Y?si=89eC_RS7Ti6s-Evnr4kNeg.
- Delete the http:// at the beginning of the URL
- Delete the question mark and everything after it at the end of the URL (delete everything bolded in the example URL).
- Click Ok
- Click write.
- Place the NFC tag against the back of the phone
- You should see "Write complete!"
- The tag is done and has the URL on it.
- Repeat this for as many tags as you want to create.
Step 3: Programming
The source code for this project can be found in this GitHub Repo. I walk through the ESP32 source code in the video above and cover how to get access to the Spotify API in the second video.
To communicate with the NFC reader, I am using the MFRC522 Arduino library by miguelbalboa located here. It worked right out of the box for me after I wired the RFID-RC522 to the ESP32. When I instantiate the MFRC522 object, I pass 22 for the SS pin and 21 for the RST pin since these are the GPIO pins I used on the ESP32.
To communicate with Spotify API, I wrote my own class. You must create yourself an App in the Spotify API dashboard to generate a Client Id and Client Secret that you will use in the ESP32 source code. Watch the Spotify Web API video above for more details on these steps.
Step 4: Build a Case
And finally I made a case to house all of the electronics and provide nice aesthetics for this project.
I've become a big fan of using walnut in my projects since using it for my subscriber count display and on air sign. I used walnut for the sides and birds eye maple for the front. One of my design goals for the case was to make it look like the Echo Dot was a speaker mounted in a box. I also wanted the CD to sit on top in a way that nicely displayed the cover art. And finally I wanted the NFC reader to not be visible.
I started with a cardboard mock up of the box to figure out over all dimensions and placement of things. Then I took that information and fabricated the final box out of wood. I really love how the horizontal grain of the walnut turned out. I wasn't exactly trying for a retro look, but it turned out gorgeous.
Step 5: Share You Project
If you build one, I would love to see it, so share it with me on twitter @MakerAtPlay1 or Instagram @makeratplay