DFPlayer_Mini_SKU_DFR0299 - jimaobian/DFRobotWiki GitHub Wiki

DFPlayer Mini

Introduction

The DFPlayer Mini is a small and low price MP3 module with an simplified output directly to the speaker. The module can be used as a stand alone module with attached battery, speaker and push buttons or used in combination with an Arduino UNO or any other with RX/TX capabilities.

Specification

  • supported sampling rates (kHz): 8/11.025/12/16/22.05/24/32/44.1/48
  • 24 -bit DAC output, support for dynamic range 90dB , SNR support 85dB
  • fully supports FAT16 , FAT32 file system, maximum support 32G of the TF card, support 32G of U disk, 64M bytes NORFLASH
  • a variety of control modes, I/O control mode, serial mode, AD button control mode
  • advertising sound waiting function, the music can be suspended. when advertising is over in the music continue to play
  • audio data sorted by folder, supports up to 100 folders, every folder can hold up to 255 songs
  • 30 level adjustable volume, 6 -level EQ adjustable

PinOut

| | |-style="vertical-align:top;" |DFPlayer_Mini_Pin | | | | | | |------------|----------|----------------------------|------------------------------------------------------------| | Number | Name | Description | Note | | 1 | VCC | Input Voltage | DC 3.2-5.0V; Typical: DC4.2 | | 2 | RX | UART serial input | | | 3 | TX | UART serial output | | | 4 | DAC_R | Audio output right channel | Drive earphone and amplifier | | 5 | DAC_L | Audio output left channel | Drive earphone and amplifier | | 6 | SPK2 | Speaker | Drive speaker less than 3W | | 7 | GND | Ground | Power Ground | | 8 | SPK1 | Speaker | Drive speaker less than 3W | | 9 | IO1 | Trigger port 1 | Short pree to play previous(long press to decrease volume) | | 10 | GND | Ground | Power Ground | | 11 | IO2 | Trigger port 2 | Short pree to play next(long press to increase volume) | | 12 | ADKEY1 | AD port 1 | Trigger play first segment | | 13 | ADKEY2 | AD port 2 | Trigger play fifth segment | | 14 | USB+ | USB+ DP | USB Port | | 15 | USB- | USB- DM | USB Port | | 16 | Busy | Playing Status | Low means playing\High means no | | |-----|-------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------|

Information derections

Serial Mode

Support for asynchronous serial communication mode via PC serial sending commands

  • Instruction Description
Commands Function Description Parameters(16 bit)
0x01 Next
0x02 Previous
0x03 Special tracking(NUM) 0-2999
0x04 Increase volume
0x05 Decrease volume
0x06 Specify volume 0-30
0x07 Specify EQ 0/1/2/3/4/5 Normal/Pop/Rock/Jazz/Classic/Bass
0x08 Specify playback mode(0/1/2/3) repeat/folder repeat/single repeat/random
0x09 Specify playback source( 0/1/2/3/4) U/TF/AUX/SLEEP/FLASH
0x0A Enter into standby-low power loss
0x0B Normal working
0x0C Reset module
0x0D Playback
0x0E Pause
0x0F Specify folder to playback 1-10(need to set by user)
0x10 Volume adjust set [DH=1:Open volume adjust][DL:set volume gain 0-31]
0x11 Repeat play [1:start repeat play][0:stop play]
0x12 Specify MP3 tracks folder 0-9999
0x13 Commercials 0-9999
0x14 Support 15 folder See detailed description below
0x15 Stop playback, play background
0x16 Stop playback
  • Serial Query Cmd
Commands Function Description Parameters(16bit)
0x3C STAY
0x3D STAY
0x3E STAY
0x3F Send initialization parameters 0-0x0F(each bit represent one device of the low-four bits)
0x40 Returns an error, request retransmission
0x41 Reply
0x42 Query the current status
0x43 Query the current volume
0x44 Query the current status EQ
0x45 Query the current palyback mode This version retains this feature
0x46 Query the current software version This version retains this feature
0x47 Query the total number of TF card files
0x48 Query the total number of U-disk files
0x49 Query the total number of FLASH card files
0x4A keep on
0x4B Queries the current track of TF card
0x4C Queries the current track of U-disk
0x4D Queries the current track of Flash

AD KEY Mode

We use the AD module keys, instead of the traditional method of matrix keyboard connection, it is to take advantage of increasingly powerful MCU AD functionality, Our module default configuration 2 AD port, 20 key resistance distribution.

  • Refer diagram

DFPlayer_Mini

I/O Mode

Here comes the most simple way to use this module. *Refer diagram DFPlayer_Mini note: short time press means pre/next,and long time press means vol- ,vol +

Tutorial

Connection Diagram

DFPlayer_Mini_Pin

Sample Code

We've created an Arduino library for DFPlayer Mini to simplify the method for you to make it work. Connect the hardware as the picture above shown and play with the sample code. Please download DFPlayer library V2.0.

center NOTE: If you are going to use the example "DFPlayer_Mini_Test" in the library "DFPlayer library V2.0", please download and install the "DFRobot_utility" library, or you will see compile fail error.

Library installation

/*
 *  Copyright:  DFRobot
 *  name:       DFPlayer_Mini_Mp3 sample code
 *  Author:     lisper <[email protected]>
 *  Date:       2014-05-30
 *  Description:    sample code for DFPlayer Mini, this code is test on Uno
 *          note: mp3 file must put into mp3 folder in your tf card
 */


#include <SoftwareSerial.h>
#include <DFPlayer_Mini_Mp3.h>

void setup () {
    Serial.begin (9600);
    mp3_set_serial (Serial);      //set Serial for DFPlayer-mini mp3 module
    delay(1);                     // delay 1ms to set volume
    mp3_set_volume (15);          // value 0~30
}

void loop () {
    mp3_play (1);
    delay (6000);
    mp3_next ();
    delay (6000);
    mp3_prev ();
    delay (6000);
    mp3_play (4);
    delay (6000);
}

/*
   mp3_play ();     //start play
   mp3_play (5);    //play "mp3/0005.mp3"
   mp3_next ();     //play next
   mp3_prev ();     //play previous
   mp3_set_volume (uint16_t volume);    //0~30
   mp3_set_EQ ();   //0~5
   mp3_pause ();
   mp3_stop ();
   void mp3_get_state ();   //send get state command
   void mp3_get_volume ();
   void mp3_get_u_sum ();
   void mp3_get_tf_sum ();
   void mp3_get_flash_sum ();
   void mp3_get_tf_current ();
   void mp3_get_u_current ();
   void mp3_get_flash_current ();
   void mp3_single_loop (boolean state);    //set single loop
   void mp3_DAC (boolean state);
   void mp3_random_play ();
 */

This sketch plays all audio file one by one.

/*********************************
**Wire:
*Pin10 - player TX;
*Pin11 - player RX;
*pin3  - player BUSY
**Board : Uno
*By: LEFF
**********************************/
#include <SoftwareSerial.h>
#include <DFPlayer_Mini_Mp3.h>

SoftwareSerial mySerial(10, 11); // RX, TX

void setup () {
  Serial.begin (9600);
  mySerial.begin (9600);
  mp3_set_serial (mySerial);    //set softwareSerial for DFPlayer-mini mp3 module
  delay(1);                     // delay 1ms to set volume
  mp3_set_volume (15);          // value 0~30
}
void loop () {
  boolean play_state = digitalRead(3);// connect Pin3 to BUSY pin of player
  if(play_state == HIGH){
    mp3_next ();
  }
}

FAQ

Q 1. When my Arduino Uno send command to DFPlayer mini, the speaker will murmur, seems like noise, how to deal with it?

A: Please connect one 1k resistor between Arduino Tx and MP3 RX since DFPlayer Mini Module operating voltage is 3.3V.

  • Besides, one of our customers found to use another power supply for the MP3 module can get a pure sound. Be sure to make all the power's ground bound together. his post
Q 2. Is there any note for the name of the folder or the music file?

A: The function mp3_play (1); plays the audio file named "0001***.mp3(or other supported format)". You may have to note these:

(1). The audio file name should named with a four-digit number start, like:

:*0001.mp3

:*0002Chasing The Sun.mp3

:*0003.mp3

:*0004Try.mp3

600px

(2). The audio file should be placed in the **"MP3"**folder which was located in the TF card's root directory;

600px

Q 3. How to use advertisment function in arduino IDE? I need to pause playing0001. mp3 (background music), store the position, play another short mp3 (advertisment announce), resume background from pause position. How i can make it?

A: There is an example about it, plz follow the link.

Q 4. Has anyone used C Code for Atmega with DFplayer? Not for Arduino...

A: Shared by one of our user on Forum. DFplayer Serial Command

center For any questions and more cool ideas to share, please visit DFRobot Forum

link=http://www.dfrobot.com/ buy from dfrobot store or dfrobot distributor list

⚠️ **GitHub.com Fallback** ⚠️