Hi everybody,
I am trying to get a dfplayer
module to work with ESPHome
. It seems to be connected and programmed correctly (for example, I get log output like TF Card available
when I insert one), but I cannot get it to play any audio.
However, when I manually initiate audio playback (by connecting GND
to the dfplayer
's IO_2
or IO_1
), it does play. So this makes me think that
- the speaker is connected correctly
- the size and file system of my SD card is correct
- the MP3 files have the appropriate encoding
It is connected like this (Wemos D1 Mini
powered via USB, but also tried an external power source, no difference):
Wemos D1 Mini | dfplayer |
---|---|
3V3 | VCC |
GND | GND |
D4 | TX |
D5 | RX |
The relevant part of my dfplayer.yaml
is at the bottom. The defined logger.log
message will be displayed when I manually initiate audio playback, so I assume the ESPHome does register things correctly as well. Only initiating playback won’t work. I tried it like this
service: esphome.tester_dfplayer_play
data:
file: 1 #or file: 001
# ==> [13:24:21][D][dfplayer:032]: Send Command 0x3 arg 0x01
service: esphome.tester_dfplayer_play_folder
data:
folder: 1 #or 01 or 001
file: 1 # or 01 or 001
# ==> [13:23:59][D][dfplayer:032]: Send Command 0xf arg 0x101
I tried the esphome.tester_dfplayer_next
service as well after manually initiating playback. This does not work, either (even though there are multiple MP3 files on the SD card).
So while I cannot control the dfplayer
module successfully via ESPHome, I can communicate with it via UART
, as it will display message when inserting/taking out an SD card and when playback has stopped after manually initiating it.
Only using Home Assistant to play/stop/change tracks does not work. Can you please help me fix this problem? Thank you in advance for your ideas
uart:
tx_pin: D4
rx_pin: D5
baud_rate: 9600
dfplayer:
on_finished_playback:
then:
logger.log: 'done!'
api:
services:
- service: dfplayer_next
then:
- dfplayer.play_next:
- service: dfplayer_previous
then:
- dfplayer.play_previous:
- service: dfplayer_play
variables:
file: int
then:
- dfplayer.play: !lambda 'return file;'
- service: dfplayer_play_loop
variables:
file: int
loop_: bool
then:
- dfplayer.play:
file: !lambda 'return file;'
loop: !lambda 'return loop_;'
- service: dfplayer_play_folder
variables:
folder: int
file: int
then:
- dfplayer.play_folder:
folder: !lambda 'return folder;'
file: !lambda 'return file;'
- service: dfplayer_play_loop_folder
variables:
folder: int
then:
- dfplayer.play_folder:
folder: !lambda 'return folder;'
loop: true
- service: dfplayer_set_device_tf
then:
- dfplayer.set_device: TF_CARD
- service: dfplayer_set_device_usb
then:
- dfplayer.set_device: USB
- service: dfplayer_set_volume
variables:
volume: int
then:
- dfplayer.set_volume: !lambda 'return volume;'
- service: dfplayer_set_eq
variables:
preset: int
then:
- dfplayer.set_eq: !lambda 'return static_cast<dfplayer::EqPreset>(preset);'
- service: dfplayer_sleep
then:
- dfplayer.sleep
- service: dfplayer_reset
then:
- dfplayer.reset
- service: dfplayer_start
then:
- dfplayer.start
- service: dfplayer_pause
then:
- dfplayer.pause
- service: dfplayer_stop
then:
- dfplayer.stop
- service: dfplayer_random
then:
- dfplayer.random
- service: dfplayer_volume_up
then:
- dfplayer.volume_up
- service: dfplayer_volume_down
then:
- dfplayer.volume_down