I²S DAC and ESP32 - media player crashes ESP32

Hello,

I’m having trouble getting a MAX98357A I²S amp to play audio on an ESP-WROOM-32D. Whenever I send it an MP3 file, the task hangs and the watchdog times out, resetting the ESP.

Since my hardware is working fine - I can run the DFrobot bluetoothAmplifier Arduino example without issue - I’m stumped as to what could be causing this problem.

I’ve tried playing various simple MP3 and WAV files from Home Assistant using a Media Player entity, but each time the ESP32 hangs before successfully completing playback. I’m at a loss for how to debug this further. Any guidance or suggestions would be much appreciated!

My esphome code:

esphome:
  name: esp-266  

esp32:
  board: nodemcu-32s
  framework:
    type: arduino

logger:
#  level: VERBOSE
  level: VERY_VERBOSE
#  level: DEBUG

# Enable Home Assistant API
api:
  encryption:
    key: !secret api_key

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_pwd
  use_address: ${devicename}.local
#  fast_connect: on
  domain: .local  
  power_save_mode: none

  
i2s_audio:
  - id: i2s_out
    i2s_lrclk_pin: 26
    i2s_bclk_pin: 25

media_player:
  - platform: i2s_audio
    name: ESPHome I2S Media Player
    id: ESPHome_media_player_speaker
    dac_type: external
    i2s_audio_id: i2s_out
    i2s_dout_pin: 27
    mode: mono

Compile and install logs:

C:\Users\dsm\Documents\esphome>esphome run "ESPHome ESP-266 MAX98357A I²S amp.yaml"
INFO ESPHome 2023.10.3
INFO Reading configuration ESPHome ESP-266 MAX98357A I²S amp.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing esp-266 (board: nodemcu-32s; framework: arduino; platform: platformio/[email protected])
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/nodemcu-32s.html
PLATFORM: Espressif 32 (5.4.0) > NodeMCU-32S
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 @ 3.20005.220925 (2.0.5)
 - tool-esptoolpy @ 1.40400.0 (4.4.0)
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ off, Compatibility ~ soft
Found 35 compatible libraries
Scanning dependencies...
Dependency Graph
|-- WiFi @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- noise-c @ 0.1.4
|-- WiFiClientSecure @ 2.0.0
|-- HTTPClient @ 2.0.0
|-- ESP32-audioI2S @ 2.0.7
Building in release mode
Compiling .pioenvs\esp-266\src\main.cpp.o
Linking .pioenvs\esp-266\firmware.elf
Retrieving maximum program size .pioenvs\esp-266\firmware.elf
Checking size .pioenvs\esp-266\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [=         ]  13.0% (used 42612 bytes from 327680 bytes)
Flash: [======    ]  64.5% (used 1183561 bytes from 1835008 bytes)
Building .pioenvs\esp-266\firmware.bin
esptool.py v4.4
Creating esp32 image...
Merged 25 ELF sections
Successfully created esp32 image.
esp32_create_combined_bin([".pioenvs\esp-266\firmware.bin"], [".pioenvs\esp-266\firmware.elf"])
esptool.py v4.6.2
Wrote 0x1325d0 bytes to file C:\Users\dsm\Documents\esphome\.esphome\build\esp-266\.pioenvs\esp-266/firmware-factory.bin, ready to flash to offset 0x0
========================================================================================== [SUCCESS] Took 16.90 seconds ==========================================================================================
INFO Successfully compiled program.
Found multiple options for uploading, please choose one:
  [1] COM6 (USB Serial Port (COM6))
  [2] Over The Air (${devicename}.local)
(number): 1
esptool.py v4.6.2
Serial port COM6
Connecting......
Chip is ESP32-D0WD (revision v1.0)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None
Crystal is 40MHz
MAC: a8:48:fa:94:3a:14
Uploading stub...
Running stub...
Stub running...
Changing baud rate to 460800
Changed.
Configuring flash size...
Auto-detected Flash size: 16MB
Flash will be erased from 0x00010000 to 0x00132fff...
Flash will be erased from 0x00001000 to 0x00005fff...
Flash will be erased from 0x00008000 to 0x00008fff...
Flash will be erased from 0x0000e000 to 0x0000ffff...
Compressed 1189328 bytes to 786306...
Wrote 1189328 bytes (786306 compressed) at 0x00010000 in 18.6 seconds (effective 511.7 kbit/s)...
Hash of data verified.
Warning: Image file at 0x1000 is protected with a hash checksum, so not changing the flash size setting. Use the --flash_size=keep option instead of --flash_size=16MB in order to remove this warning, or use the --dont-append-digest option for the elf2image command in order to generate an image file without a hash checksum
Compressed 17440 bytes to 12128...
Wrote 17440 bytes (12128 compressed) at 0x00001000 in 0.5 seconds (effective 264.0 kbit/s)...
Hash of data verified.
Compressed 3072 bytes to 144...
Wrote 3072 bytes (144 compressed) at 0x00008000 in 0.1 seconds (effective 387.3 kbit/s)...
Hash of data verified.
Compressed 8192 bytes to 47...
Wrote 8192 bytes (47 compressed) at 0x0000e000 in 0.1 seconds (effective 693.6 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
INFO Successfully uploaded program.
INFO Starting log output from COM6 with baud rate 115200

Running the code:

[18:36:28]ets Jun  8 2016 00:22:57
[18:36:28]
[18:36:28]rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
[18:36:28]configsip: 0, SPIWP:0xee
[18:36:28]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
[18:36:28]mode:DIO, clock div:2
[18:36:28]load:0x3fff0030,len:1184
[18:36:28]load:0x40078000,len:13132
[18:36:28]load:0x40080400,len:3036
[18:36:28]entry 0x400805e4
[18:36:29][     6][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
[18:36:29][I][logger:326]: Log initialized
[18:36:29][I][app:029]: Running through setup()...
[18:36:29][V][app:030]: Sorting components by setup priority...
[18:36:29][VV][scheduler:063]: set_interval(name='', interval=60000, offset=13480)
[18:36:29][C][i2s_audio:024]: Setting up I2S Audio...
[18:36:29][C][wifi:038]: Setting up WiFi...
[18:36:29][C][wifi:051]: Starting WiFi...
[18:36:29][C][wifi:052]:   Local MAC: A8:48:FA:94:3A:14
[18:36:29][V][esp32.preferences:059]: nvs_get_blob('2610565746'): ESP_ERR_NVS_NOT_FOUND - the key might not be set yet
[18:36:29][V][wifi_esp32:039]: Enabling STA.
[18:36:29][   107][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 0 - WIFI_READY
[18:36:29][V][wifi_esp32:417]: Event: WiFi ready
[18:36:29][   200][V][WiFiGeneric.cpp:338] _arduino_event_cb(): STA Started
[18:36:29][   201][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 2 - STA_START
[18:36:29][V][wifi_esp32:428]: Event: WiFi STA start
[18:36:29][VV][scheduler:226]: Running interval '' with interval=60000 last_execution=4294893868 (now=213)
[18:36:35][  6024][V][WiFiGeneric.cpp:381] _arduino_event_cb(): SCAN Done: ID: 128, Status: 0, Results: 8
[18:36:35][  6024][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 1 - SCAN_DONE
[18:36:35][V][wifi_esp32:422]: Event: WiFi Scan Done status=0 number=8 scan_id=128
[18:36:35][D][wifi:443]: Found networks:
[18:36:35][I][wifi:487]: - 'wifiSSID' (0C:72:74:DD:AC:25) ▂▄▆█
[18:36:35][D][wifi:488]:     Channel: 6
[18:36:35][D][wifi:489]:     RSSI: -64 dB
[18:36:35][I][wifi:487]: - 'wifiSSID' (74:42:7F:39:EA:31) ▂▄▆█
[18:36:35][D][wifi:488]:     Channel: 11
[18:36:35][D][wifi:489]:     RSSI: -76 dB
[18:36:35][I][wifi:487]: - 'wifiSSID' (50:E6:36:17:32:08) ▂▄▆█
[18:36:35][D][wifi:488]:     Channel: 11
[18:36:35][D][wifi:489]:     RSSI: -79 dB
[18:36:35][I][wifi:277]: WiFi Connecting to 'wifiSSID'...
[18:36:35][V][wifi:279]: Connection Params:
[18:36:35][V][wifi:280]:   SSID: 'wifiSSID'
[18:36:35][V][wifi:283]:   BSSID: 0C:72:74:DD:AC:25
[18:36:35][V][wifi:303]:   Password: 'wifipassword'
[18:36:35][V][wifi:308]:   Channel: 6
[18:36:35][V][wifi:317]:   Using DHCP IP
[18:36:35][V][wifi:319]:   Hidden: NO
[18:36:36][  6855][V][WiFiGeneric.cpp:353] _arduino_event_cb(): STA Connected: SSID: wifiSSID, BSSID: 0c:72:74:dd:ac:25, Channel: 6, Auth: WPA2_PSK
[18:36:36][  6857][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 4 - STA_CONNECTED
[18:36:36][V][wifi_esp32:442]: Event: Connected ssid='wifiSSID' bssid=0C:72:74:DD:AC:25 channel=6, authmode=WPA2 PSK
[18:36:36][  6875][V][WiFiGeneric.cpp:367] _arduino_event_cb(): STA Got New IP:192.168.1.95
[18:36:36][  6886][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
[18:36:36][  6891][D][WiFiGeneric.cpp:991] _eventCallback(): STA IP: 192.168.1.95, MASK: 255.255.255.0, GW: 192.168.1.1
[18:36:36][V][wifi_esp32:496]: Event: Got IP static_ip=192.168.1.95 gateway=192.168.1.1
[18:36:36][I][app:102]: ESPHome version 2023.10.3 compiled on Aug 24 2024, 18:35:05
[18:36:36][C][wifi:546]: WiFi:
[18:36:36][C][wifi:382]:   Local MAC: A8:48:FA:94:3A:14
[18:36:36][C][wifi:383]:   SSID: 'wifiSSID'
[18:36:36][C][wifi:384]:   IP Address: 192.168.1.95
[18:36:36][C][wifi:386]:   BSSID: 0C:72:74:DD:AC:25
[18:36:36][C][wifi:387]:   Hostname: 'esp-266'
[18:36:36][C][wifi:389]:   Signal strength: -63 dB ▂▄▆█
[18:36:36][V][wifi:391]:   Priority: 0.0
[18:36:36][C][wifi:393]:   Channel: 6
[18:36:36][C][wifi:394]:   Subnet: 255.255.255.0
[18:36:36][C][wifi:395]:   Gateway: 192.168.1.1
[18:36:36][C][wifi:396]:   DNS1: 192.168.1.1
[18:36:36][C][wifi:397]:   DNS2: 0.0.0.0
[18:36:36][C][logger:416]: Logger:
[18:36:36][C][logger:417]:   Level: VERY_VERBOSE
[18:36:36][C][logger:418]:   Log Baud Rate: 115200
[18:36:36][C][logger:420]:   Hardware UART: UART0
[18:36:36][C][mdns:115]: mDNS:
[18:36:36][C][mdns:116]:   Hostname: esp-266
[18:36:36][V][mdns:117]:   Services:
[18:36:36][V][mdns:119]:   - _esphomelib, _tcp, 6053
[18:36:36][V][mdns:121]:     TXT: version = 2023.10.3
[18:36:36][V][mdns:121]:     TXT: mac = a848fa943a14
[18:36:36][V][mdns:121]:     TXT: platform = ESP32
[18:36:36][V][mdns:121]:     TXT: board = nodemcu-32s
[18:36:36][V][mdns:121]:     TXT: network = wifi
[18:36:36][V][mdns:121]:     TXT: api_encryption = Noise_NNpsk0_25519_ChaChaPoly_SHA256
[18:36:36][C][api:138]: API Server:
[18:36:36][C][api:139]:   Address: ${devicename}.local:6053
[18:36:36][C][api:141]:   Using noise encryption: YES
[18:36:36][C][audio:203]: Audio:
[18:36:36][C][audio:225]:   External DAC channels: 1
[18:36:36][C][audio:226]:   I2S DOUT Pin: 27
[18:36:37][D][api:102]: Accepted 192.168.1.199
[18:36:37][VV][api.socket:696]: 192.168.1.199: Handshake complete!
[18:36:37][VV][api.service:504]: on_hello_request: HelloRequest {
[18:36:37]  client_info: 'Home Assistant 2024.8.2'
[18:36:37]  api_version_major: 1
[18:36:37]  api_version_minor: 10
[18:36:37]}
[18:36:37][V][api.connection:1014]: Hello from client: 'Home Assistant 2024.8.2 (192.168.1.199)' | API Version 1.10
[18:36:37][VV][api.service:013]: send_hello_response: HelloResponse {
[18:36:37]  api_version_major: 1
[18:36:37]  api_version_minor: 9
[18:36:37]  server_info: 'esp-266 (esphome v2023.10.3)'
[18:36:37]  name: 'esp-266'
[18:36:37]}
[18:36:37][VV][api.service:513]: on_connect_request: ConnectRequest {
[18:36:37]  password: ''
[18:36:37]}
[18:36:37][D][api.connection:1032]: Home Assistant 2024.8.2 (192.168.1.199): Connected successfully
[18:36:37][VV][api.service:019]: send_connect_response: ConnectResponse {
[18:36:37]  invalid_password: NO
[18:36:37]}
[18:36:37][VV][api.service:558]: on_device_info_request: DeviceInfoRequest {}
[18:36:37][VV][api.service:049]: send_device_info_response: DeviceInfoResponse {
[18:36:37]  uses_password: NO
[18:36:37]  name: 'esp-266'
[18:36:37]  mac_address: 'A8:48:FA:94:3A:14'
[18:36:37]  esphome_version: '2023.10.3'
[18:36:37]  compilation_time: 'Aug 24 2024, 18:35:05'
[18:36:37]  model: 'nodemcu-32s'
[18:36:37]  has_deep_sleep: NO
[18:36:37]  project_name: ''
[18:36:37]  project_version: ''
[18:36:37]  webserver_port: 0
[18:36:37]  legacy_bluetooth_proxy_version: 0
[18:36:37]  bluetooth_proxy_feature_flags: 0
[18:36:37]  manufacturer: 'Espressif'
[18:36:37]  friendly_name: ''
[18:36:37]  voice_assistant_version: 0
[18:36:37]}
[18:36:37][VV][api.service:567]: on_list_entities_request: ListEntitiesRequest {}
[18:36:37][VV][api.service:316]: send_list_entities_media_player_response: ListEntitiesMediaPlayerResponse {
[18:36:37]  object_id: 'esphome_i2s_media_player'
[18:36:37]  key: 3210548230
[18:36:37]  name: 'ESPHome I2S Media Player'
[18:36:37]  unique_id: 'esp-266media_playeresphome_i2s_media_player'
[18:36:37]  icon: ''
[18:36:37]  disabled_by_default: NO
[18:36:37]  entity_category: ENTITY_CATEGORY_NONE
[18:36:37]  supports_pause: YES
[18:36:37]}
[18:36:37][VV][api.service:055]: send_list_entities_done_response: ListEntitiesDoneResponse {}
[18:36:37][VV][api.service:576]: on_subscribe_states_request: SubscribeStatesRequest {}
[18:36:37][VV][api.service:638]: on_subscribe_homeassistant_services_request: SubscribeHomeassistantServicesRequest {}
[18:36:37][VV][api.service:665]: on_subscribe_home_assistant_states_request: SubscribeHomeAssistantStatesRequest {}
[18:36:37][VV][api.service:324]: send_media_player_state_response: MediaPlayerStateResponse {
[18:36:37]  key: 3210548230
[18:36:37]  state: MEDIA_PLAYER_STATE_IDLE
[18:36:37]  volume: 1
[18:36:37]  muted: NO
[18:36:37]}

-> Media player PLAY action gets triggered here from Home Assistant

[18:36:45][VV][api.service:759]: on_media_player_command_request: MediaPlayerCommandRequest {
[18:36:45]  key: 3210548230
[18:36:45]  has_command: NO
[18:36:45]  command: MEDIA_PLAYER_COMMAND_PLAY
[18:36:45]  has_volume: NO
[18:36:45]  volume: 0
[18:36:45]  has_media_url: YES
[18:36:45]  media_url: 'https://myHAservername.org:8123/media/local/test.mp3?authSig=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIxYzAwN2UyNjNjZjY0OThiYWM0ODg2NTRkNzIwMjAzYiIsInBhdGgiOiIvbWVkaWEvbG9jYWwvR29sZGJhbmQgTm9vZGdldmFsIC0ga29ydC5tcDMiLCJwYXJhbXMiOltdLCJpYXQiOjE3MjQ
[18:36:45][D][media_player:059]: 'ESPHome I2S Media Player' - Setting
[18:36:45][D][media_player:066]:   Media URL: https://myHAservername.org:8123/media/local/test.mp3?authSig=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiIxYzAwN2UyNjNjZjY0OThiYWM0ODg2NTRkNzIwMjAzYiIsInBhdGgiOiIvbWVkaWEvbG9jYWwvR29sZGJhbmQgTm9vZGdldmFsIC0ga29ydC5tcDMiLCJwYXJhbXMiOltdLCJpYXQiOjE3MjQ1MTc0MDUsImV4cCI6MTcyNDYwMzgwNX0.mSTcRgyiAvdDu6_JUOsYyIHCwRxivQIBiPJOxI_jzzc
[18:36:45][W][component:214]: Component api took a long time for an operation (0.09 s).
[18:36:45][W][component:215]: Components should block for at most 20-30ms.
[18:36:45][ 16703][V][ssl_client.cpp:324] stop_ssl_socket(): Cleaning SSL connection.
[18:36:46][ 17216][V][ssl_client.cpp:62] start_ssl_client(): Free internal heap before TLS 181428
[18:36:46][ 17216][V][ssl_client.cpp:68] start_ssl_client(): Starting socket
[18:36:51]E (25818) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
[18:36:51]E (25818) task_wdt:  - loopTask (CPU 1)
[18:36:51]E (25818) task_wdt: Tasks currently running:
[18:36:51]E (25818) task_wdt: CPU 0: IDLE
[18:36:51]E (25818) task_wdt: CPU 1: IDLE
[18:36:51]E (25818) task_wdt: Aborting.
[18:36:51]
[18:36:51]abort() was called at PC 0x40104f84 on core 0
[18:36:51]
[18:36:51]
[18:36:51]Backtrace:0x40083811:0x3ffbeaec |<-CORRUPTED
WARNING Found stack trace! Trying to decode it
WARNING Decoded 0x40083811: panic_abort at /Users/ficeto/Desktop/ESP32/ESP32S2/esp-idf-public/components/esp_system/panic.c:402
[18:36:51]
[18:36:51]
[18:36:51]
[18:36:51]
[18:36:51]ELF file SHA256: 0000000000000000
[18:36:51]
[18:36:51]Rebooting...
[18:36:51]ets Jun  8 2016 00:22:57
[18:36:51]
[18:36:51]rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
[18:36:51]configsip: 0, SPIWP:0xee
[18:36:51]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
[18:36:51]mode:DIO, clock div:2
[18:36:51]load:0x3fff0030,len:1184
[18:36:51]load:0x40078000,len:13132
[18:36:51]load:0x40080400,len:3036
[18:36:51]entry 0x400805e4
[18:36:51][     6][D][esp32-hal-cpu.c:244] setCpuFrequencyMhz(): PLL: 480 / 2 = 240 Mhz, APB: 80000000 Hz
[18:36:51][I][logger:326]: Log initialized
[18:36:51][I][app:029]: Running through setup()...
[18:36:51][V][app:030]: Sorting components by setup priority...
[18:36:51][VV][scheduler:063]: set_interval(name='', interval=60000, offset=9281)
[18:36:51][C][i2s_audio:024]: Setting up I2S Audio...
[18:36:51][C][wifi:038]: Setting up WiFi...
[18:36:51][C][wifi:051]: Starting WiFi...
[18:36:51][C][wifi:052]:   Local MAC: A8:48:FA:94:3A:14
[18:36:51][V][esp32.preferences:059]: nvs_get_blob('2610565746'): ESP_ERR_NVS_NOT_FOUND - the key might not be set yet
[18:36:51][V][wifi_esp32:039]: Enabling STA.
[18:36:51][   107][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 0 - WIFI_READY
[18:36:51][V][wifi_esp32:417]: Event: WiFi ready
[18:36:51][   198][V][WiFiGeneric.cpp:338] _arduino_event_cb(): STA Started
[18:36:51][   198][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 2 - STA_START
[18:36:51][V][wifi_esp32:428]: Event: WiFi STA start
[18:36:57][  6020][V][WiFiGeneric.cpp:381] _arduino_event_cb(): SCAN Done: ID: 128, Status: 0, Results: 8
[18:36:57][  6021][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 1 - SCAN_DONE
[18:36:57][V][wifi_esp32:422]: Event: WiFi Scan Done status=0 number=8 scan_id=128
[18:36:57][D][wifi:443]: Found networks:
[18:36:57][I][wifi:487]: - 'wifiSSID' (0C:72:74:DD:AC:25) ▂▄▆█
[18:36:57][D][wifi:488]:     Channel: 6
[18:36:57][D][wifi:489]:     RSSI: -62 dB
[18:36:57][I][wifi:487]: - 'wifiSSID' (74:42:7F:39:EA:31) ▂▄▆█
[18:36:57][D][wifi:488]:     Channel: 11
[18:36:57][D][wifi:489]:     RSSI: -78 dB
[18:36:57][I][wifi:487]: - 'wifiSSID' (50:E6:36:17:32:08) ▂▄▆█
[18:36:57][D][wifi:488]:     Channel: 11
[18:36:57][D][wifi:489]:     RSSI: -80 dB
[18:36:57][I][wifi:277]: WiFi Connecting to 'wifiSSID'...
[18:36:57][V][wifi:279]: Connection Params:
[18:36:57][V][wifi:280]:   SSID: 'wifiSSID'
[18:36:57][V][wifi:283]:   BSSID: 0C:72:74:DD:AC:25
[18:36:57][V][wifi:303]:   Password: 'wifipassword'
[18:36:57][V][wifi:308]:   Channel: 6
[18:36:57][V][wifi:317]:   Using DHCP IP
[18:36:57][V][wifi:319]:   Hidden: NO
[18:36:58][  6857][V][WiFiGeneric.cpp:353] _arduino_event_cb(): STA Connected: SSID: wifiSSID, BSSID: 0c:72:74:dd:ac:25, Channel: 6, Auth: WPA2_PSK
[18:36:58][  6859][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 4 - STA_CONNECTED
[18:36:58][V][wifi_esp32:442]: Event: Connected ssid='wifiSSID' bssid=0C:72:74:DD:AC:25 channel=6, authmode=WPA2 PSK
[18:36:58][  6877][V][WiFiGeneric.cpp:367] _arduino_event_cb(): STA Got New IP:192.168.1.95
[18:36:58][  6888][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
[18:36:58][  6892][D][WiFiGeneric.cpp:991] _eventCallback(): STA IP: 192.168.1.95, MASK: 255.255.255.0, GW: 192.168.1.1
[18:36:58][V][wifi_esp32:496]: Event: Got IP static_ip=192.168.1.95 gateway=192.168.1.1
[18:36:58][I][app:102]: ESPHome version 2023.10.3 compiled on Aug 24 2024, 18:35:05
[18:36:58][C][wifi:546]: WiFi:
[18:36:58][C][wifi:382]:   Local MAC: A8:48:FA:94:3A:14
[18:36:58][C][wifi:383]:   SSID: 'wifiSSID'
[18:36:58][C][wifi:384]:   IP Address: 192.168.1.95
[18:36:58][C][wifi:386]:   BSSID: 0C:72:74:DD:AC:25
[18:36:58][C][wifi:387]:   Hostname: 'esp-266'
[18:36:58][C][wifi:389]:   Signal strength: -64 dB ▂▄▆█
[18:36:58][V][wifi:391]:   Priority: 0.0
[18:36:58][C][wifi:393]:   Channel: 6
[18:36:58][C][wifi:394]:   Subnet: 255.255.255.0
[18:36:58][C][wifi:395]:   Gateway: 192.168.1.1
[18:36:58][C][wifi:396]:   DNS1: 192.168.1.1
[18:36:58][C][wifi:397]:   DNS2: 0.0.0.0
[18:36:58][C][logger:416]: Logger:
[18:36:58][C][logger:417]:   Level: VERY_VERBOSE
[18:36:58][C][logger:418]:   Log Baud Rate: 115200
[18:36:58][C][logger:420]:   Hardware UART: UART0
[18:36:58][C][mdns:115]: mDNS:
[18:36:58][C][mdns:116]:   Hostname: esp-266
[18:36:58][V][mdns:117]:   Services:
[18:36:58][V][mdns:119]:   - _esphomelib, _tcp, 6053
[18:36:58][V][mdns:121]:     TXT: version = 2023.10.3
[18:36:58][V][mdns:121]:     TXT: mac = a848fa943a14
[18:36:58][V][mdns:121]:     TXT: platform = ESP32
[18:36:58][V][mdns:121]:     TXT: board = nodemcu-32s
[18:36:58][V][mdns:121]:     TXT: network = wifi
[18:36:58][V][mdns:121]:     TXT: api_encryption = Noise_NNpsk0_25519_ChaChaPoly_SHA256
[18:36:58][C][api:138]: API Server:
[18:36:58][C][api:139]:   Address: ${devicename}.local:6053
[18:36:58][C][api:141]:   Using noise encryption: YES
[18:36:58][C][audio:203]: Audio:
[18:36:58][C][audio:225]:   External DAC channels: 1
[18:36:58][C][audio:226]:   I2S DOUT Pin: 27
[18:37:17][D][api:102]: Accepted 192.168.1.199
[18:37:17][VV][api.socket:696]: 192.168.1.199: Handshake complete!
[18:37:17][VV][api.service:504]: on_hello_request: HelloRequest {
[18:37:17]  client_info: 'Home Assistant 2024.8.2'
[18:37:17]  api_version_major: 1
[18:37:17]  api_version_minor: 10
[18:37:17]}
[18:37:17][V][api.connection:1014]: Hello from client: 'Home Assistant 2024.8.2 (192.168.1.199)' | API Version 1.10
[18:37:17][VV][api.service:013]: send_hello_response: HelloResponse {
[18:37:17]  api_version_major: 1
[18:37:17]  api_version_minor: 9
[18:37:17]  server_info: 'esp-266 (esphome v2023.10.3)'
[18:37:17]  name: 'esp-266'
[18:37:17]}
[18:37:17][VV][api.service:513]: on_connect_request: ConnectRequest {
[18:37:17]  password: ''
[18:37:17]}
[18:37:17][D][api.connection:1032]: Home Assistant 2024.8.2 (192.168.1.199): Connected successfully
[18:37:17][VV][api.service:019]: send_connect_response: ConnectResponse {
[18:37:17]  invalid_password: NO
[18:37:17]}
[18:37:17][VV][api.service:558]: on_device_info_request: DeviceInfoRequest {}
[18:37:17][VV][api.service:049]: send_device_info_response: DeviceInfoResponse {
[18:37:17]  uses_password: NO
[18:37:17]  name: 'esp-266'
[18:37:17]  mac_address: 'A8:48:FA:94:3A:14'
[18:37:17]  esphome_version: '2023.10.3'
[18:37:17]  compilation_time: 'Aug 24 2024, 18:35:05'
[18:37:17]  model: 'nodemcu-32s'
[18:37:17]  has_deep_sleep: NO
[18:37:17]  project_name: ''
[18:37:17]  project_version: ''
[18:37:17]  webserver_port: 0
[18:37:17]  legacy_bluetooth_proxy_version: 0
[18:37:17]  bluetooth_proxy_feature_flags: 0
[18:37:17]  manufacturer: 'Espressif'
[18:37:17]  friendly_name: ''
[18:37:17]  voice_assistant_version: 0
[18:37:17]}
[18:37:17][VV][api.service:567]: on_list_entities_request: ListEntitiesRequest {}
[18:37:17][VV][api.service:316]: send_list_entities_media_player_response: ListEntitiesMediaPlayerResponse {
[18:37:17]  object_id: 'esphome_i2s_media_player'
[18:37:17]  key: 3210548230
[18:37:17]  name: 'ESPHome I2S Media Player'
[18:37:17]  unique_id: 'esp-266media_playeresphome_i2s_media_player'
[18:37:17]  icon: ''
[18:37:17]  disabled_by_default: NO
[18:37:17]  entity_category: ENTITY_CATEGORY_NONE
[18:37:17]  supports_pause: YES
[18:37:17]}
[18:37:17][VV][api.service:055]: send_list_entities_done_response: ListEntitiesDoneResponse {}
[18:37:17][VV][api.service:576]: on_subscribe_states_request: SubscribeStatesRequest {}
[18:37:17][VV][api.service:638]: on_subscribe_homeassistant_services_request: SubscribeHomeassistantServicesRequest {}
[18:37:17][VV][api.service:665]: on_subscribe_home_assistant_states_request: SubscribeHomeAssistantStatesRequest {}
[18:37:17][VV][api.service:324]: send_media_player_state_response: MediaPlayerStateResponse {
[18:37:17]  key: 3210548230
[18:37:17]  state: MEDIA_PLAYER_STATE_IDLE
[18:37:17]  volume: 1
[18:37:17]  muted: NO
[18:37:17]}

Is there anyone who might point me in the right direction? Any options on how to troubleshoot this? I am stuck…

So I’ve tried this with a different ESP32 dev board (NodeMCU) and with a PCM5102A DAC, same issue. When I play a media file from Home Assistant to the I²S Media Player, the ESP crashes.

This is definitely a software issue. I would be grateful if anyone could offer some help.

So I found out that the issue is not with the hardware nor with the ESPhome config, but rather in the media access. I can play a web radio stream just fine from Home Assistant to the ESP32 and through the I²S DAC.

When I attempt to play a media file from Home Assistant’s media directory, I get a ‘connection refused’ message from the webserver. Need to further troubleshoot this.