This documentation outlines the development process of a contactless music player that uses RFID cards to control song playback on a speaker. The project follows the engineering design process, progressing from initial concept to a fully functional prototype. The inspiration for my project came from my love for listening to music and a need for more ‘aesthetic’ room décor. I combined the concept of contactless smart technology with the nostalgia of a vinyl player. The project also combines sever weeks from PS70 this semester, including but not limited to, hand tools, 2D Design and laser cutting, microcontroller programming, 3D printing, and input/output devices such as sensors.
The project adhered to the following engineering design process:
The initial MVP aimed to create an RFID-controlled music player on a breadboard. The primary goal was to establish a system where each unique RFID tag corresponded to a specific song stored on the SD card.
Initially, we encountered difficulties with the DFPlayer Mini module. The audio would not play consistently and struggled to read MP3 files from the SD card. To overcome these issues, we transitioned to using the Serial MP3 Modules from DIYables. This module proved more reliable and included a built-in headphone jack, simplifying the audio output process. Below is the code for the inital iteration of the MVP using the DFPlayer MP3 Module.
#include "DFRobotDFPlayerMini.h"
//#include // No longer using it.
DFRobotDFPlayerMini myDFPlayer;
#define RXD2 5
#define TXD2 4
void setup()
{
Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
Serial.begin(115200);
delay(200); // My preference for print stability
if (!myDFPlayer.begin(Serial2)) {// Start communication with DFPlayer
// myDFPlayer.begin(Serial1, true, false); // Start communication with DFPlayer
Serial.println("ERROR");
}
Serial.println();
Serial.println(F("DFRobot DFPlayer Mini Demo"));
Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));
delay(1000); // Add this to allow player to fully initialise
myDFPlayer.volume(15); //Set volume value. From 0 to 30
Serial.println("setup ended"); // I like this reassurance
}
void loop()
{
// myDFPlayer.play(001); // Ensure that your files have been renamed to 001, 002, etc.
myDFPlayer.play(1);
delay(5000); // If you actually want to hear anything each time
}
/*
* This ESP32 code is created by esp32io.com
*
* This ESP32 code is released in the public domain
*
* For more detail (instruction and wiring diagram), visit https://esp32io.com/tutorials/esp32-rfid-mp3-player
*/
#include
#include
#include
// *make sure the RX on the YX5300 goes to the TX on the ESP32, and vice-versa
#define RX 16
#define TX 17
YX5300_ESP32 mp3; // the mp3 object
#define SS_PIN 5 // ESP32 pin GPIO5 connected to the SS of the RFID reader
#define RST_PIN 27 // ESP32 pin GPIO27 connected to the RST of the RFID reader
#define SONG_NUM 12 // 3 songs + 3 RFID cards, change it as your need
MFRC522 rfid(SS_PIN, RST_PIN);
byte RFID_UIDs[SONG_NUM][4] = {
{ 0xF9, 0xF5, 0x55, 0x14 }, // song 1
{ 0xB1, 0xDF, 0x27, 0x1D }, // song 2
{ 0x37, 0x23, 0x27, 0x7B }, // song 3
{ 0xb8, 0x92, 0x1c, 0x33 }, // song 4
{ 0x07, 0x4b, 0x3a, 0x7b }, // song 5
{ 0xb7, 0x90, 0x2a, 0x7b }, // song 6
{ 0xf7, 0x3c, 0x28, 0x7b }, // song 7
{ 0xf7, 0x08, 0x2a, 0x7b }, // song 8
{ 0xa1, 0x8a, 0xec, 0x1d }, // song 9
{ 0x27, 0xa6, 0x91, 0x75 }, // song 10
{ 0xdf, 0x80, 0x54, 0x9e }, // song 11
{ 0xd3, 0x70, 0x1e, 0x19 } // song 12
// ADD MORE IF NEEDED
};
void setup() {
Serial.begin(9600);
Serial2.begin(9600);
delay(500); // wait chip initialization is complete
mp3 = YX5300_ESP32(Serial2, RX, TX);
delay(200); // wait for 200ms
SPI.begin(); // init SPI bus
rfid.PCD_Init(); // init MFRC522
Serial.println("Tap RFID Tag on reader");
}
void loop() {
if (rfid.PICC_IsNewCardPresent()) { // new tag is available
if (rfid.PICC_ReadCardSerial()) { // NUID has been readed
Serial.print("Tag UID:");
for (int i = 0; i < rfid.uid.size; i++) {
Serial.print(rfid.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(rfid.uid.uidByte[i], HEX);
}
Serial.println();
for (int index = 0; index < SONG_NUM; index++) {
if (rfid.uid.uidByte[0] == RFID_UIDs[index][0] && rfid.uid.uidByte[1] == RFID_UIDs[index][1] && rfid.uid.uidByte[2] == RFID_UIDs[index][2] && rfid.uid.uidByte[3] == RFID_UIDs[index][3]) {
Serial.print("Playing song ");
Serial.println(index);
mp3.playTrack(index+1);
// mp3_command(CMD_PLAY_W_INDEX, index); // Play mp3
}
}
rfid.PICC_HaltA(); // halt PICC
rfid.PCD_StopCrypto1(); // stop encryption on PCD
}
}
}
The exterior design drew inspiration from vintage vinyl players, aiming to blend retro aesthetics with modern technology.
Throughout the project, several challenges were encountered:
The contactless music player project has numerous avenues for future enhancement and expansion. Key areas for improvement include integrating with popular streaming services like Spotify to broaden music access, miniaturizing the device for increased portability, and adding wireless capabilities such as Bluetooth and Wi-Fi for enhanced connectivity. The user experience could be elevated by incorporating a more sophisticated interface with displays and companion apps (e.g., phone integration), while expanding RFID functionality could open up creative interaction possibilities. These developments would transform the current prototype into a more advanced, user-friendly, and adaptable music player, catering to a wider audience and diverse use cases.
This project demonstrated the successful integration of RFID technology with audio playback, packaged in an aesthetically pleasing, vintage-inspired enclosure. The iterative design process and problem-solving approaches employed throughout the project provided valuable learning experiences in both electronic and mechanical design.