RFID Triggered Audio System
Introduction
In this tutorial, we’ll create an RFID-based audio player that plays specific audio tracks based on the RFID tag scanned. This device can be used for interactive experiences, such as in escape rooms or as a unique audio player. We’ll use an OLED screen for user feedback, displaying messages such as "Equipment Activated" or error notifications if the tag is unrecognized.
Download the code for this project from its GitHub Page.
Supplies
- Microcontroller: Arduino Nano (or any other Arduino board)
- OLED Display: Adafruit SSD1306 128x32
- RFID Reader: MFRC522
- DFPlayer Mini: An audio player module with an SD card
- SD Card: 32GB or less, preloaded with audio files
- 1kΩ Resistor
- Jumper Wires: For connections
- Breadboard (Optional): For easy wiring
Gather and Install Required Libraries
Before starting, ensure that the following libraries are installed in your Arduino IDE:
- Adafruit GFX Library
- Adafruit SSD1306 Library
- MFRC522 Library
- DFRobotDFPlayerMini Library
To install these:
- Open the Arduino IDE, go to Sketch > Include Library > Manage Libraries.
- Search for each library by name and click Install.
Prepare Your Audio Files
- Prepare your audio files for the DFPlayer Mini module.
- Naming Requirement: Name each audio file using the following format: 0001"name".mp3, 0002"name".mp3, etc.
- Transfer these audio files onto an SD card.
- Insert the SD card into the DFPlayer Mini.
Tip: Ensure the SD card is 32GB or less for compatibility.
Example files with the correct naming requirements can be found on this project's GitHub Page in the audio-files folder.
Insert the SD card into the DFPlayerMini.
Build the Circuit
Follow the wiring guide below to connect each component to the Arduino Nano:
Pin Connections
- OLED Display (128x32):
- GND → GND
- VCC → 5V
- SCL → A5 (SCK)
- SDA → A4
- RFID Reader (MFRC522):
- RST → Pin 9
- SDA → Pin 10
- DFPlayer Mini:
- RX → Pin 4
- TX → Pin 5 (place a 1kΩ resistor between TX and Pin 5)
- BUSY → Pin 6
Notes
- Confirm all components are securely connected.
- Adjust pin numbers in the code if you modify the setup.
For other boards (if not using an Arduino Nano)
If you are using a different microcontroller the most impacted change will be the wiring to the RFID module. Reference the RC522 GitHub for other pain layouts. Using the correct pin layout is necessary for the RFID module to work.
After using the correct layout for your case, use the pin out diagrams for the OLED Display, and DFPlayerMini to edit the code to match your case.
Prepare the RFID Tags
Each RFID tag has a unique UID (identifier) that allows us to assign it to a specific audio track. To configure your tags:
- Use the DumpInfo example code provided with the RFID library to find the UID of each tag.
- In the project code, locate the tagUIDs array and replace the 00 placeholders with the actual UID values of each tag.
Example: If your tag's UID is 4A B2 1F, enter it in the code exactly as shown.
For a full tutorial on how to use the DumpInfo program watch the video above.
The original code was made from 7 primary tags and 7 backup tags however, this can be changed and the back ups fields removed if it will not serve a purpose.
Upload the Code to Arduino
- Open the Arduino IDE and load the code for this project.
- Connect your Arduino board to your computer and select the appropriate Board and Port under Tools.
- Upload the code to the Arduino.
Testing and Operation
- Power On: Once powered, the OLED display will show messages like “Equipment Activated” and “Ready to Scan.”
- Scanning a Tag: When an authorized RFID tag is scanned, the corresponding audio track will play through the DFPlayer Mini.
- Error Handling: If an unrecognized tag is scanned, an error message will display on the OLED screen.
Troubleshooting
- No Sound: Check the SD card formatting and ensure files are named correctly.
- OLED Display Not Working: Double-check wiring, especially the SCL and SDA connections.
- RFID Tag Not Recognized: Ensure the UID is entered correctly in the code.
Optional Improvements and Ideas
- Multi-language Support: Add support for additional languages in the OLED messages.
- Track Cycling: Program multiple audio tracks per tag, cycling through with each scan.
- Amplifier: Connect to an amplifier for a louder sound output.
- 3D Printed Case: Model and design a 3D printed case to make a mobile device for escape rooms.