Skip to content Skip to sidebar Skip to footer

How To Controll DFPlayer Mini MP3 Player Using Arduino Uno

DFPlayer Mini MP3 Module

How To Controll DFPlayer Mini MP3 Player Using Arduino Uno - DFPlayer Mini is an mp3 player module that can be controlled using a microcontroller such as the Arduino Uno. In this module, there is a card slot for a microSD, where mp3 files will be called and played from the microSD.

For the type of microSD format itself, it supports FAT16, FAT32, 32G from TF Card, 32G from U disk and 64M bytes NORFLASH. To be able to control this module, we will use serial communication (TX RX) on the Arduino Uno. However, before we enter the program, there are many types of this module on the market, including using ICs:

  • YX5200 (Official DF Robot chip, Support Serial Command)
  • GD3200 (DF Player versi baru, Support Serial Command)
  • MH2024 (Versi clone, tidak support serial command)
In this article, I use the GD3200 ic. So there might be some slightly different commands.

Library DFPlayer Mini Arduino

Now please download the library using the following download buttons:

How to add a library:
- Open Arduino IDE
- Click the Sketch menu > Include Library > Add .ZIP Library
- Select the file DFRobotDFPlayerMini-master.zip
- Click OK

DFPlayer Arduino Wiring

After the library has been successfully added to the Arduino IDE, let's set it up as shown in the following image:
How To Controll DFPlayer Mini MP3 Player Using Arduino Uno

Before we get into the circuit, let's take a look and learn the function of each pin. note the following picture:
How To Controll DFPlayer Mini MP3 Player Using Arduino Uno
DFPlayer Pin Mapping (DFROBOT)


Information:
  • VCC from 3.2~5.0V
  • GND for ground
  • RX for serial input
  • TX for serial output
  • DAC_R for Right Channel Audio Output
  • DAC_L for Left Channel Audio Output
  • SPK1 for Speaker connection +
  • SPK2 for Speaker connection -
  • BUSY to see status
  • LOW means audio is playing
  • HIGH means no audio is playing)
  • USB+ to USB+ DP
  • USB- for USB- DM
  • ADKEY1
  • ADKEY2
  • IO_1 for button
  • Short press to play previous file
  • Long press to lower volume
  • IO_2 for button
  • Short press to play next file
  • Long press to increase volume

Prepare MP3 Files

According to the official DF Robot website, the DFPlayer module will read files in order. The format is a maximum of 4 digits such as 0001.mp3 for file sequences to 1 and so on.

To read it we use the command:

myDFPlayer.play(1);

Now, put the mp3 file into the Micro SD and rename it to 0001. The first experiment let's use the program below.


Basic Program Playing mp3

#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"
#include "Arduino.h"

SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;


void setup () {
  mySoftwareSerial.begin(9600);
  myDFPlayer.begin(mySoftwareSerial);

  //set volume
  myDFPlayer.volume(30);

  //play first list
  myDFPlayer.play(1);

}

void loop () {

}
If you want to play second mp3, rename that file to 0002.mp3 and so on.

DFPlayer Function

As for besides playing mp3 files, we can use other functions, such as:
  • myDFPlayer.setTimeOut(500); 
    Set serial communictaion time out 500ms

  • myDFPlayer.next(); 
    Play next mp3

  • myDFPlayer.previous(); 
    Play previous mp3

  • myDFPlayer.play(1); 
    Play the first mp3

  •  myDFPlayer.loop(1); 
    Loop the first mp3

  • myDFPlayer.pause(); 
    pause the mp3

  • myDFPlayer.start(); 
    start the mp3 from the pause

  • myDFPlayer.playFolder(15, 4); 
    play specific mp3 in SD:/15/004.mp3; Folder Name(1~99); File Name(1~255)

  • myDFPlayer.enableLoopAll();
    loop all mp3 files.

  • myDFPlayer.disableLoopAll();
    stop loop all mp3 files.

  • myDFPlayer.playMp3Folder(4);
    play specific mp3 in SD:/MP3/0004.mp3; File Name(0~65535)

  • myDFPlayer.advertise(3);
    advertise specific mp3 in SD:/ADVERT/0003.mp3; File Name(0~65535)

  • myDFPlayer.stopAdvertise();
    stop advertise

  • myDFPlayer.playLargeFolder(2, 999);
    play specific mp3 in SD:/02/004.mp3; Folder Name(1~10); File Name(1~1000)

  • myDFPlayer.loopFolder(5);
    loop all mp3 files in folder SD:/05.

  • myDFPlayer.randomAll();
    Random play all the mp3.

  • myDFPlayer.enableLoop();
    enable loop.

  • myDFPlayer.disableLoop();
    disable loop.

  • myDFPlayer.volume(nilai); 
    Set volume value (0~30).

  • myDFPlayer.volumeUp();
    Volume Up

  • myDFPlayer.volumeDown();
    Volume Down

  • myDFPlayer.EQ(DFPLAYER_EQ_NORMAL);
    Mengatur Equalizer Normal

  • myDFPlayer.EQ(DFPLAYER_EQ_POP);
    Mengatur Equalizer Normal

  • myDFPlayer.EQ(DFPLAYER_EQ_ROCK);
    Mengatur Equalizer Rock

  • myDFPlayer.EQ(DFPLAYER_EQ_JAZZ);
    Mengatur Equalizer Jazz

  • myDFPlayer.EQ(DFPLAYER_EQ_CLASSIC);
    Mengatur Equalizer Classic

  • myDFPlayer.EQ(DFPLAYER_EQ_BASS);
    Mengatur Equalizer Bass
For the full function, please go to here.

Post a Comment for "How To Controll DFPlayer Mini MP3 Player Using Arduino Uno"