Introduction
The YX5300 Serial MP3 Player module is a versatile MP3/WAV/WMA player designed for embedded applications. It allows you to easily integrate audio playback into your projects, controlled via a simple serial UART interface.
The module features a high-quality audio decoder chip, a TF card (Micro SD) slot for storing audio files, and a 3.5mm stereo audio jack for connecting headphones, powered speakers, or an external amplifier. It is controlled via a UART serial interface at 9600 baud, making it compatible with a wide range of microcontrollers including Arduino, AVR, ARM, and PIC. This guide covers features, specifications, connections, the serial command protocol, example code, and troubleshooting.
⭐ Key Features
- Versatile Audio Format Support: Plays MP3, WAV, and WMA audio files.
- Wide Sampling Frequency Range: Supports 8kHz to 48kHz sampling frequencies.
- Micro SD/SDHC Card Compatibility: Accepts Micro SD and Micro SDHC cards up to 32GB (FAT16/FAT32).
- UART TTL Serial Control: Control playback via a simple 9600 baud serial interface.
- 3.5mm Stereo Audio Jack: Connect headphones, powered speakers, or an external amplifier.
- 30-Step Adjustable Volume: Fine-grained volume control via serial commands.
- 6 Equalizer Presets: Normal, Pop, Rock, Jazz, Classic, and Bass.
- Multiple Playback Modes: Repeat All, Repeat Folder, Single Repeat, and Random.
- Folder Support: Organize files into folders on the Micro SD card and navigate between them via serial commands.
- Compact Size: Just 1.7 × 1 × 0.2 inches (43 × 25 × 5 mm) for easy integration.
📋 Specifications
| Feature | Specification |
|---|---|
| Supported File Formats | MP3, WAV, WMA |
| Supported Sampling Frequencies | 8 / 11.025 / 12 / 16 / 22.05 / 24 / 32 / 44.1 / 48 kHz |
| Micro SD Card Support | Micro SD and Micro SDHC up to 32GB (FAT16/FAT32) |
| Volume Control | 30-step adjustable volume |
| Equalizer Presets | Normal, Pop, Rock, Jazz, Classic, Bass |
| Playback Modes | Repeat All, Repeat Folder, Single Repeat, Random |
| Audio Output | 3.5mm stereo audio jack (line-level output) |
| Serial Communication | UART TTL, 9600 baud rate |
| Power Supply | 3.2V ~ 5.2V DC |
| Dimensions | 1.7 x 1 x 0.2 inches (43 x 25 x 5 mm) |
📌 Pinout and Connections
The YX5300 module (Catalex variant) has 4 header pins and a 3.5mm audio jack:
| Pin | Function |
|---|---|
| VCC | Power supply input (3.2V – 5.2V DC) |
| GND | Ground |
| TX | UART Transmit — connect to the RX pin of your microcontroller |
| RX | UART Receive — connect to the TX pin of your microcontroller |
Audio Output: The module outputs audio through the onboard 3.5mm stereo audio jack. Connect headphones, powered/amplified speakers, or an external amplifier to this jack. This module does not have exposed speaker pins or a built-in power amplifier — it provides a line-level audio signal only.
Important Notes:
- Ensure the power supply voltage is within the specified range (3.2V – 5.2V). Exceeding this range may damage the module.
- Connect the TX pin of the module to the RX pin of your microcontroller and vice-versa.
- The 3.5mm jack outputs a line-level audio signal. To drive passive (unpowered) speakers, you will need an external amplifier module such as the PAM8403 or LM386.
🔧 What You'll Need
- Micro SD card (up to 32GB) — formatted FAT16 or FAT32 with your MP3, WAV, or WMA audio files.
- Headphones or powered speakers — connected via the 3.5mm audio jack. For passive speakers, you'll also need an external amplifier module.
- Jumper wires — for connecting the module to your microcontroller.
- Microcontroller — Arduino, AVR, ARM, PIC, ESP32, or any board with a UART serial port.
- 3.5mm audio cable — male-to-male if connecting to an external amplifier or powered speaker with a 3.5mm input.
🚀 Getting Started
Preparing the Micro SD Card
- Format the Micro SD card: Format the Micro SD card using the FAT16 or FAT32 file system. NTFS and exFAT are not supported.
- Copy Audio Files: Copy your MP3, WAV, or WMA audio files to the Micro SD card. The module will play files in the order they were copied to the card. It is recommended to number your files sequentially (e.g., 001.mp3, 002.mp3, 003.mp3). You can also organize files into folders for folder-based playback.
- Insert the Micro SD Card: Carefully insert the Micro SD card into the TF card socket on the module.
Folder Structure (Optional)
For more advanced control, you can organize files into numbered folders:
/01/001.mp3
/01/002.mp3
/02/001.mp3
/02/002.mp3
/03/001.mp3
Use commands 0x11 (Play Next Folder) and 0x12 (Play Previous Folder) to navigate between folders.
Connecting the YX5300 to a Microcontroller (Example: Arduino)
Wiring
| YX5300 Pin | Arduino UNO Pin |
|---|---|
| VCC | 5V |
| GND | GND |
| TX | Digital Pin 10 (SoftwareSerial RX) |
| RX | Digital Pin 11 (SoftwareSerial TX) |
Connect headphones or powered speakers to the 3.5mm audio jack on the module.
Arduino Example Code
// Arduino Example Code for YX5300 MP3 Player Module #include <SoftwareSerial.h> // Define the RX and TX pins for the software serial port #define MP3_RX 10 #define MP3_TX 11 // Create a software serial object SoftwareSerial mp3Serial(MP3_RX, MP3_TX); // RX, TX void setup() { Serial.begin(9600); // Initialize hardware serial for debugging mp3Serial.begin(9600); // Initialize software serial for MP3 module delay(1000); // Wait for the module to initialize // Example commands (sent as byte arrays) playFirst(); delay(1000); setVolume(20); // Set volume to 20 (0-30) delay(1000); } void loop() { // Your other code here } // Function to send commands to the MP3 player void sendCommand(byte command[], int length) { for (int i = 0; i < length; i++) { mp3Serial.write(command[i]); } delay(20); // Small delay after each command } // Example command functions void playFirst() { byte command[] = {0x7E, 0xFF, 0x06, 0x01, 0x00, 0x00, 0x00, 0xEF}; // Play first song sendCommand(command, sizeof(command)); } void nextSong() { byte command[] = {0x7E, 0xFF, 0x06, 0x01, 0x00, 0x00, 0x02, 0xEF}; // Play next song sendCommand(command, sizeof(command)); } void previousSong() { byte command[] = {0x7E, 0xFF, 0x06, 0x01, 0x00, 0x00, 0x01, 0xEF}; // Play previous song sendCommand(command, sizeof(command)); } void setVolume(int volume) { if (volume >= 0 && volume <= 30) { byte command[] = {0x7E, 0xFF, 0x06, 0x06, 0x00, 0x00, (byte)volume, 0xEF}; // Set volume sendCommand(command, sizeof(command)); } else { Serial.println("Invalid volume level. Must be between 0 and 30."); } } void play() { byte command[] = {0x7E, 0xFF, 0x06, 0x0D, 0x00, 0x00, 0x01, 0xEF}; // Play sendCommand(command, sizeof(command)); } void pause() { byte command[] = {0x7E, 0xFF, 0x06, 0x0E, 0x00, 0x00, 0x01, 0xEF}; // Pause sendCommand(command, sizeof(command)); }
Explanation:
- Include SoftwareSerial Library: This allows you to create a serial port on any digital pins. If you are using a microcontroller with multiple hardware serial ports (like some Arduinos), you can use a hardware serial port instead.
- Define Pins: Define the Arduino pins to be used for RX and TX. These can be any digital pins.
-
Create SoftwareSerial Object: Create an instance of the
SoftwareSerialclass, specifying the RX and TX pins. - Initialize Serial Ports: Initialize both the hardware serial port (for debugging) and the software serial port (for the MP3 module) at 9600 baud.
-
sendCommand()Function: This function sends a byte array to the MP3 module. It iterates through the array and writes each byte to the serial port. A small delay is added after sending the command. - Example Command Functions: These functions create the byte arrays for specific commands (e.g., play first song, next song, set volume).
⚙️ YX5300 Command Set
The YX5300 module is controlled using a series of commands sent via the UART serial interface. Each command is a byte array with the following structure:
{0x7E, 0xFF, 0x06, Command Code, 0x00, 0x00, Data, 0xEF}
- 0x7E: Start byte.
- 0xFF: Version information (fixed value).
- 0x06: Number of bytes following (excluding start and end bytes).
- Command Code: Specifies the action to be performed. See the table below.
- 0x00, 0x00: Reserved bytes (set to 0x00).
- Data: Data associated with the command (e.g., volume level, track number).
- 0xEF: End byte.
Example Checksum Calculation
Let's say we want to send the "Play Next" command (0x01). The command sequence would be:
- Start Byte:
0x7E - Version Byte:
0xFF - Data Length:
0x06 - Command Code:
0x01 - Feedback:
0x00 - Data 1:
0x00 - Data 2:
0x00
Sum of bytes 2 through 7: 0xFF + 0x06 + 0x01 + 0x00 + 0x00 + 0x00 = 0x106
Checksum = 0x100 – (0x106 % 0x100) = 0x100 – 0x06 = 0xFA
Therefore, the complete command sequence would be: 0x7E 0xFF 0x06 0x01 0x00 0x00 0x00 0xFA
Common Commands
| Command Code (Hex) | Description | Data (Hex) | Example Command (Hex) |
|---|---|---|---|
| 0x01 | Play Next Song | 0x00 (No data required) | 7E FF 06 01 00 00 00 EF |
| 0x02 | Play Previous Song | 0x00 (No data required) | 7E FF 06 02 00 00 00 EF |
| 0x03 | Play Specified Track Number (SD Card) | Track Number (High Byte, Low Byte). For example, to play track 10 (0x000A), send 0x00, 0x0A. Note: This command is unreliable. It is better to play first and then play next. |
7E FF 06 03 00 00 0A EF (Play track 10) |
| 0x06 | Set Volume | Volume Level (0x00 – 0x1E, corresponding to volume levels 0-30). |
7E FF 06 06 00 00 1E EF (Set volume to 30) |
| 0x07 | Set Equalizer | Equalizer Mode: 0x00 = Normal, 0x01 = Pop, 0x02 = Rock, 0x03 = Jazz, 0x04 = Classic, 0x05 = Bass |
7E FF 06 07 00 00 01 EF (Set equalizer to Pop) |
| 0x08 | Set Play Mode | Play Mode: 0x00 = Repeat All, 0x01 = Repeat Folder, 0x02 = Single Repeat, 0x03 = Random |
7E FF 06 08 00 00 00 EF (Set play mode to Repeat All) |
| 0x09 | Set Output Device | Output Device: 0x01 = Speaker, 0x02 = Headphones |
7E FF 06 09 00 00 01 EF (Set output to Speaker) |
| 0x0D | Play | 0x01 (Start Playing) |
7E FF 06 0D 00 00 01 EF (Start Playing) |
| 0x0E | Pause | 0x01 (Pause Playing) |
7E FF 06 0E 00 00 01 EF (Pause Playing) |
| 0x0F | Stop | 0x01 (Stop Playing) |
7E FF 06 0F 00 00 01 EF (Stop Playing) |
| 0x11 | Play Next Folder | 0x00 (No data required) | 7E FF 06 11 00 00 00 EF |
| 0x12 | Play Previous Folder | 0x00 (No data required) | 7E FF 06 12 00 00 00 EF |
| 0x16 | Play First Song | 0x00 (No data required) | 7E FF 06 16 00 00 00 EF |
| 0x17 | Loop Playback | 0x00 (No data required) | 7E FF 06 17 00 00 00 EF |
| 0x42 | Volume Increment | 0x00 (No data required) | 7E FF 06 42 00 00 00 EF |
| 0x43 | Volume Decrement | 0x00 (No data required) | 7E FF 06 43 00 00 00 EF |
🛠️ Troubleshooting
-
No Audio Output:
- Verify that headphones or powered speakers are properly connected to the 3.5mm audio jack.
- Check the volume level. Send the set volume command (0x06) with a value of at least 15 (0x0F) to test.
- Ensure the power supply voltage is within the specified range (3.2V – 5.2V).
- Verify the audio files are in a supported format (MP3, WAV, or WMA) and the sampling frequency is within the supported range.
- Make sure the Micro SD card is properly inserted and formatted correctly (FAT16 or FAT32). NTFS and exFAT are not supported.
- Try a different Micro SD card — some cards are not compatible with the module.
- Note: This module does not have a built-in speaker amplifier. Passive (unpowered) speakers will not produce audible sound. Use headphones, powered speakers, or add an external amplifier module (e.g., PAM8403 or LM386).
-
Module Not Responding to Commands:
- Double-check the serial connections (TX to RX, RX to TX, GND to GND).
- Verify the baud rate is set to 9600 in your microcontroller code.
- Ensure the command structure is correct (start byte, version, length, command code, data, end byte).
- Add a small delay (e.g., 20ms) after sending each command.
- Allow at least 1 second after power-on before sending the first command for the module to initialize.
-
Audio Quality Issues:
- Ensure the audio files are of good quality and encoded at a supported sampling rate.
- Experiment with different equalizer settings using command 0x07.
- Try re-encoding your audio files as MP3 at 44.1kHz, 128-192kbps CBR for best compatibility.
-
Micro SD Card Not Detected:
- Ensure the card is 32GB or smaller.
- Reformat the card as FAT32 using your computer's disk utility.
- Try a different brand or speed class of Micro SD card.
- Check that the card is fully seated in the TF card slot.
-
Tracks Play in Wrong Order:
- The module plays files in the order they were written to the card, not alphabetically.
- Format the card fresh, then copy files one at a time in the desired order using 3-digit numeric prefixes (001.mp3, 002.mp3, etc.).
- Avoid deleting and re-adding files — this can scramble the play order.
💡 Project Ideas & Advanced Usage
- Folder Playback: Organize your audio files into folders on the Micro SD card. Use commands 0x11 (Play Next Folder) and 0x12 (Play Previous Folder) to navigate between folders.
- Adding an External Amplifier: Since this module outputs line-level audio via the 3.5mm jack, you can connect an external amplifier module (such as the PAM8403 or LM386) to drive passive speakers. This is ideal for projects that need louder audio output.
-
Custom Applications: Integrate the YX5300 module into various projects, such as:
- Interactive audio installations and museum exhibits.
- Voice prompts and announcements for embedded systems.
- DIY music players and jukebox builds.
- Educational toys with sound effects.
- Doorbell and chime systems with custom sounds.
- Halloween props triggered by motion sensors.
- Alarm and alert systems with voice notifications.
- Game sound effects for DIY arcade projects.
🛒 Where to Buy the YX5300 UART TTL Serial Control MP3 Music Player Module
You can purchase the YX5300 UART TTL Serial Control MP3 Music Player Module directly from Envistia Mall:
YX5300 UART TTL Serial Control MP3 Music Player Module
📚 Additional Resources
- Envistia Mall — Browse our full catalog of development boards, sensors, and modules.
- Envistia Mall Learning Center — User guides and tutorials for all our products.
This user guide is provided for informational purposes only by Envistia Mall. While every effort has been made to ensure accuracy, Envistia Mall makes no warranties or representations regarding the completeness or accuracy of the information contained herein. Use of this product is at your own risk. Envistia Mall shall not be held liable for any damages resulting from the use or inability to use this product. Always follow proper electrical safety practices and local regulations when working with electronic components.