RFID JukeBox Using Arduino Uno + DFPlayerMini
by afrancois0720 in Circuits > Arduino
5003 Views, 51 Favorites, 0 Comments
RFID JukeBox Using Arduino Uno + DFPlayerMini
Hi, I wanted to create this RFID Jukebox as a gift and I was inspired by ANANORDS, Talaexe, Jordi Parra. Honestly, this project is pretty cool and using an RFID puts a twist to how you can interact with a streaming device/speaker. In this step by step guide, I will go over a breakdown for parts and materials, some tips, wiring diagrams and testing.
Hope you enjoy as this is my first tutorial. Please feel free to comment on where I could improve (coding, setup, etc)
Supplies
Here is the list of components (QTY and Cost breakdown is in the BOM in the hyperlink below):
Parts:
- Push Momentary Buttons
- 2 inch 5W 8Ohm Speaker
- 12mm Vertical Slide Switch
- 22 Gauge - Colored Jumper Wires
- 12mm Mini Latching push button
- 3W+3W Amplifier W/ Potentiometer
- RFID Smart Cards 13.56MHz
- 3.5mm stereo jack
- DFPlayer mini
- 32GB Micro SD Card
- Arduino Uno REV3
- Protoboard (for prototype/final)
- Bread Board (for testing)
- Tactical Push Button (for testing)
Tools:
- 3D Printer
- Its not necessary but if you don't have one, a simple enclosure box shouldn't be too expensive
- I also thought about reusing a shoebox or even making an enclosure from card board
- Soldering Kit
- Wire stripper
- Printer
- Glue sticks
Software:
- Arduino.ino
- 3D Printing Software:
- (Option) Fusion360
- (Option) Creo
- Canva: Graphic design platform that is used to create social media graphics and presentations. The app includes readymade templates for users to use, and the platform is free and offers paid subscriptions such as Canva Pro
- Bulk File Renamer:
- used to rename the audio files
- HitPaw
- Pros
- Downloads & Converts Spotify Playlist to MP3 Files
- No need to search individual songs on YouTube to then use a different site to convert it to mp3 files
- Cons:
- May get flagged by Spotify
- Make sure the version is up to date otherwise, it wont download the playlist/song link
- It does have a $20 Monthly Subscription but i just bought it and canceled it so i would only have to use it that one time
- YouTube to MP3 Converter:
- Pros:
- Downloads YouTube links to MP3 files
- Added an update that you can add to your bookmark so you can click it while your on an active YouTube Tab that automatically downloads the page
- Cons:
- Tedious to go back and forth between
- Pop up Browser ads
I also created a BOM with a Cost Break down with an estimated tax (defers state to state but i did an estimate of all my invoices) .
Tips:
- Amazon is a quick place to get parts but it does get pricey with amazon because they sell the components in packs of 2 or more when realistically you only need 1 item. plus its free 3 day shipping
- AliExpress is cheap but i did not want to wait weeks to get my part but if your looking for cost efficiency it would be good
- DigiKey, Adafruit and similar sites are good because its a reliable supplier but the only reason why I didn't buy it from them was because of the shipping cost so be wary.
Sources:
- https://wiki.dfrobot.com/DFPlayer_Mini_SKU_DFR0299
- https://techcrunch.com/2011/02/13/spanish-design-student-creates-sleek-new-spotify-gadget/
Check Out the Demo
I hope you enjoy the demo!
Schematic & Bread Board Testing
Schematic:
- The schematic is attached above, if your not familiar with how to read a schematic its pretty simple, just follow the trace or google for tips
- There are 4 Push buttons (Previous, Pause/Play, Next, Shuffle) that act as the controls
- I added an Audio Amplifiers with an 5V input that delivers 3W to 2 output for 2 speakers.
- There's a Latch Button that connects to the VCC of the amplifier to turn on/off the speakers when headphones is connected to the 3.5mm audio jack
- Slide Switch (optional) - I added this slide switch to turn on/off AutoPlay for the audio files.
- If you don't want the switch but want the songs to AutoPlay by itself, you can implement it in the loop in the Arduino code.
Testing: Be sure to test on a breadboard before soldering on a protoboard
- Tactical Push Button:
- At first, its best to test with tactical pushbutton, to make sure that the code works so be sure to change the code where your reading from LOW to HIGH (or vice versa) because of the way the Arduino Digital port reads the push button vs tactical pushbutton
- Tactical reads from +3.3V or 5V
- Push button reads from GND
- MFRC522:
- Use the "DUMP Info" library on the Arduino to check if all the RFID Smart Cards work
- Tips: Some cards may work when your programing others may not, its better to order these cards in Bulk and then return the ones that doesn't work
- DFPlayerMini:
- Remember to use a 1K resistor between RX on the DFPlayerMini and the Arduino.
- Tips: By 2-5 DFPlayerMini because incase something is wrong and your not sure if its the DFPlayerMini, Arduino, or the code. I ran into some issues where i had to swap them out to trouble shoot
Programming & Testing
The code is separated into two parts, Program.ino and Player.ino, which are attached below. The Program.ino will be use to program the individual RFID cards. Once completed, the Player.ino card will be run on the Arduino to run the Jukebox. For this you will need to add two libraries. If you have not already added the libraries into your Arduino.ino you can add them below.
- DFPlayerMini
- MFRC522 - you can use the GitHub link but if that doesn't work you can extract it from the Arduino software
If you need additional help to add these libraries, check out this article: Installing Libraries. After its been added, you can begin programming the Arduino.
NOTE: The DFPlayerMini requires the folder name to be "mp3", placed under the SD card root directory, and the mp3 file name needs to be 4 digits, for example, "0001.mp3", placed under the mp3 folder. If you want to name it in Both English and Chinese, you can add it after the number, for example, "0001hello.mp3" or "0001后来.mp3".
Essentially, the DFPlayerMini reads the MP3 files as a 4 digit number, I've played around with the file names and noticed that as long as the first 4 characters of the file name is binary than it should be fine. I found it easier to use the following format ( "0001 - song name" ), that way for songs that start with a number don't get mixed up.
For more details, check the out DFRobot for more info.
Programming Modes:
There are two programming modes when it comes to programming the RFID cards, "auto" and "manual". Where the program writes a number to a specific block in the RFID. You can check the blocks by using the DUMP Info library. Use this especially if your trouble shooting.
- Auto Mode: The Arduino programs the RFID cards in a consecutive order by increasing by 1 so you can just keep tapping a new card after the previous has been assigned
- Manual mode: Write number you specify in the block of the RFID.
How to use modes:
Auto mode:
- After running the Program.ino code, open the Arduino serial monitor
- On the top right corner, type "auto" and either click send or press enter
- Tap the a card and wait for the "success" message
- Be sure to not leave the card too long on the reader or else the program will write over the previous block
Manual Mode:
- After running the Program.ino code, open the Arduino serial monitor
- On the top right corner, type "manual" and either click send or press enter
- Wait for the the "Type any number and hit send/enter" message
- On the top right corner, enter the number you want to assign the card, then press enter
- Tap the a card and wait for the "success" message
Findings: I mainly used auto mode because there where some complications with manual however, you can change the starting number at the beginning of the code to go to a specific number to reprogram a card.
(Optional) Auto Play Feature
You can implement an auto play feature in the code that plays the next song on the SD card directory after 3 seconds when the song is finished. You can change the amount of time to be more or less but that is up to you. Although the DFPlayer has an AutoPay function, you have that is primarily up to you as to how you would like to implement it
static unsigned long timer = millis();
if (millis() - timer > 3000) {
timer = millis();
myDFPlayer.next(); //Play next mp3 every 3 second.
}
- This code goes in the loop section
- (Optional) Implementing Folder Playlist Code
Findings: You can think the main "mp3" folder as the folder that houses all of the songs, but there is a little bit of a loop hole to have different folders that act as different playlist.
- Lets say you want 2 additional playlist that gets called out by the RFID cards.
- In the Program.ino , You can even change the starting number to a negative number like (-4,-3,-2, etc.) to reference a card as a playlist. So then you can have negative numbers as playlist and positive numbers as individual songs.
- Then you can setup an if statement so when the a negative card is present, you can call out a playlist
int currentNumber = -2; //NUMBER TO START FROM
- You can use the following code for the Player.ino to call out a folder when a specific card is present with the RFID reader.
if (number.toInt() ==-2) //when a negative playlist card is present
{
myDFPlayer.playLargeFolder(2,1); // Plays a specific folder
Serial.print(F("\nVolume: "));
Serial.print(myDFPlayer.readVolume()); //read current volume
//Serial.println(myDFPlayer.readCurrentFileNumber()); //read current play file number
isPlaying = true;
}
else
{
myDFPlayer.play(number.toInt());
Serial.print(F("\nVolume: "));
Serial.print(myDFPlayer.readVolume()); //read current volume
isPlaying = true;
}
Download Song Files
This part is pretty straight forward where I used Spotify to create various playlist so i could have different categories like R&B, Hip Hop, Lofi Beats, etc. The following step uses the HitPaw which is a software that converts Spotify links (playlist or individual song) and converts them to MP3 Files. Lastly, we will also use the Bulk File ReNamer software that will rename the files to the following format that the DFPlayer can read
Use the Image steps above for guidance.
Step 1: Create Playlist on Spotify:
- Use Spotify to search and create your playlist.
- Be sure to keep in mind of the storage of the SD card you are using because spaces gets filled quickly
- After your playlist is complete copy the playlist link to paste into the HitPaw Software
Step 2: Using HitPaw:
- Open the HitPaw Software and go to the Toolbox Tab
- Click the Spotify Music Converter
- Paste or Drag Spotify Track Link
- Choose Output Format
- Convert Spotify Music to MP3
Findings: VERIFY THAT THE SOFTWARE IS UP TO DATE!! I had an issue where the copied link showed up but the MP3 conversion process failed. The software can sometimes be a little bit slow so be sure to keep your computer on or change the sleep settings to keep it on. I had about 200 files per playlist trying to convert so it took a little bit of time but it was a lot faster than looking up the songs individually on YouTube and converting them.
Step 3: File Renamer:
- Use Image steps 3-5 above for additional help
- Open the Renamer software, and add your desired folder
- Click "+ Add" to add the following rule from Image Steps 3 to Serialize your files
- The index can either start with 1 or 0 but keep in mind this correlates with the "current number" from the Program.ino
- Check off "Pad with zeros to length:" with drop down "4"
- This indicates that you want the file name to start with 4 digits "0000"
- Click "+ Save Rule"
- Click "+ Add" to add the following rule from Image Steps 4
- In the "Insert" section, type " - ".
- Check off "position" with drop down "5"
- Click "+ Save Rule"
This will put a space between the previous rule of serialization with the file name.
- Example: "0000 - filename", "0001 - filename"
After you are done setting the rules, click Preview on the top ribbon to get a preview of your new filenames. Reference Image Step 5 for guidance.
Step 4: Save Files to SD
Now that the files are renamed, you can then move your files to the SD card.
- If you decided to create different playlist. You have to separate your playlist folder with a numeric number from the mp3 folder. So your file directory should look like this
- mp3
- 01
- 02
- 03
- Be sure that the code on the Player.ino is set up with "IF" statement as shown on the "Optional Implementing Folder Playlist Code"
Once complete, the SD card is ready to be put on the DFPlayerMini
Protoboard Testing
Now that the hard part is out the way, if your like me and this is your first time soldering on a protoboard, welcome to the other semi-hard part. Just kidding but it was a great learning opportunity to practice some soldering skills. If you don't already have one, I found it really helpful to have a desoldering pump whenever I made a mistake with the traces.
Use the schematic to really follow your traces and be sure not have certain traces touch so you don't short your boards and waste your money!!!! ( I'm glad this did not happen to me).
Trace Layout
To draw out my traces, I got creative and used google slides as showed in the figure image above. This really helped me get a better idea as to how things were going to look like.
Unlike a schematic, I found out it really helpful to draw out how I was going to put my traces on the protoboard. I tried to look for a software to do it but I couldn't find the right one but if anyone find ones be sure to add it in the comments.
Since everything will be wired up on the protoboard keep in mind of the parts that will be surface mounted on the enclosure like the push buttons, slide switch, and the amplifier volume knob
Because of that you will need to test that everything works first and for things like the pushbutton, you will most likely need to cut, mount, and resolder the wires back together.
If you used tactical pushbuttons for testing on the breadboard, don't forget to change your code from high to low (vice versa) when going back to regular push button on the protoboard
3D Printed Enclosure
I designed this enclosure on google slides and then had a friend of mine design on CREO 3d printing software but you can also use Fusion 360 as well. I attached the step files so feel free to print or modify
We found it helpful to do two prints where the first print to to verify that whether the mounting holes fit the parts. And the second print is the final enclosure. Some things still didn't fit so i used a soldering iron to melt the plastic.
Once printed, mount the the protoboard and and the surface mounted parts. where you would need to cut and resolder the push buttons
Designing the Cards
This was probably the easiest and fun part of the project where you could really just be creative with any downtime. For creating the card covers, I used the Canva, which is an easy to use graphic design platform that is used to create social media graphics and presentations. I was able to get a free Canva pro version from previous years through GitHub.
To learn how to get Canva Pro check out this link.
Using Canva pro version is honestly the best tool to use for this project because you can customize the template size to your desired dimension. So with that, I changed the dimension and then created a word document and pasted the finished template. The templates are in a large table array so its easier to cut out and glue onto the RFID Cards.
The gluing is a bit tedious but with the music files you just download, time sure will fly by.
Since this doesn't support word docs, i also attached the pdf version for better clarity of the print.
With that said your done!
Downloads
Follow and Support
Thank you for making it through this! Please comment and feel free to give me tips on things to improve for the next time. Be sure to follow this page as I will be posting new project moving ahead.