Also read!
Home / Tools / Arduino / DFPlayer mp3 player module for Arduino

DFPlayer mp3 player module for Arduino

Arduino is an open-source platform that facilitates Assembly and prototyping projects. By now you should know that the Arduino can light Leds, Turn motors, receive analog voltage, Print values on a LCD display, and now finally play MP3 with the DFPlayer module.

wpid-img_20150826_192819.jpg

This is the module.

wpid-img_20150826_192857.jpg

Has microSD card input. It also has a USB port and auxiliary analog audio, but it doesn't have the connectors. Not tested, but I think it would be possible to weld a connector and make it work!

wpid-img_20150826_192919.jpg

The module has two chips, I believe that is an MP3 decoder and a stereo amplifier, up to 3W!

wpid-img_20150826_192928.jpg

Below the pinout. Look at the DAC_R, DAC_L to analog input and the USB- and USB for USB port. Anyone who wants to can read the datasheet and try to understand what it's for each pin.

arduino mp3 pinout

To connect to the Arduino UNO I used this pinout.

arduino mp3

Downloaded the library DFPlayer-Mini-mp3 and I tried to run the sample programs. All a drug. I decided to make my own sample program using the library:

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

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

void setup () {
Begin serial. (9600);
mySerial. begin (9600);
mp3_set_serial (mySerial); //set softwareSerial is DFPlayer-mini mp3 module
delay(10); // delay 1ms to set volume

mp3_reset();
delay(1000);

mp3_set_volume (10); // value 0 ~ 30
delay(10);

}
void loop () {
If (Serial. available()) {
char command = read Serial.();

switch (command) {
case ‘ S ’:
mp3_stop();
delay(10);
break;
case ‘ N ’:
mp3_next();
delay(10);
break;
case ‘ P ’:
mp3_prev();
delay(10);
break;
}
}
}

With the program that I made, the MP3 player plays files from the SD card in the order they are written. To touch just open the Serial Monitor in 9600 and send “N” to the next song and “P” to the previous. It worked! Below is my connection. I left two loose wires to connect to the speaker, in my case it was a headset. I simply lay on the headset connector, on only one side, to listen it was working.

wpid-wp-1440632748801.jpeg

The library is a drug, but the label worked. I couldn't receive via serial the name of the song, or any other information, but I was able to raise and lower the volume, play at random and loop. Very cool, pity that the support is awful.

I leave the link to the product and to the datasheet, If someone wants to do a new library:

Product – http://www.banggood.com/DFPlayer-Mini-MP3-Player-Module-For-Arduino-p-969191.html

Datasheet – http://www.dfrobot.com/wiki/index.php/DFPlayer_Mini_SKU:DFR0299

About Adriano Moutinho

Adriano Moutinho
Professor of Electronics technician at CEFET-RJ, Telecommunications engineer, Master in computer science and a Ph.d. in Civil Engineering. In addition to crazy China products buyer.

10 comments

  1. Hello everyone

    I would like to succeed has read my loop 4 mp3 files for a model forraine I can not find how to do .I just want an end code that instructs to read as a result my MP3s
    Thank you for your help here is the code that I put but it does not suit me. #include
    #include

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

    void setup()
    {
    Begin serial.( 115200 );
    Serial .print( “\nnDFPlayer_Mini_Mp3n” );

    DFPlayerSerial.begin( 9600 );
    mp3_set_serial( dfplayerserial );
    mp3_set_device( 2 ); // SD card
    mp3_set_volume( 30 ); // 0-30
    mp3_single_loop (true); // Play file repeatedly
    }

    void loop()
    {
    mp3_next();
    _delay_ms( 78000 );
    }

  2. The DFPlayer working smoothly with the Arduino Mega2560.
    The Arduino due the soft serial library does not go.
    Tried the functions from the DFPlayer_Mini_Mp3 with the Serial2.print of TX2 Port16 most due to spend. Then a test with the soft_uart_serial Library = 11 on TX and RX = 10.
    9600Baud and send length 64 bit was set there and the default of the variable send_buf[10] taken from the DFPlayer_Mini_Mp3.h. Somehow nothing works because.

    Will prefer the due working, because it is better suited for larger projects.
    Has there ever tried in the direction of what any of you?

    Tan …Ulf

    • Adriano Moutinho

      In. I have only tested with Arduino Uno. This module is a complete mp3 player, so there is no need to use Arduino’s processor. Any Arduino will do fine.

    • perigalacticon

      Did you ever get this to work with the Due? I am using Due for a large robot project and would like to use this mp3 player. I get errors about software serial and the serial buffer also but don’t know the fix. Does someone have an updated library?

      Thanks.

  3. I really like your tutorial, helped me understand this shield. How do I make it run a specific music. Example, I want him to run the music 001.mp3.
    I used this command line and it didn't work:
    case ‘ P ’:
    mp3_play(1);
    delay(10);
    break;

    When I put “N” works normally. But I want in a list that he run only the specific song.

    Help me?

Leave a Reply

Your email address will not be published. Required fields are marked *

*