Search for your product name or keyword
YX5300 UART TTL Serial Control MP3 Music Player Module
This document provides a comprehensive guide to using the Envistia YX5300 UART TTL Serial Control MP3 Music Player Module. This module allows you to easily integrate MP3 and WAV audio playback into your projects, controlled via a serial UART interface.
Introduction
The YX5300 module is a versatile MP3/WAV player designed for embedded applications. It features a high-quality audio chip, a TF card (Micro SD) slot for storing audio files, and a 3-Watt amplifier for direct speaker connection. The module is controlled via a simple serial UART interface, making it compatible with a wide range of microcontrollers, including Arduino, AVR, ARM, and PIC. This manual will guide you through the module’s features, specifications, connections, and basic usage.
Features
- Versatile Audio Format Support: Plays MP3 and WAV audio files.
- Wide Sampling Frequency Range: Supports 8k Hz to 48k Hz sampling frequencies.
- Micro SD/SDHC Card Compatibility: Accepts Micro SD and Micro SDHC cards up to 32GB for audio storage.
- UART TTL Serial Control: Control playback via a simple serial interface.
- 3-Watt Amplifier: Built-in amplifier for direct connection to a speaker.
- Adjustable Volume: 30-step adjustable volume control.
- Compact Size: Small form factor for easy integration.
YX5300 Specifications
Feature | Specification |
---|---|
Supported Sampling Frequencies | 8 / 11.025 / 12 / 16 / 22.05 / 24 / 32 / 44.1 / 48 kHz |
Supported File Formats | MP3, WAV, WMA |
Micro SD Card Support | Micro SD and Micro SDHC up to 32GB |
Volume Control | 30-step adjustable volume |
Serial Communication | UART TTL, 9600 baud rate |
Power Supply | 3.2V ~ 5.2VDC |
Dimensions | 1.7 x 1 x 0.2 inches (43 x 25 x 5 mm) |
Pinout and Connections
The YX5300 module has the following pins:
- VCC: Power supply input (3.2V – 5.2V DC).
- GND: Ground.
- TX: UART Transmit pin. Connect to the RX pin of your microcontroller.
- RX: UART Receive pin. Connect to the TX pin of your microcontroller.
- Speaker +/-: (Not Pictured) Connect directly to a speaker. The module has a 3W amplifier built in.
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 module includes a 3.5mm audio jack for connecting headphones or external amplifiers. If using the built-in amplifier, connect a speaker directly to the speaker +/- pins.
Getting Started
Preparing the Micro SD Card
- Format the Micro SD card: Format the Micro SD card using the FAT16 or FAT32 file system.
- Copy Audio Files: Copy your MP3 or WAV 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).
- Insert the Micro SD Card: Carefully insert the Micro SD card into the TF card socket on the module.
Connecting the YX5300 to a Microcontroller (Example: Arduino)
// 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
SoftwareSerial
class, 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).
Wiring
- YX5300 VCC -> Arduino 5V
- YX5300 GND -> Arduino GND
- YX5300 TX -> Arduino Digital Pin 10 (RX)
- YX5300 RX -> Arduino Digital Pin 11 (TX)
- Speaker +/- -> Speaker
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 – 0x30, 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 | Set Volume Increment | 0x00 (No data required) | 7E FF 06 42 00 00 00 EF |
0x43 | Set Volume Decrement | 0x00 (No data required) | 7E FF 06 43 00 00 00 EF |
Troubleshooting
- No Audio Output:
- Verify the speaker is properly connected to the speaker +/- pins or headphones are connected to the 3.5mm jack.
- Check the volume level.
- Ensure the power supply voltage is within the specified range (3.2V – 5.2V).
- Verify the audio files are in a supported format (MP3 or WAV) and the sampling frequency is within the supported range.
- Make sure the Micro SD card is properly inserted and formatted correctly (FAT16 or FAT32).
- 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.
- Audio Quality Issues:
- Ensure the audio files are of good quality.
- Experiment with different equalizer settings.
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.
- Custom Applications: Integrate the YX5300 module into various projects, such as:
- Interactive audio installations.
- Voice prompts for embedded systems.
- DIY music players.
- Educational toys.
Where to Buy the YX5300 UART TTL Serial Control MP3 Music Player Module
YX5300 UART TTL Serial Control MP3 Music Player Module on the Envistia Mall Website:
https://envistiamall.com/products/yx5300-uart-ttl-serial-control-mp3-music-player-module-supports-mp3-wav-sd-sdhc
Disclaimer
This user manual is provided for informational purposes only. The manufacturer is not responsible for any damages or losses resulting from the use of this product. Always exercise caution when working with electronic components.
Copyright © 2025 Envistia Mall
www.envistiamall.com
P/N EM-AUDIO-0021