Can't get ESP32 and DFPlayer working

Can’t get any file to play (using random, play next, play folder, etc) - no sound and no logged event.

HARDWARE:

  • esp32 devkitv1
  • dfplayer mini hw-247a
  • 1GB SD card formatted MAC MS-DOS(FAT)
  • folder and mp3 files named as instructed on ESPHome
  • 2w 80ohm speaker

TROUBLESHOOTING:

  • changed IO pins
  • changed SD card
  • changed esp32, dfplayer boards, and speaker
  • wired directly to home assistant
  • set volume to 30

CONFIG:

esphome:
  name: esp32-chucky
  platform: ESP32
  board: esp32doit-devkit-v1

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "some_key"

  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

ota:
  password: "some_password"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32-Chucky Fallback Hotspot"
    password: "another_password"

captive_portal:

uart:
  tx_pin: GPIO14
  rx_pin: GPIO15
  baud_rate: 9600

dfplayer:
  on_finished_playback:
    then:
      logger.log: 'Playback finished event'

LOG AFTER WIRED INSTALL AND SENDING PLAY RANDOM:

INFO Successfully uploaded program.
INFO Starting log output from /dev/ttyUSB1 with baud rate 115200
[12:55:04][I][logger:258]: Log initialized
[12:55:04][C][ota:469]: There have been 0 suspected unsuccessful boot attempts.
[12:55:04][D][esp32.preferences:113]: Saving 1 preferences to flash...
[12:55:04][D][esp32.preferences:142]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[12:55:04][I][app:029]: Running through setup()...
[12:55:04][C][uart.arduino_esp32:077]: Setting up UART...
[12:55:04][    83][E][HardwareSerial.cpp:525] setRxBufferSize(): RX Buffer can't be resized when Serial is already running.
[12:55:04]
[12:55:04][C][wifi:037]: Setting up WiFi...
[12:55:04][C][wifi:038]:   Local MAC: some_mac
[12:55:04][D][wifi:386]: Starting scan...
[12:55:10][D][wifi:401]: Found networks:
ETC
[12:55:10][I][wifi:257]: WiFi Connecting to 'some_network'...
[12:55:11][I][wifi:518]: WiFi Connected!
ETC
[12:55:11][D][wifi:527]: Disabling AP...
[12:55:11][C][ota:093]: Over-The-Air Updates:
[12:55:11][C][ota:094]:   Address: esp32-chucky2.local:3232
[12:55:11][C][ota:097]:   Using Password.
[12:55:11][C][api:025]: Setting up Home Assistant API server...
[12:55:11][I][app:062]: setup() finished successfully!
[12:55:11][I][app:102]: ESPHome version 2022.12.1 compiled on Jan 11 2023, 12:54:37
ETC
[12:55:11][C][logger:293]: Logger:
[12:55:11][C][logger:294]:   Level: DEBUG
[12:55:11][C][logger:295]:   Log Baud Rate: 115200
[12:55:11][C][logger:296]:   Hardware UART: UART0
[12:55:11][C][uart.arduino_esp32:108]: UART Bus 1:
[12:55:11][C][uart.arduino_esp32:109]:   TX Pin: GPIO14
[12:55:11][C][uart.arduino_esp32:110]:   RX Pin: GPIO15
[12:55:11][C][uart.arduino_esp32:112]:   RX Buffer Size: 256
[12:55:11][C][uart.arduino_esp32:114]:   Baud Rate: 9600 baud
[12:55:11][C][uart.arduino_esp32:115]:   Data Bits: 8
[12:55:11][C][uart.arduino_esp32:116]:   Parity: NONE
[12:55:11][C][uart.arduino_esp32:117]:   Stop bits: 1
[12:55:11][C][dfplayer:127]: DFPlayer:
[12:55:11][C][captive_portal:088]: Captive Portal:
[12:55:11][C][mdns:103]: mDNS:
[12:55:11][C][mdns:104]:   Hostname: esp32-chucky2
[12:55:11][C][ota:093]: Over-The-Air Updates:
[12:55:11][C][ota:094]:   Address: esp32-chucky2.local:3232
[12:55:11][C][ota:097]:   Using Password.
[12:55:11][C][api:138]: API Server:
[12:55:11][C][api:139]:   Address: esp32-chucky2.local:6053
[12:55:11][C][api:141]:   Using noise encryption: YES
[12:55:12][D][api:102]: Accepted ::FFFF:some_ip_address
[12:55:12][D][api.connection:918]: Home Assistant 2023.1.2 (::FFFF: some_ip_address): Connected successfully
[12:59:04][D][dfplayer:032]: Send Command 0x18 arg 0000
[13:00:04][I][ota:113]: Boot seems successful, resetting boot loop counter.
[13:00:04][D][esp32.preferences:113]: Saving 1 preferences to flash...
[13:00:04][D][esp32.preferences:142]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed

Ran into an issue using the latest version 2022.12.7 and had the same error in the logs

12:55:04][    83][E][HardwareSerial.cpp:525] setRxBufferSize(): RX Buffer can't be resized when Serial is already running.

For me this was resolved by changing to esp-idf framework. Might be something to try?

I believe removing this

esphome:
  name: esp32-chucky
  platform: ESP32
  board: esp32doit-devkit-v1

and inserting this in it’s place will be all that is necessary to try esp-idf. There might be some other config changes necessary, check the ESPHome config UI for any other errors/changes.

esphome:
  name: esp32-chucky

esp32:
  board: esp32doit-devkit-v1
  framework:
    type: esp-idf

I have the same issue, changing the framework is not an option when using library’s from Arduino unfortunately.