Pls help with i2s media player

Hi everybody,

I have an ESP32-WROOM-32 set up like this (wiring image at the bottom); only relevant parts, I cropped out wifi etc.

esp32:
  board: esp32dev
  framework:
    type: arduino


i2s_audio:
  id: testy
  i2s_lrclk_pin: 9 #GPIO25
  i2s_bclk_pin: 10 #GPIO26

media_player:
 - platform: i2s_audio
   name: ESPHome I2S Media Player
   dac_type: external
   i2s_audio_id: testy
   i2s_dout_pin: 12 #GPIO14
   mode: mono

### ---> I've found this part when searching for i2s audio issues:
   on_pause:
     - media_player.stop

This is the output I receive when playing an audio file; I specifically chose a very short (<2sec) WAVE audio file hosted on my HASS server. Other media players in my network play this without issues.

[13:07:55][I][app:100]: ESPHome version 2024.5.5 compiled on Jun 15 2024, 13:07:22
[13:07:55][C][wifi:580]: WiFi:
[13:07:55][C][wifi:408]:   Local MAC: 08:B6:1F:29:90:C8
[13:07:55][C][wifi:413]:   SSID: [redacted]
[13:07:55][C][wifi:416]:   IP Address: 10.0.20.250
[13:07:55][C][wifi:420]:   BSSID: [redacted]
[13:07:55][C][wifi:421]:   Hostname: 'i2saudiotest'
[13:07:55][C][wifi:423]:   Signal strength: -73 dB ▂▄▆█
[13:07:55][C][wifi:427]:   Channel: 6
[13:07:55][C][wifi:428]:   Subnet: 255.255.255.0
[13:07:55][C][wifi:429]:   Gateway: 10.0.20.1
[13:07:55][C][wifi:430]:   DNS1: 10.0.20.1
[13:07:55][C][wifi:431]:   DNS2: 0.0.0.0
[13:07:55][C][logger:185]: Logger:
[13:07:55][C][logger:186]:   Level: DEBUG
[13:07:55][C][logger:188]:   Log Baud Rate: 115200
[13:07:55][C][logger:189]:   Hardware UART: UART0
[13:07:55][C][mdns:115]: mDNS:
[13:07:55][C][mdns:116]:   Hostname: i2saudiotest
[13:07:55][C][ota:096]: Over-The-Air Updates:
[13:07:55][C][ota:097]:   Address: i2saudiotest.local:3232
[13:07:55][C][ota:103]:   OTA version: 2.
[13:07:55][C][api:139]: API Server:
[13:07:55][C][api:140]:   Address: i2saudiotest.local:6053
[13:07:55][C][api:142]:   Using noise encryption: YES
[13:07:55][C][audio:214]: Audio:
[13:07:55][C][audio:236]:   External DAC channels: 1
[13:07:55][C][audio:237]:   I2S DOUT Pin: 12
[13:07:55][D][api:102]: Accepted 10.0.0.25
[13:07:55][D][api.connection:1321]: Home Assistant 2024.6.2 (10.0.0.25): Connected successfully
[13:08:05][D][media_player:061]: 'ESPHome I2S Media Player' - Setting
[13:08:05][D][media_player:068]:   Media URL: http://hass.local:8123/media/local/frosch.wav?authSig=eyJhbGciOiJIUzI1NiIsInR5cCI6.....................
WARNING i2saudiotest @ 10.0.20.250: Connection error occurred: [Errno 104] Connection reset by peer
INFO Processing unexpected disconnect from ESPHome API for i2saudiotest @ 10.0.20.250
WARNING Disconnected from API
INFO Successfully connected to i2saudiotest @ 10.0.20.250 in 0.006s
INFO Successful handshake with i2saudiotest @ 10.0.20.250 in 0.095s

Wiring is as follows

color ESP32 i²s board speaker
WHITE GPIO25 LRC x
PURPLE GPIO26 BCLK x
BLUE GPIO14 SD x
GREEN GND GND x
YELLOW VIN V5 x
RED x + +
BLACK x - -

It seems like the board crashes / reboots when I try to play media. Can you please tell me what I did wrong and/or what to do in order to fix this? Thank you in advance for your help :slight_smile:

Hi!
I have the same problem with a “az-delivery-devkit-v4” module (https://mischianti.org/esp32-devkitc-v4-high-resolution-pinout-and-specs/)
My setup is as follows:
ESP32-------MAX98357A
GPIO26------LRC
GPIO25------BCLK
GPIO22------DIN
GND----------GND
+5V------------Vin

GPIO17-------Relay module

When I try to play any media, the ESP32 reboots, even without the MAX98357 module connected. I didn’t have any problems with the internal DAC. Switched to external due to poor sound quality. I did some tests with different pins but no difference.
Has anyone managed to use esp32 with external i2s DAC?

Yaml file:

substitutions:
  name: esphome-web-13dcc8
  friendly_name: Access control

esphome:
  name: ${name}
  friendly_name: ${friendly_name}
  name_add_mac_suffix: false
  project:
    name: esphome.web
    version: '1.0'
  on_boot:
  - priority: 600 #This is where most sensors are set up.
    then:
    - switch.turn_on: Lamp
  - priority: -100 #At this priority, pretty much everything should already be initialized.
    then:
    - switch.turn_off: Lamp

esp32:
  board: az-delivery-devkit-v4
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: isD1UEPV78Fcf2ZVJRv09pROfJRkbnG1CuzLkWc4D90=
# Allow Over-The-Air updates
ota:

# Allow provisioning Wi-Fi via serial
improv_serial:

wifi:
  ap: {}

captive_portal:

dashboard_import:
  package_import_url: github://esphome/example-configs/esphome-web/esp32.yaml@main
  import_full_config: true

# web_server:


i2s_audio:
  - id: i2s_in
    i2s_lrclk_pin: GPIO26 
    i2s_bclk_pin: GPIO25 

media_player:
  - platform: i2s_audio
    name: "WindFang Media Player"
    id: media_player_speaker
    i2s_audio_id: i2s_in
    dac_type: external
    i2s_dout_pin: GPIO22
    mode: mono

switch:
  - platform: gpio
    name: "Lamp"
    id: "Lamp"
    pin: GPIO17
    inverted: True

My log:

[D][api.connection:1321]: Home Assistant 2024.6.2 (192.168.68.117): Connected successfully
[D][media_player:061]: 'WindFang Media Player' - Setting
[D][media_player:068]:   Media URL: http://172.30.32.1:8123/api/tts_proxy/69342c5c39e5ae5f0077aecc32c0f81811fb8193_en_-_tts.google_en_com.mp3
[D][media_player:074]:  Announcement: yes
E (1517347) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (1517347) task_wdt:  - loopTask (CPU 1)
E (1517347) task_wdt: Tasks currently running:
E (1517347) task_wdt: CPU 0: IDLE
E (1517347) task_wdt: CPU 1: IDLE
E (1517347) task_wdt: Aborting.

abort() was called at PC 0x4010bd60 on core 0


Backtrace:0x40083925:0x3ffbe9dc |<-CORRUPTED




ELF file SHA256: 0000000000000000

Rebooting...
ets Jul 29 2019 12:21:46

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13132
load:0x40080400,len:3036
entry 0x400805e4
[I][logger:156]: Log initialized
[C][ota:483]: There have been 0 suspected unsuccessful boot attempts.
[D][esp32.preferences:114]: Saving 1 preferences to flash...
[D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[I][app:029]: Running through setup()...
[C][switch.gpio:011]: Setting up GPIO Switch 'Lamp'...
[D][switch:016]: 'Lamp' Turning OFF.
[D][switch:055]: 'Lamp': Sending state OFF
[D][switch:016]: 'Lamp' Turning OFF.
[D][switch:012]: 'Lamp' Turning ON.
[D][switch:055]: 'Lamp': Sending state ON
[C][i2s_audio:024]: Setting up I2S Audio...
[C][wifi:038]: Setting up WiFi...
[C][wifi:051]: Starting WiFi...
[C][wifi:052]:   Local MAC: D0:EF:76:13:DC:C8

Has anybody else encountered this issue and perhaps found a solution? It is kinda disappointing having bought this supported hardware and just realizing it doesn’t actually work when trying to build a project.

I haven’t encountered this issue. It works fine for me on an ESP32-nodemcu and a max98357a with the following config:

i2s_audio:
  i2s_lrclk_pin: GPIO25
  i2s_bclk_pin: GPIO26

media_player:
  - platform: i2s_audio
    name: Player
    dac_type: external
    i2s_dout_pin: GPIO27
    mode: mono

I also have it working on an esp32-s3-devkitc-1

i2s_audio:
  i2s_lrclk_pin: GPIO6
  i2s_bclk_pin: GPIO20

media_player:
  - platform: i2s_audio
    name: Player
    dac_type: external
    i2s_dout_pin: GPIO8
    mode: mono

You seem to be missing connection on the Din pin from Dout on the esp32