Git Product home page Git Product logo

dfplayer's Introduction

license-badge version stars hit-count github-issues

DFPlayer Mini

This is small and fast Arduino library for:

  • DFPlayer Mini, MP3-TF-16P, FN-M16P (YX5200 chip, YX5300 chip or JL AAxxxx chip from Jieli)
  • FN-M10P, FN-M10P (FN6100 chip)
  • DFPlayer Mini HW-247A (GD3200B chip)

alt text

DFPlayer Mini features:

  • +3.2v..+5.0v, typical +4.2v
  • average curren 24mA
  • 24-bit DAC with 90dB output dynamic range and SNR over 85dB
  • micro SD-card, up to 32GB (FAT16, FAT32)
  • USB-Disk up to 32GB (FAT16, FAT32)
  • supports mp3 sampling rate 8KHz, 11.025KHz, 12KHz, 16KHz, 22.05KHz, 24KHz, 32KHz, 44.1KHz, 48KHz
  • supports up to 100 folders, each folder can be assigned to 001..255 songs
  • built-in 3W mono amplifier, NS8002 AB-Class with standby function (move jumper to STBY->BUSY, see picture above)
  • UART to communicate, 9600bps (parity: none/data bits: 8/stop bits: 1/flow control: none)

NOTE:

  • If you hear a loud noise, add a 1K resistors in series with DFPlayer TX-pin & RX-pin.
  • Move the jumper from right to left to automatically switch the amplifier to standby.
  • Files are in the root must contain 4 digits with leading zeros. For example: SD_ROOT/0001 - My favorite song.mp3. Player sorts the root by the time of writing to the card. Do not copy 0003.mp3 and then 0001.mp3 as 0003.mp3 will play first.
  • Folders must contain 2 digits with leading zeros. Number of folders 01..99. Files inside must contain 3 digits with leading zeros. The number of files in each folder is 001..255. For example: SD_ROOT/01/001 - My favorite song.mp3. Unlike the root, files from folders can be read by the file number.
  • Folder "mp3" and "advert". Files inside this folders must contain 4 digits with leading zeros. The number of files is 0001..9999 and can be read by file number. For example: SD_ROOT/mp3/ 0001 - My favorite song.mp3. Files from "advert" are played only if a track is already playing. Then the module pauses the current one, plays the file from "advert" and unpauses the main one.

Library APIs supports all modules features:

void begin(Stream& stream, uint16_t threshold = 350, DFPLAYER_MODULE_TYPE = DFPLAYER_MINI, bool feedback = false, bool bootDelay = true);

void setModel(DFPLAYER_MODULE_TYPE = DFPLAYER_MINI);
void setTimeout(uint16_t threshold); //usually 200msec..300msec for YX5200/AAxxxx chip & 350msec..500msec for GD3200B/MH2024K chip
void setFeedback(bool enable);

void setSource(uint8_t source); //all sources may not be supported by some modules
void playTrack(uint16_t track);
void next();
void previous();
void pause();
void resume();
void stop();

void playFolder(uint8_t folder, uint8_t track);
void playMP3Folder(uint16_t track);
void play3000Folder(uint16_t track); //may not be supported by some modules
void playAdvertFolder(uint16_t track);
void playAdvertFolder(uint8_t folder, uint8_t track); //may not be supported by some modules
void stopAdvertFolder();

void setVolume(uint8_t volume);
void volumeUp();
void volumeDown();
void enableDAC(bool enable); //flase=mute/true=unmute
void setDACGain(uint8_t gain, bool enable = true); //may not be supported by some modules
void setEQ(uint8_t preset); //may not be supported by some modules

void repeatTrack(uint16_t track);
void repeatCurrentTrack(bool enable);
void repeatAll(bool enable);
void repeatFolder(uint16_t folder);
void randomAll();

void sleep();
void wakeup(uint8_t source = 2);
void enableStandby(bool enable, uint8_t source = 2);
void reset();

uint8_t  getStatus();
uint8_t  getVolume();
uint8_t  getEQ(); //may not be supported by some modules
uint8_t  getPlayMode(); //may not be supported by some modules
uint8_t  getVersion();
uint16_t getTotalTracksSD();
uint16_t getTotalTracksUSB();
uint16_t getTotalTracksNORFlash(); //may not be supported by some modules
uint16_t getTrackSD();
uint16_t getTrackUSB();
uint16_t getTrackNORFlash(); //may not be supported by some modules
uint8_t  getTotalTracksFolder(uint8_t folder);
uint8_t  getTotalFolders(); //may not be supported by some modules
uint8_t  getCommandStatus();

Supports:

  • Arduino AVR
  • Arduino ESP8266
  • Arduino ESP32
  • Arduino STM32

dfplayer's People

Contributors

enjoyneering avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dfplayer's Issues

communication error

i use the esp32
conect with pin12 and pin14 as rx and tx
but it cant work
Snipaste_2022-06-18_20-28-06

Repeat folder not waiting for millis.

Is there a way to play folder and have it loop after the last track in the folder, ive called it with a random number to start with and it rolls onto the next folder after the last track. Ive tried repeat folder but in the function is supposed to be a 10sec delay with millis and the repeat folder function just goes with no gap between tracks.

MH2024K-24SS Chip

Hi! I have a DFPlayer Mini with a MH2024K-24SS which doesn't work with the library. I was wondering if the code can be adapted to work by figuring out what the proper checksum is?

Thanks!

HW-247A with 3200D chip

Hi,

I can't get HW-247A with 3200D chip modules to work with your DF_Player_ESP8266_Basic sample code.

The (good) documentation refers to the 3200B and this has 3200D printed on it, and I am wondering if that may be the cause.

Using a Wemos D1 mini (ESP8266) with D1 ---> RX and D2 ---> TX.

mp3.getStatus() returns: 4=communication error

I have increased MP3_SERIAL_TIMEOUT to 800

Tried 3.3V and 5V power. (Red LED on DFPlayer comes on for a short while after powering up)

mp3.getStatus() always returning 0 even when mp3 playing

Great library - thank you :)

I have it up and running, however I am unable to detect when a track has finished. I thought I could use:

while(mp3.getStatus() == 1){
delay(50);
}

But I always get 0 for mp3.getStatus() even when a track is playing - any suggestions?

I should add - I have the "df player HW-247A" version with the GD3200B chip

Volume control not working

Thanks for creating this library! I've been unable to get the official DF Robot library to work but this one does. I did run into an issue initially with not being able to control the volume but found a fix for it.

In the .h and .cpp files the setVolume command is defined as:

void setVolume(uint8_t volume);

whereas the DF Robot library defines it as:

void setVolume(uint16_t volume);

Changing the setVolume to be uin16_t in the .h and .cpp files for this library allowed me to control the volume.

Errors on DFPlayer_ESP8266_HW_Serial.ino compilation

Hello all.

I'm trying to compile the 'DFPlayer_ESP8266_HW_Serial.ino' example, but Arduino IDE 2.2.1 fails with tthe following output:

C:\Users\kvark\OneDrive\Arduino\libraries\DFPlayer-ESP\examples\DFPlayer_ESP8266_HW_Serial\DFPlayer_ESP8266_HW_Serial.ino: In function 'void setup()':
C:\Users\kvark\OneDrive\Arduino\libraries\DFPlayer-ESP\examples\DFPlayer_ESP8266_HW_Serial\DFPlayer_ESP8266_HW_Serial.ino:72:44: error: no matching function for call to 'USBCDC::begin(int, SerialConfig)'
   Serial.begin(MP3_SERIAL_SPEED, SERIAL_8N1);                     //hardware serial on GPIO01(TX) & GPIO03(RX) after boot
                                            ^
In file included from C:\Users\kvark\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.13\cores\esp32/USB.h:21,
                 from C:\Users\kvark\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.13\cores\esp32/HardwareSerial.h:201,
                 from C:\Users\kvark\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.13\cores\esp32/Arduino.h:184,
                 from C:\Users\kvark\AppData\Local\Temp\arduino\sketches\39004B9F2A7C6CE6203C16BE7839C87D\sketch\DFPlayer_ESP8266_HW_Serial.ino.cpp:1:
C:\Users\kvark\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.13\cores\esp32/USBCDC.h:70:10: note: candidate: 'void USBCDC::begin(long unsigned int)'
     void begin(unsigned long baud=0);
          ^~~~~
C:\Users\kvark\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.13\cores\esp32/USBCDC.h:70:10: note:   candidate expects 1 argument, 2 provided
C:\Users\kvark\OneDrive\Arduino\libraries\DFPlayer-ESP\examples\DFPlayer_ESP8266_HW_Serial\DFPlayer_ESP8266_HW_Serial.ino:76:10: error: 'class USBCDC' has no member named 'swap'
   Serial.swap();     //now hardware serial on GPIO15(TX) & GPIO13(RX)
          ^~~~
C:\Users\kvark\OneDrive\Arduino\libraries\DFPlayer-ESP\examples\DFPlayer_ESP8266_HW_Serial\DFPlayer_ESP8266_HW_Serial.ino:89:10: error: 'class USBCDC' has no member named 'swap'
   Serial.swap();     //now hardware serial on GPIO01(TX) & GPIO03(RX)
          ^~~~
C:\Users\kvark\OneDrive\Arduino\libraries\DFPlayer-ESP\examples\DFPlayer_ESP8266_HW_Serial\DFPlayer_ESP8266_HW_Serial.ino: In function 'void loop()':
C:\Users\kvark\OneDrive\Arduino\libraries\DFPlayer-ESP\examples\DFPlayer_ESP8266_HW_Serial\DFPlayer_ESP8266_HW_Serial.ino:103:10: error: 'class USBCDC' has no member named 'swap'
   Serial.swap();                      //now hardware serial on GPIO15(TX) & GPIO13(RX)
          ^~~~
C:\Users\kvark\OneDrive\Arduino\libraries\DFPlayer-ESP\examples\DFPlayer_ESP8266_HW_Serial\DFPlayer_ESP8266_HW_Serial.ino:112:7: error: 'class DFPlayer' has no member named 'setResponse'; did you mean '_getResponse'?
   mp3.setResponse(true);              //enable=request feedback to return not only errors but also OK statuses
       ^~~~~~~~~~~
       _getResponse
C:\Users\kvark\OneDrive\Arduino\libraries\DFPlayer-ESP\examples\DFPlayer_ESP8266_HW_Serial\DFPlayer_ESP8266_HW_Serial.ino:116:10: error: 'class USBCDC' has no member named 'swap'
   Serial.swap();                      //now hardware serial on GPIO01(TX) & GPIO03(RX)
          ^~~~
C:\Users\kvark\OneDrive\Arduino\libraries\DFPlayer-ESP\examples\DFPlayer_ESP8266_HW_Serial\DFPlayer_ESP8266_HW_Serial.ino:121:10: error: 'class USBCDC' has no member named 'swap'
   Serial.swap();                      //now hardware serial on GPIO15(TX) & GPIO13(RX)
          ^~~~
C:\Users\kvark\OneDrive\Arduino\libraries\DFPlayer-ESP\examples\DFPlayer_ESP8266_HW_Serial\DFPlayer_ESP8266_HW_Serial.ino:129:10: error: 'class USBCDC' has no member named 'swap'
   Serial.swap();                      //now hardware serial on GPIO01(TX) & GPIO03(RX)
          ^~~~

exit status 1

Compilation error: no matching function for call to 'USBCDC::begin(int, SerialConfig)'

GD3800D Chip

Hi, I received a GD3800D chip (similar to GD3200D) but it doesn't work with this library. I should fix What parts of this library can be improved?

Thanks!

GD3800D解码芯片用户手册 V1.2.pdf

(The link above is the datasheet of the GD3800D.)

HW-247A ... communication error

Hi,
Thanks for your work ... but unfortunately it doesn't work for me

I just buy on AliE some "DF Player mini" labelled HW-247A with the GB3200B chip.
It doesn't lool exactly as the one shown on your page (no STBY->BUSY nor STBY->GND solder points)

On ESP32, I've tryied the different module types, with timeout up to 2000ms ... still having communication error (#4)

Any suggestion or ideas to test ?

I can provide one module for testing if you want ...
the AE url is : https://www.aliexpress.com/item/1005001417104130.html?spm=a2g0o.order_list.0.0.30ba5e5bVI3RBV

thanks for your help

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.