Page 1 of 1

DFPlayer mp3 player

Posted: Fri Sep 11, 2020 3:49 pm
by mnf
Recently been trying to get one of these working. I tried using some code on the forum but it wasn't working for me :-(

So I made a small component - the interface is a bit 'busy' for FC. Suggestions welcome - I' suspect naming similar routines to keep them together (PlayTrack, PlayFolder, Play....) might make things a bit easier here? All the play features are supported but there are some more 'query' routines to come, there a few demo ones here.

There is a small test program - I've used an Arduino Nano. I'm using a software serial port on D2 and D3. Other MCUs with multiple UARTs will do otherwise.
DFPlayer.fcpx
(4.28 KiB) Downloaded 252 times
DFPLayer_Test.fcfx
(11.72 KiB) Downloaded 244 times
You'll need some tracks (mp3) in a folder 01 (for the demo - plays track 5) on an SD card - the tracks are named 0001.mp3 (a four digit number.mp3) - they can also be nnnnTEXT.mp3 - where nnnn is a four digit number. I haven't tried attaching flash memory etc.
Get FoldersSD - doesn't seem to work correctly (the DFPlayer returns number of folders including deleted ones!)

Martin

Re: DFPlayer mp3 player

Posted: Sat Sep 12, 2020 12:58 am
by medelec35
Hi Martin,
Thank you for posting the component & test flowchart.
I have a few DF mini players.
They are great for putting audio to your projects.

I will have a play over the weekend with your component & let you know how it goes.

Re: DFPlayer mp3 player

Posted: Sat Sep 12, 2020 5:42 am
by mnf
Thanks Martin,

I'm keen to check it works with other MCUs as well as Arduino. Also ideas on the interface - it has quite a lot of macros (the Df player is very flexible!) - very easy to write - most macros are a single line of code...
The one problem I found is that a small delay is needed after a play command before doing a 'read' 1s delay in demo, I will probably alter the 'query' macro to check for this...

Martin

Re: DFPlayer mp3 player

Posted: Sun Sep 13, 2020 6:04 pm
by mnf
Tried playing via the DAC - through a mono amplifier. I'm a bit confused as to wiring DAC_L/R to amp with gnd to ground just gave a nasty buzz.. Connecting L and R to + gnd on the (mono) amp worked ok with pretty good sound.
However playing a stereo track only played one channel - how should this be wired??

Turning the DAC on /off doesn't seem to make much difference - sound is always produced via the DAC?

The player seems a bit 'picky' about what it will play - I managed to get some files playing from the 'mp3' folder but others didn't work?

Martin

Re: DFPlayer mp3 player

Posted: Sun Sep 13, 2020 7:35 pm
by Bachman
Try this:
Stereo to mono.png
Stereo to mono.png (4.07 KiB) Viewed 7395 times

Re: DFPlayer mp3 player

Posted: Sun Sep 13, 2020 8:05 pm
by mnf
Thanks - will give it a go....

Martin

Re: DFPlayer mp3 player

Posted: Sun Sep 13, 2020 10:10 pm
by mnf
Sadly it didn't work like that - nasty 'tractor' noise in the background :| , back to dac_l and dac_r.
Everything going wrong this evening - now it will only play track 1 and none of the queries return anything. Except I hadn't changed anything - just tweaked the test program to try different things - it allowed different folders, MP3 folder too. And then it didn't...

Look again tomorrow !

Martin

Re: DFPlayer mp3 player

Posted: Mon Sep 14, 2020 3:37 pm
by stefan.erni
Hi Martin

I found something about noise reduce for the DF player

regards

Stefan

Note: For simple use ,the upper diagram is ready,But if you find the noise is quite loud, then you could attach an 1K resistor to the TX pin

https://wiki.dfrobot.com/DFPlayer_Mini_ ... on_Diagram

Re: DFPlayer mp3 player

Posted: Mon Sep 14, 2020 4:06 pm
by Bachman
Sorry, i've forgotten an important thing, what is helped for me:
TXRX.png
TXRX.png (2.05 KiB) Viewed 7360 times

Re: DFPlayer mp3 player

Posted: Mon Sep 14, 2020 4:56 pm
by mnf
Thanks to both, I'll try the 10k resistors.. the 1k in the tx doesn't make much difference.
The sound from dac_l and r is actually pretty good....

Martin

Re: DFPlayer mp3 player

Posted: Tue Sep 15, 2020 10:46 pm
by medelec35
Hi Martin,
Sorry for the delay I have a lot going on at the moment.
Just got around to testing DF Component.
With the DF player, to play a precise track rather then the order it was placed on the card.
Create a folder Called MP3.
Then within the MP3 folder add the tracks in the format of

Code: Select all

0001 Any name you like.mp3
,

Code: Select all

0002 Any name you like.mp3
etc.
To play the track uses:

Code: Select all

Commands = 0x12
Parameter1HighByte = 0x00 //Track number HB
Parameter2LowByte = Count //Track number LB
With the component not able to use mapping.
To get around that, the component is created with the target set to say 16F18877 or any of the 16F15xxx.
With mapping there is a bug to select pins.
To get around that I just select UART software then back to hardware.
Unable to test received commands due to mapping not exposed.
This is what happens:
Mapped pins not available..png
Mapped pins not available..png (41.57 KiB) Viewed 7337 times
For a 5V PIC I just use a 1k resistor from TX of PIC to RX of player.
No resistor is requited from TX of player to RX of PIC.
Without the resistor going to RX of player, there will be voltage stress which can cause noise.
So although does not make any difference in your case, it's best to keep it in place.

Another cause of noise which I helped a friend to fix is caused by the power supply.
Try changing it for another.
You can check it's the case by trying batteries instead.

Re: DFPlayer mp3 player

Posted: Wed Sep 16, 2020 9:56 am
by mnf
Thanks for the feedback.

I'll add the remap pins and try battery power.

The folder structure is already supported - folders can either be names 01..nn (and I've seen this documented as either 10 folders or (more likely) 100 (so 00..99)) There is a PlayMP3Folder that plays tracks from a folder called 'mp3'

Similarly tracks can either be 0001.mp3 or 0001text.mp3 - the key is the first four digits are used by the player to find tracks and the text is ignored.

I also added a Busy macro - and a pin property - connected to the Busy pin on the player...

Martin

Re: DFPlayer mp3 player

Posted: Wed Sep 16, 2020 10:46 pm
by medelec35
you're welcome.
if not already seen one?
There are several data sheets floating about.
Not all cover command 0x12.
Here is one that does.
Also this one