Download Print this page

Advertisement

Quick Links

Welcome!
Thank you for purchasing our AZ-Delivery MP3 DFPlayer Mini Module. On
the following pages, we will introduce you to how to use and set-up this
handy device.
Have fun!

Advertisement

loading
Need help?

Need help?

Do you have a question about the MP3 DFPlayer Mini Module and is the answer not in the manual?

Questions and answers

Summary of Contents for AZ-Delivery MP3 DFPlayer Mini Module

  • Page 1 Welcome! Thank you for purchasing our AZ-Delivery MP3 DFPlayer Mini Module. On the following pages, we will introduce you to how to use and set-up this handy device. Have fun!
  • Page 2 Areas of application Education and teaching: Use in schools, universities and training institutions to teach the basics of electronics, programming and embedded systems. Research and development: Use in research and development projects to create prototypes and experiments in the fields of electronics and computer science. Prototype development: Use in the development and testing of new electronic circuits and devices.
  • Page 3 consult a doctor. Caution: Keep the product out of the reach of children and pets to avoid accidental contact and swallowing of small parts. Note: Store the product in a safe, closed container when not in use. Attention: Avoid contact of the product with food and drinks.
  • Page 4 The MP3 DFPlayer Mini Module is a small and affordable MP3 module with output directly to the speaker or headphones. The module can be used as a stand alone module with attached battery, speaker and push buttons or used in combination with any Atmega328p board or any other board with USART capabilities.
  • Page 5: Specification

    Specification: » Operating voltage range: from 3.2V to 5V DC » Standby current: 20mA ℃ ℃ » Operating temperature: from -40 to 70 » UART port: Standard serial (TTL level) » Baud rate: Adjustable (default 9.600) » Equalizer: 6 levels, adjustable »...
  • Page 6 The pinout USART pins are used for serial communication. If you are experiencing high noise, connect one 1kΩ resisor to the TX pin, serially. Audio output channel pins are used as DAC pins (Digital to Analog Converter), and you should connect them to the external amplifier. Speaker pins are pins from on-board 3W amplifier, and you can connect them directly to the external speaker (8Ω...
  • Page 7 Power supply and BUSY pin The module supports operating voltage range from 3.2V up to 5V DC. Connect external power supply between Power supply pin and Ground pin. The module serial port TTL logic level voltage is 3.3V, so when you use 5V levels (for example Atmega328p board), connect serially a resistor with more than 1kΩ...
  • Page 8 Audio output channels and speaker pins The main chip of the module has 24 bit digital to analog converter (DAC for short). Chip has two DAC pins which are connected directly to the audio output channels of the module. You should connect external amplifier on the audio output channel pins in order to use DAC capabilities of the module.
  • Page 9 Trigger ports (IO pins) These pins are used for song switching and adjusting volume levels via hardware. Connect push buttons to these pins as shown on the connection diagram: When push button rest state, diagonal pins of the push button are not connected. When you press the push button diagonal pins of the push button are connected, which then puts the push button in an active state.
  • Page 10 ADKEY pins The AD functionality of the chip on-board the module enables you to connect 20 resistors with buttons on two AD ports of the module as shown on the connection diagram below: NOTE: It is necessary that the power supply is as stable as possible in order for this to work properly! Short push on the Play Mode button switches the playback to interrupted or not interrupted.
  • Page 11 Short push on the Loop All button switches the play mode to loop all or not looping of all songs. There is no long push function for this button. Short push on the Pause/Play button pauses or plays currently selected song.
  • Page 12: Serial Port

    Serial port RX and TX pins are used to establish serial communication with external microcontroller. Do not forget to connect a resistor to the RX pin when using 5V TTL logic. Serial port of the module supports asynchronous serial communication mode. Default baud rate of the serial communication is 9600bps and it is adjustable in software.
  • Page 13 Format of the command To send a command to the module, follow specific format: $SB VB LB CMD ACK DATA1 DATA2 CHKS1 CHKS2 $EB Mark Byte Byte description Start byte 0x7E Version byte 0xFF The number of bytes of the command without 0xxx start and end bytes (In our case 0x06) Such as PLAY and PAUSE and so on...
  • Page 14 Folder structure and song names The module supports several types of folders and specific names for songs. Names of folders are numbers, except “mp3” and “ADVERT” folders. Song names have to start with a number after which comes the string without spaces.
  • Page 15 Fourth is a folder called “ADVERT” and it too can contain 3000 songs and it is used for advertisement songs. The module supports one “ADVERT” folder in total. Song names in this folder start with numbers in the range from 0000 to 2999.
  • Page 16 Sending commands to the module In order to send commands to the module, connect the module with the Atmega328p as shown on the connection diagram below: Module pin > Mc pin > Red wire > D7 (via 1kΩ resistor) Blue wire >...
  • Page 17 We are using serial interface created in software on digital I/O pins 6 and 7 of the Atmega328p, because Atmega328p uses hardware serial pins (digital I/O pins 0 and 1), for programming main microcontroller. The microcontroller can not send commands to control the module until initialization of the module is finished and data is returned.
  • Page 18 Sketch example: #include "SoftwareSerial.h" #define Start_Byte 0x7E #define Version_Byte 0xFF #define Command_Length 0x06 #define End_Byte 0xEF // Returns info with command 0x41 [0x01: info, 0x00: no info] #define Acknowledge 0x01 SoftwareSerial mySerial(6, 7); RX, TX byte receive_buffer[10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; char data;...
  • Page 19 void reset_rec_buf() { for(uint8_t i = 0; i < 10; i++) { receive_buffer[i] = 0; bool receive() { reset_rec_buf(); if(mySerial.available() < 10) { return false; for(uint8_t i = 0; i < 10; i++) { short b = mySerial.read(); if(b == -1) { return false;...
  • Page 20 void print_received(bool print_it) { if(print_it) { if(receive()) { for(uint8_t i = 0; i < 10; i++) { Serial.print(receive_buffer[i], HEX); Serial.print("\t"); Serial.println(); else { receive(); } void module_init() { execute_CMD(0x0C, 0, 0); delay(1000); // Reset the module print_received(false); delay(100); Serial.print("SDON\t"); print_received(true); delay(100);...
  • Page 21 void set_volume(uint8_t volume) { Serial.print("SETVOL\t"); execute_CMD(0x06, 0, volume); delay(100); // Set volume level print_received(false); delay(100); execute_CMD(0x43, 0, 0); delay(100); // Get volume level print_received(false); delay(100); print_received(true); delay(100); void play_next() { Serial.print("NEXT\t"); execute_CMD(0x01, 0, 0); delay(100); print_received(false); delay(100); execute_CMD(0x4C, 0, 0); delay(100); // Get current song played print_received(false);...
  • Page 22 // one tab else Serial.print("VOL\t"); execute_CMD(0x06, 0, volume); delay(100); // Set previous vol print_received(false); delay(100); execute_CMD(0x43, 0, 0); delay(100); // Get volume level print_received(false); delay(100); print_received(true); delay(100); void random_play() { // Random plays all songs, loops all, repeats songs in playback execute_CMD(0x18, 0, 0);...
  • Page 23 void query_status() { execute_CMD(0x42, 0, 0); delay(100); // Get status of module print_received(false); delay(100); Serial.print("STATUS\t"); print_received(true); delay(100); execute_CMD(0x43, 0, 0); delay(100); // Get volume level print_received(false); delay(100); Serial.print("VOLUME\t"); print_received(true); delay(100); execute_CMD(0x44, 0, 0); delay(100); // Get EQ status print_received(false); delay(100); Serial.print("EQ\t");...
  • Page 24 void setup() { Serial.begin(115200); mySerial.begin(9600); delay(1000); Serial.println("\nInitialization"); module_init(); void loop() { print_received(true); while(Serial.available() > 0) { data = Serial.read(); // Serial.println(data, HEX); // For debugging if(data != "/n") { if(data == 'N') { Serial.println("\nPlay next song"); play_next(); else if(data == 'B') { Serial.println("\nRandom play");...
  • Page 25 The sketch starts with including one library called “SoftwareSerial.h”. Then we define five macros. These macros represents the command bytes that are the same for all commands. First byte is called ”Start_Byte” which value is 0x7E, second byte is called “Version_Byte” which value is 0xFF, third byte is called “Command_Length”...
  • Page 26 Then we create several functions. First function is called “execute_CMD()” which accepts three arguments and returns no value. The function execute_CMD() is used to send commands to the module. First argument is the command byte, second is data1 byte and third is data2 byte of the command.
  • Page 27 If the return data has ten bytes, then we use for loop to read all ten bytes. After reading a byte, we check if its value is valid by checking if it is different from “-1”. If it is different, store its value to the receive_buffer. If any of the checks are not satisfied, returned boolean value is “false”;...
  • Page 28 In the setup() function we start hardware serial with baud rate of 115.200 bps, and software serial with baud rate 9.600 bps (which is default baud rate of the module). Then we call the function module_init() which initializes the module, sets equalizer, volume level, plays the first song on the storage device and prints out the status data to the Serial Monitor.
  • Page 29 When you upload the complete sketch example to the Atmega328p, start the Serial Monitor (Tools > Serial Monitor), and send few letters from the sketch via Serial Monitor to the Atmega328p. The output should look like the output on the image below:...
  • Page 30: Command Examples

    Command examples Command Bytes (HEX) * Description Next Song 7E FF 06 00 00 00 EF Play next song Previous Song 7E FF 06 00 00 00 EF Play previous song 7E FF 06 00 00 01 EF Play the first song Play with index 7E FF 06 00 00 02 EF...
  • Page 31 Command Bytes (HEX) * Description Play specific song in a folder 7E FF 06 00 00 01 EF In folder 0 play song 001 that supports 3000 songs; 7E FF 06 00 91 11 EF In folder 9 play song 273 (=0x111) module suports 16 folders 7E FF 06 00 F0 05 EF...
  • Page 32 Status updates of the module There is an option if you want to get the return data from the module. This data is very useful because it can contain information of current playback status, volume level, EQ option, when the current playing song is finished, etc.
  • Page 33: Return Values

    Return values The return data is in format: 0x7E 0xFF 0x06 0x41 0x00 A B checksum1 checksum0 0xEF The value 0x41 indicates that a ommand was received by the module and executed successfully. The value “A” represents storage media, where: A = 0x01 - USB flash disk, and A = 0x02 - SD card.
  • Page 34 Errors If some error occures, the return data will be in the format: 0x7E 0xFF 0x06 0x40 0x00 0x00 0x01 chks1 chks0 0xEF Where 0x40 indicates that error occurred, and 0x01 indicates error value. Error values with descriptions are in the table below: Error data (HEX) * Description 7E FF 06...
  • Page 35 Specific returned data If the acknowledge byte is set to 0x01, the module will output data when song is finished, when SD card (or USB flash disk) is pushed IN or pulled OUT or when storage device is online. These values will be returned without sending any command to the module.
  • Page 36 The returned data when storage device is online: 0x7E 0xFF 0x06 0x3F 0x00 0x00 0xFE 0xF7 0xEF where: 0x3F indicates that storage device is online, and "A" can have several different values: A = 0x01 indicates USB flash disk A = 0x02 indicates SD card A = 0x03 indicates that USB flash disk and SD card are both online at the same time A = 0x04 indicates PC connection...
  • Page 37 Playback returned values If the acknowledge byte is set to 0x01, we send the command for playback status: 0x7E 0xFF 0x06 0x45 0x00 0x00 0x00 chks1 chks0 0xEF The returned data will be in format: 0x7E 0xFF 0x06 0x41 0x00 0x00 chks1 chks0 0xEF where "A"...
  • Page 38 If you are looking for the high quality microelectronics and accessories , AZ-Delivery Vertriebs GmbH is the right company to get them from. You will be provided with numerous application examples, full installation guides, eBooks, libraries and assistance from our technical experts.