top of page
Writer's pictureRamesh G

Arduino based MP3 Player using DF Player mini

Updated: Apr 23, 2022


Here to learn arduino nano based Mp3 player to Play MP3 songs using using DFPlayermini module. In this DFPlayer SD card is used to store the MP3 files. Push Buttons using to control Volume +,Volume -, Previous, next and start from first.

Circuit diagram



Components Required

Arduino Nano - 1 no

DFPlayer Mini - 1 no

Memory card 16gb- 1 no

Push button - 3 nos

Resistor 1k - 1 no


DFPlayer Mini

The DFPlayer Mini MP3 Player For Arduino is a small and low price MP3 module with an simplified output directly to the speaker. The module can be used as a stand alone module with attached battery, speaker and push buttons or used in combination with an Arduino UNO or any other with RX/TX capabilities.



Specification

  • supported sampling rates (kHz): 8/11.025/12/16/22.05/24/32/44.1/48

  • 24 -bit DAC output, support for dynamic range 90dB , SNR support 85dB

  • fully supports FAT16 , FAT32 file system, maximum support 32G of the TF card, support 32G of U disk, 64M bytes NORFLASH

  • a variety of control modes, I/O control mode, serial mode, AD button control mode

  • advertising sound waiting function, the music can be suspended. when advertising is over in the music continue to play

  • audio data sorted by folder, supports up to 100 folders, every folder can hold up to 255 songs

  • 30 level adjustable volume, 6 -level EQ adjustable


Work Mode

1. Serial Mode

Support for asynchronous serial communication mode via PC serial sending commands Communication Standard:9600 bps Data bits :1 Checkout :none Flow Control :none

  • Instruction Description


  • Serial Control CMD


  • Serial Query CMD

2. AD KEY Mode

We use the AD module keys, instead of the traditional method of matrix keyboard connection, it is to take advantage of increasingly powerful MCU AD functionality, Our module default configuration 2 AD port, 20 key resistance distribution.



3. I/O Mode

Here comes the most simple way to use this module.


Copy your mp3 into you micro SD card

NOTE: The order you copy the mp3 into micro SD card will affect the order mp3 played , which means play(1) function will play the first mp3 copied into micro SD card.

The folder name needs to be mp3, placed under the SD card root directory, and the mp3 file name needs to be 4 digits, for example, "0001.mp3", placed under the mp3 folder. If you want to name it in Both English and Chinese, you can add it after the number, for example, "0001hello.mp3" or "0001后来.mp3".


Installing Library

To install the library navigate to the Sketch > Include Library > Manage Libraries… Wait for Library Manager to download libraries index and update list of installed libraries.


DFRobotDFPlayerMini.h : you need to Download and install the DFPlayer library.


After installing the required libraries, copy the following code to your Arduino IDE.




Arduino Code

#include "SoftwareSerial.h"

#include "DFRobotDFPlayerMini.h"


// Use pins 2 and 3 to communicate with DFPlayer Mini

static const uint8_t PIN_MP3_TX = 10; // Connects to DFPlayer Mini pin RX

static const uint8_t PIN_MP3_RX = 11; // Connects to DFPlayer Mini pin 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(10);

// Play the first MP3 file on the SD card

player.play(1);

} else {

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

}

}


void loop() {

}


Demo







Recent Posts

See All

Comentários


bottom of page