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

Professor, Engineer and buyer of products crazy China.

11 comments

  1. I have the same problem with DFPlayer and Arduino Due:
    My problem: I bought some Mini-MP3-Players and my son compiled the Software “Get Started” (in “DFPlayer Mini SKU DFR0299 – DFRobot Electronic Product Wiki and Tutorial Arduino and Robot Wiki-DFRobot.com.htm” without any Problem for Arduino UNO. He said, Arduino DUE is better, so I bought a DUE. With the following result:
    The compilation of (it is the shrinked “Get Started”!):
    **************************************************
    #include “Arduino.h”
    #include “SoftwareSerial. h”
    #include “DFRobotDFPlayerMini.h”

    SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
    //DFRobotDFPlayerMini myDFPlayer;
    //void printDetail(uint8_t type, int value);
    void setup() {
    // put your setup code here, to run once:
    }
    void loop() {
    // put your main code here, to run repeatedly:
    }
    **************************************************
    results with error:
    sketch sketch_nov14a.ino.cpp.o: In function `__static_initialization_and_destruction_0′:
    (C):\UsersGerdDocumentsArduinosketch_nov14a/sketch_nov14a.ino:5: undefined reference to `SoftwareSerial::SoftwareSerial(unsigned char, unsigned char, bool)’
    (C):\UsersGerdDocumentsArduinosketch_nov14a/sketch_nov14a.ino:5: undefined reference to `SoftwareSerial::~SoftwareSerial()’
    collect2.exe: error: ld returned 1 exit status

    It’s okay, because in SoftwareSerial.h:

    public:
    // public methods
    SoftwareSerial(uint8_t receivePin, uint8_t transmitPin, bool inverse_logic = false);

    there are three terms (rec.Pin, trans.Pin, inverse_l.), but in “Get Started” there are only two terms (SoftwareSerial mySoftwareSerial(10, 11); // RX, TX)

    My Problem: Why for Ard. UNO it’s compiled with no errors, but for Ard. DUE with errors. Is it another library? What can I do?

  2. 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 );
    }

  3. 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

    • 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.

  4. 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 to perigalacticon Cancel reply

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

*