Is anyone controlling a DFPlayer Mini MP3 player with an ESP8266/ESP32 using ESPHome? It’s a small MP3 player board with an SD card slot that can be connected directly to a speaker and controlled via serial commands. For example, like this taken from an Arduino example:
My use case is to play pre-recorded messages like “Just a moment. I’ll be right there.” on an ESP32-cam based doorbell, triggered via an actionable Android notification.
Has anyone tackled this? Otherwise, any suggestions?
I have that module and I’m gonna take care of that feature if nobody does it first. I need some spare time. Like two weeks plus the esphome releases cycle.
Anyway if it is really that simple it should work with UART switch and you don’t have to write any C code.
The features I need for my use case are pretty limited. I think that the only commands I need are:
Specify tracking
Specify volume
Playback
Query the current status
Reset module
Of course, if someone really wanted to build an MP3 player, they would need many more.
Looking at that Arduino example I posted, I’m a bit confused as to what all is included. This could be totally wrong, but here’s what I think that I can work out:
0x7E - Start bit
0xFF - ?
0x06 - Specify volume
0x03 - Specify tracking
0x00 - Feedback = No
0x00 - [I think that this should be the volume; confusing that it is zero.]
0x0D - Track number 13
0xFE - Checksum?
0xEB - ?
0xEF - End bit
I am making my daughters play kitchen set more interactive. Right now i have lights for the playset’s fridge, oven, microwave that turn on/off when the doors are open controlled by led strip lights connected to an esp8266…thanks to ESPHome. I hope to install the led strips next week into the playset.
What I want to do next is add sound effects of a microwave running and “ding” when done, perhaps the sound of water when her hands get by the sink. Since I have the esp8266 already at the playset I wanted to get that to also play the sound effects.
Having fun with this, I hope to send a PR before weekend.
In case anyone is tinkering with this, I had to add a 10k pull down resistor between TX (Using D0) on ESP8266 and RX on DFPlayer Mini, otherwise it will not work at 3.3v.
Ahh yes I have done some progress.
I decided to partially support the component but not adding much magic to it, as the commands it accepts are very specific, there is no much to do, e.g.
there are commands to play a file, no mather the name
there are other commands to play files but you have to put then in numbered folders and then number the files inside the folders
the random didn’t make sense to me so far
volume works ok
the playback end notification triggers for every song being played, there are commands to play in loop, folders or files, but I did not test how they all work
So that’s why I decided to give the commands ‘as is’ and see what happens, but I still need to code some stuff and do the PR - go in code revision with Otto and fix stuff write docs, etc.
The good thing is I am pretty sure I know where to end, how to finish.
Well I’ve already sent a PR for dfplayer. However since it’s still in code review phase it is not available in the dev branch. Otto seems to be busy so I don’t know when this will happen.
Meanwhile you can test for sure:
One way to test is by creating a custom_components folders next to your yaml files, then inside a dfplayer folder and put the dfplayer files inside (init.py and the others)
Get the files and read the docs
Don’t forget to delete this folder once ESPHome ships dfplayer otherwise you’ll be always using this version