Source: https://mokxi.com/learn/arduino-dfplayer-mini
Updated: 2026-11-02

Learn

# Play MP3 files from an Arduino with a DFPlayer Mini

Intermediate

Written by the Mokxi team, updated November 2, 2026

Start building free Open the editor

Or see every lesson.

- 465 parts on the bench
- 43 boards running now
- 1.00x real time, on every board

Click to open it in the editor

A DFPlayer Mini on SoftwareSerial pins 10 and 11, with BUSY on pin 3, on a simulated ATmega328P.

The DFPlayer Mini is a tiny MP3 player on a board: a microSD card slot, a decoder and a small amplifier that drives a speaker directly. The Arduino never touches the audio. It sends ten-byte commands over serial, "play file 1" or "volume 20", and the module does the rest. That makes sound effects and spoken lines easy even on an Uno.

The circuit above is an Uno with a DFPlayer Mini on SoftwareSerial, playing the card’s files one after another and watching for each one to end. The module’s face shows which file is playing and how far in it is. There are no recordings in a simulator, so you will not hear anything, but every command, reply and pin works as on the bench.

## What you need

- An Arduino Uno
- A DFPlayer Mini
- A microSD card with MP3 files (FAT32)
- A 1k resistor
- A small speaker, 3 W or less, or headphones on the DAC pins
- A breadboard and jumper wires

## Wiring

Part and pin | Goes to | Note

DFPlayer VCC and GND | 5 V and GND | Runs on 3.2 to 5 V

DFPlayer RX | Pin 11, through 1k | Its inputs are 3.3 V

DFPlayer TX | Pin 10 | SoftwareSerial’s receive pin

DFPlayer BUSY | Pin 3 | LOW while a file plays (optional)

DFPlayer SPK_1 and SPK_2 | The speaker | Not to ground; the amplifier drives both

## Wiring it to an Uno

The module talks serial at 9600 baud. The Uno’s hardware serial port is busy with the serial monitor, so the sketch makes a second one on pins 10 and 11 with SoftwareSerial link(10, 11): pin 10 receives from the module’s TX, pin 11 sends to its RX.

The module’s RX is a 3.3 V input. A 1k resistor in series from the 5 V pin keeps the current into it small, which is the wiring DFRobot shows. Without it, many modules work but make a hum or behave oddly.

## The sketch, step by step

player.begin(link) waits for the module to read its card and answer. If nothing answers, the sketch prints "Unable to begin: check the wiring and the card" and stops. volume(20) sets the volume on a scale of 0 to 30, and readFileCounts() asks how many files are on the card. This card holds four files in the root and two folders of four, so the first line says "Jukebox ready, 12 files". play(1) starts the first file.

loop() watches two things. BUSY on pin 3 goes LOW while a file plays, and the sketch prints "playing" and "quiet" as it changes. The module also sends a message when a file ends: available() and readType() == DFPlayerPlayFinished catch it, read() gives the file number, and the sketch prints "finished file 1" and plays the next one, wrapping around at the end. The module sends that message twice for every file, as the real one does, so the sketch only moves on when the number is the file it is playing.

The jukebox sketch

## Naming the files on the card

play(n) does not go by file name. The module numbers files in the order they were copied onto the card, so copy them one at a time, in order, onto a freshly formatted card. For named control, put files in folders called 01, 02 and so on, named 001.mp3, 002.mp3, and use playFolder(folder, file). Or put them in a folder called mp3, named 0001.mp3 and up, and use playMp3Folder(n).

BUSY and the "finished" message are two ways to know a file has ended. Pull the BUSY wire in this circuit and pin 3 is left floating: the sketch prints "playing" and "quiet" at random, many times a second, because a loose input picks up noise and is not a reading you can trust. But "finished file 1" still arrives over serial and the next file still plays.

## A bigger build: the talking skull

The second circuit uses the same DFPlayer wiring in a Halloween prop. A PIR sensor wakes a skull, its eyes light, and a servo moves its jaw from a list of timed cues written to match a spoken line. The skull knows the line is over when BUSY goes high, so a longer recording never leaves the jaw hanging open.

## Common mistakes

TX and RX swapped. The module’s TX goes to the Uno’s receive pin, pin 10 here. Swap them in this circuit and the sketch prints "Unable to begin: check the wiring and the card".

No 1k resistor on RX, which can give a buzz on the speaker.

Files in the wrong order, because the card numbers them by copy order, not by name.

A speaker from SPK_1 to ground. Wire it across SPK_1 and SPK_2.

Weak power. The amplifier draws a lot at high volume, and a USB port can sag. Power the module from a good 5 V supply with the ground shared, and turn the volume down while testing.

A card it cannot read. Use FAT32 and 32 GB or smaller.

## Questions

How do I connect a DFPlayer Mini to an Arduino Uno?

VCC to 5 V and GND to GND, the module’s TX to pin 10 and its RX to pin 11 through a 1k resistor, and a speaker across SPK_1 and SPK_2. Then use SoftwareSerial on pins 10 and 11 at 9600 baud.

Why do I need a 1k resistor on the DFPlayer RX pin?

Its inputs work at 3.3 V and the Uno’s pins are 5 V. The resistor limits the current into the pin, and it often cures a buzz from the speaker.

Which library does the DFPlayer Mini use?

DFRobotDFPlayerMini, from DFRobot. begin(), volume(), play(), playFolder(), next() and readFileCounts() are the calls most sketches need. Mokxi includes it.

Why does the DFPlayer play the wrong file?

Because it numbers files in the order they were copied onto the card, not by their names. Reformat the card and copy the files one at a time, or use numbered folders with playFolder().

Related

## Keep going

Arduino Halloween Props to Build in Your Browser PIR Motion Sensor: How It Works, With an Arduino UART Serial Explained: Baud, Frames and the Wire Arduino Tone Melody: Play a Song on a Piezo How the DFPlayer Mini is modeled The talking skull project Intermediate The Arduino Uno simulator The project page, with the full sketch Intermediate

## Build this for real

Open the editor, change a value and watch the number move with it. Nothing to install, and no account needed.

Start building free Open the editor
