DFPlayer mini

69-cat

Member
Since MDfly removed their more popular MP3 player that I have been using for years with my Halloween controllers, I was given direction to the Robotshop for the DFPlayer mini. I am using a basic code just to see if I can make it work but looks like I am not communicating via serial. The player works fine using the grounded inputs to play a track but just cant nail down the serial issue. Any input would be great...I think part of my problem is with the hex code and am I using the correct ones for this player?
Dave

Code:
[color=Navy]#Picaxe [/color][color=Black]14m2[/color]
[color=Blue]setfreq M8
symbol [/color][color=Purple]PIR_1 [/color][color=DarkCyan]= [/color][color=Purple]pinC.0[/color]
[color=Blue]symbol [/color][color=Purple]PIR_2 [/color][color=DarkCyan]= [/color][color=Purple]pinC.1[/color]
[color=Blue]symbol [/color][color=Purple]busy [/color][color=DarkCyan]= [/color][color=Purple]pinc.2[/color]
[color=Blue]symbol light1 [/color][color=DarkCyan]= [/color][color=Blue]B.1
symbol light2 [/color][color=DarkCyan]= [/color][color=Blue]B.2
symbol baud [/color][color=DarkCyan]= [/color][color=Blue]t9600_8
symbol messages [/color][color=DarkCyan]= [/color][color=Navy]2[/color]


[color=Black]Powerup: [/color][color=Green]'Just a starting point label[/color]
[color=Blue]Pause [/color][color=Navy]45000 [/color][color=Green]'45 second wait time to allow the PIR to stabilize [/color]

[color=Black]Main:[/color]
[color=Blue]serout C.4[/color][color=Black],[/color][color=Blue]baud[/color][color=Black], [/color][color=Blue]([/color][color=Navy]$FA[/color][color=Blue])
Do [/color][color=Black]: [/color][color=Blue]Loop Until [/color][color=Purple]PIR_1 [/color][color=DarkCyan]= [/color][color=Navy]1[/color]
[color=Blue]pause [/color][color=Navy]1000[/color]
[color=Blue]serout C.4[/color][color=Black],[/color][color=Blue]baud[/color][color=Black], [/color][color=Blue]([/color][color=Navy]$01[/color][color=Blue])  [/color][color=Green]'play first MP3[/color]
[color=Blue]pause [/color][color=Navy]1000[/color]
[color=Blue]do high light1
loop while [/color][color=Purple]busy [/color][color=DarkCyan]= [/color][color=Navy]0[/color]
[color=Blue]low light1


Do [/color][color=Black]: [/color][color=Blue]Loop Until [/color][color=Purple]PIR_2 [/color][color=DarkCyan]= [/color][color=Navy]1[/color]
[color=Blue]pause [/color][color=Navy]500[/color]
[color=Blue]serout C.4[/color][color=Black],[/color][color=Blue]baud[/color][color=Black], [/color][color=Blue]([/color][color=Navy]$02[/color][color=Blue])  [/color][color=Green]'play second MP3[/color]
[color=Blue]pause [/color][color=Navy]500[/color]
[color=Blue]do toggle light2
      pause [/color][color=Navy]500[/color]
[color=Blue]loop while [/color][color=Purple]busy [/color][color=DarkCyan]= [/color][color=Navy]0[/color]
[color=Blue]low light2

pause [/color][color=Navy]20000[/color]
[color=Blue]goto [/color][color=Black]main[/color]
 

PhilHornby

Senior Member
Here is my guess :-
Code:
[COLOR=blue]Pause [/COLOR][COLOR=navy]45000 [/COLOR][COLOR=green]'45 second wait time to allow the PIR to stabilize [/COLOR]
[COLOR=RED]HIGH C.4    [/COLOR][COLOR=red]'Set transmit line idle state correctly, rather than waiting for an initial Serout to do it.[/COLOR]
[COLOR=black]Main:[/COLOR]
 

tmfkam

Senior Member
The DfPlayer requires a more complex instruction than just the track number. Something like: serout MP3_Player_TX, t9600_16,($7E,$FF,$06,$0F,$00,$01,$02,$EF) 'Play track 2

The command needs to take into account the location (folder) of the tracks on the disk.

I think these modules are superb. I listen to one daily through my ancient valve radios and minature AM transmitter, very reliable and excellent sound quality through the line (headphone) out. Fab.
 

69-cat

Member
They are/were very easy to work with and stable. I have the Tenda boards as well but they are a bit too big for my project.
Dave
 

steliosm

Senior Member
DFPlayer mini is an excellent mp3 player and very easy to be use with a Picaxe. As Hippy said, the datashet for SPE035 has all the details you will need to use it. Not to mention that the price is pretty low for what it offers, that is if you get it from eBay.
 

69-cat

Member
I got it working! Since I have a working code, I still want to play with the hex stuff so I have better understanding what they do. I would like to thank ALL of you for your input !!!!!!!!!!
Dave
 

steliosm

Senior Member
There are not much things you can do with the hex stuff. What you can do is receive responses from the module, if you need that.
For the 'play' related commands, you just define a command id and its arguments and use the start and stop sequence for the command. Note, that the command's argument are passed as a double byte (w1) in MSB,LSB order.
e.g. To set the volume you define the command (0x06) and the volume level (0x17)
Code:
' Set the volume level
b0 = $06
w1 = $17 
serout tx_pin, baud, ($7E,$FF,$06,b0,$00,b3,b2,$EF)
 
Top