Wiring DFPlayer Mini (MP3 Module) to Arduino. Stereo/Mono Diagrams.

Table of content:

DFPlayer Mini is a cheap MP3 player module with a Micro SD card slot.

A photo of the DFPlayer Mini module

To use the DFPlayer Mini module with Arduino, you only need to connect four wires - VCC and GND to give power to the module and two Arduino digital pins to the RX and TX pins for serial communication. Then you can send commands to play MP3 files on the SD card.

You can connect one mono speaker to the module or two speakers in stereo mode.

DFPlayer Mini connection diagram
DFPlayer Mini datasheet: http://www.picaxe.com/docs/spe033.pdf

To follow this tutorial, you need:

  • A DFPlayer Mini module
  • A Micro SD card
  • An Arduino or Arduino compatible board
  • A speaker (Up to 3W)
  • Two resistors to create a voltage divider from 5V to 3.3V. For example, a 1kΩ and a 680Ω resistor.
  • Some jumper wires

Video Tutorial

This is a step-by-step guide in video form. Here I am using Arduino Nano instead of Uno, but the pins are the same.

It's a revised version of my previous DFPlayer Mini video, where I connected the Arduino serial output pin directly to the DFPlayer Mini board's RX pin. This shouldn't be done since input pins of the module are not 5V tolerant. In this video, I am using a voltage divider for the RX pin.

Wiring Diagram: mono

P-Channel MOSFET connection diagram. Connected on the VCC side.

1. You can connect the 5V output from Arduino to the VCC pin of the MP3 player module. It is 5V tolerant.

It is possible to power DFPlayer Mini with 3.3V, but in my experience, the 3.3V voltage regulator on the Arduino board could not deliver enough current for it to work reliably.

2. Connect Arduino GND to the GND on the right side of the board.

DFPlayer Mini has two Ground pins. One is on the left side between the speaker pins (SPK1 and SPK2), and the other is on the right side between the IO pins. It will work with either of the Ground pins, but you will get less noise if you connect your Arduino to the right side of the DFPlayer Mini board. The left GND is meant for stereo speakers.

3. Make a voltage divider between Arduino D2 (software serial data transmit) pin and module's RX (data receive) pin.

DFPlayer Mini's digital input pins are not 5V tolerant. You should create a voltage divider by connecting a 680Ω and a 1kΩ in series from Arduino D2 to GND. Then connect a wire from between the resistors to the module's RX pin.

4. Connect Arduino D3 (software serial data receive) pin to the module's TX (data transmit) pin.

5. For a mono speaker, connect one wire to SPK1 and the other to SPK2.

Wiring Diagram: stereo

P-Channel MOSFET connection diagram. Connected on the VCC side.

1. You can connect the 5V output from Arduino to the VCC pin of the MP3 player module. It is 5V tolerant.

It is possible to power DFPlayer Mini with 3.3V, but in my experience, the 3.3V voltage regulator on the Arduino board could not deliver enough current for it to work reliably.

2. Connect Arduino GND to the GND on the right side of the board.

DFPlayer Mini has two Ground pins. One is on the left side between the speaker pins (SPK1 and SPK2), and the other is on the right side between the IO pins. It will work with either of the Ground pins, but you will get less noise if you connect your Arduino to the right side of the DFPlayer Mini board. The left GND is meant for stereo speakers.

3. Make a voltage divider between Arduino D2 (software serial data transmit) pin and module's RX (data receive) pin.

DFPlayer Mini's digital input pins are not 5V tolerant. You should create a voltage divider by connecting a 680Ω and a 1kΩ in series from Arduino D2 to GND. Then connect a wire from between the resistors to the module's RX pin.

4. Connect Arduino D3 (software serial data receive) pin to the module's TX (data transmit) pin.

5. For stereo speakers, connect one wire of both of the speakers to the left GND (between the speaker wires). The second wire for the first speaker goes to SPK1 and for the second speaker to SPK2.

Choosing a Speaker

DFPlayer Mini has a 3W amplifier on the board. You can try it with any speaker that has 4Ω or more impedance. The lower the impedance, the louder the maximum volume can be. I have mostly used cheap 8Ω speakers off of eBay, although once I tried it with the handset of an old rotary phone.

Here is an example of the 8Ω speaker in action:

I don't know the actual impedance value of the old phone's speaker, but it was probably higher than 8Ω. It was pretty quiet but about right for a phone's handset.

Here is an example of the phone's speaker:

Arduino Code

The easiest way to control DFPlayer Mini is to use the "DFRobotDFPlayerMini" library: https://github.com/DFRobot/DFRobotDFPlayerMini

Click on the green "Clone or download" button and then "Download ZIP."

Extract the downloaded ZIP file and move it into your Arduino "libraries" folder.

On Windows:
C:\Users\<username>\Documents\Arduino\libraries
On Mac:
/Users/<username>/Documents/Arduino/libraries

This is a simple example that starts playing the first MP3 file on the SD card after Arduino start up:

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

// Use pins 2 and 3 to communicate with DFPlayer Mini
static const uint8_t PIN_MP3_TX = 2; // Connects to module's RX
static const uint8_t PIN_MP3_RX = 3; // Connects to module's TX
SoftwareSerial softwareSerial(PIN_MP3_RX, PIN_MP3_TX);

// Create the Player object
DFRobotDFPlayerMini player;

void setup() {
  // Init USB serial port for debugging
  Serial.begin(9600);
  // Init serial port for DFPlayer Mini
  softwareSerial.begin(9600);

  // Start communication with DFPlayer Mini
  if (player.begin(softwareSerial)) {
    Serial.println("OK");

    // Set volume to maximum (0 to 30).
    player.volume(30);
    // Play the first MP3 file on the SD card
    player.play(1);

  } else {
    Serial.println("Connecting to DFPlayer Mini failed!");
  }
}

void loop() {
}

As a next step, you can follow the examples that come with the "DFRobotDFPlayerMini" library. It has commands to start and stop a song, play the next song in the sequence, play a song in a loop, etc.

Preparing Your SD Card

1. Format your SD card to FAT or FAT32 format.

On Windows:
  • Right-click on the SD card drive -> "Format..."
  • Select the file system as "FAT32 (Default)"
  • Click on the "Start" button
Formatting an SD card on Windows
On Mac:
  • Open "Disk Utility"
  • Select your SD card
  • Click on the "Erase" button on the toolbar
  • Select the format as "MS-DOS (FAT)"
  • Click on the "Erase" button
Formatting an SD card on Mac

2. Copy your MP3 files to the SD card.

Arduino cannot access MP3 files from the DFPlayer Mini by name. Instead, you must use a file number. It supports up to 255 files per folder. This means that you can access a file with values from 1 to 255.

You can organize your files into sub-folders – up to 100. Each folder can contain 255 MP3s.

The number of a file is determined by the order that it is copied to the SD card. Renaming files that are already copied to the SD card will not change the file number! When I am preparing an SD card for the module, I always add prefixes to the file names before copying them over. Usually I'll add "001_", "002_", "003_ ", etc. Then clear the SD card and copy all the files onto it.

It's the same deal with folders. Names do not matter. The first folder you created will be 1; the second one will be 2, etc.

Here is an example of my SD Card content for the Rotary Phone Project:

An example of SD folder content for the DFPlayer Mini module

IMPORTANT FOR MAC USERS!
Your Operating System creates hidden files on the SD card that WILL mess up the file numbers.

Open a terminal window and enter:
dot_clean /Volumes/<SD Card Name>

This command will remove all the hidden "._<your file name>.mp3" files that were created by the OS.