Hello, I was trying with a simple media player kit for a few evenings, canβt get it work as expected. I hope someone can help me.
My hardware setup:
ESP32-S3-DevkitC-1 N16R8 (not espressif original one)
PCM5102A DAC (small purple board)
LRCLK - GPIO15
DIN - GPIO16
BCLK - GPIO17
XSMT - GPIO10
I have tried different options so far:
- legacy I2S Audio Media Player with Arduino framework
- I2S Audio Speaker + Speaker Media Player with pipelines (full setup and simplest setup with only annoucement pipeline output to i2s audio speaker)
- I2S Audio Speaker + Speaker Source Media Player + Sendspin source
In each of the setup also tried in different sample rate (44100 or 48000), mode (stereo or mono), format (MP3 or FLAC), buffer duration (100ms to 1000ms).
What I can make success so far is with MP3 format playing from home assistant. It is quite ok without stuttering. My goal is to achieve playing media from Music Assistant, which is so far never succeed.
Here is my latest code I used:
substitutions:
name: "esp32-media-player"
friendly_name: "ESP32 Media Player"
led_gpio_pin: GPIO48
sample_rate: 48000
esphome:
name: $name
friendly_name: $friendly_name
platformio_options:
board_build.f_flash: 80000000L
board_build.f_cpu: 240000000L
board_build.flash_mode: qio
board_build.psram_type: opi
board_build.arduino.memory_type: qio_opi
board_upload.maximum_size: 16777216
board_upload.speed: 921600
build_flags:
- -DBOARD_HAS_PSRAM
esp32:
variant: esp32s3
board: esp32-s3-devkitc-1
cpu_frequency: 240MHz
flash_size: 16MB
framework:
type: esp-idf
version: recommended
sdkconfig_options:
CONFIG_ESP32S3_DATA_CACHE_64KB: "y"
CONFIG_ESP32S3_DATA_CACHE_LINE_64B: "y"
CONFIG_ESP32S3_INSTRUCTION_CACHE_32KB: "y"
CONFIG_SPIRAM_RODATA: "y"
CONFIG_SPIRAM_FETCH_INSTRUCTIONS: "y"
CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST: "y"
CONFIG_BT_BLE_DYNAMIC_ENV_MEMORY: "y"
CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC: "y"
CONFIG_MBEDTLS_SSL_PROTO_TLS1_3: "y"
logger:
ota:
- platform: esphome
password: !secret ota_password
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
#output_power: 8.5dB
power_save_mode: NONE
network:
enable_high_performance: true
psram:
mode: octal
speed: 80MHz
ignore_not_found: false
api:
encryption:
key: !secret api_key
reboot_timeout: 0s
http_request:
id: http_req
buffer_size_rx: 4096
external_components:
- source:
# https://github.com/esphome/esphome/pull/14933
type: git
url: https://github.com/kahrendt/esphome
ref: 7a6cf5c8472b7e2fa18ee0fc314f66a80d249e32
components: [const, media_source, sendspin]
- source:
# https://github.com/esphome/esphome/pull/12429
type: git
url: https://github.com/esphome/esphome
ref: ff8ce89556748509d7ee8724e12d9d43d3c8c1e8
refresh: 0s
components: [http_request]
i2s_audio:
- id: i2s_out
i2s_lrclk_pin: GPIO15
i2s_bclk_pin: GPIO17
sendspin:
id: sendspin_hub
task_stack_in_psram: true
speaker:
- platform: i2s_audio
id: i2s_audio_speaker
i2s_audio_id: i2s_out
sample_rate: $sample_rate
i2s_dout_pin: GPIO16
bits_per_sample: 16bit
dac_type: external
channel: stereo
#timeout: never
buffer_duration: 200ms
media_source:
- platform: sendspin
id: sendspin_media_source
buffer_size: 1000000
media_player:
- platform: speaker_source
id: external_media_player
name: NONE
media_pipeline:
format: MP3
num_channels: 2
sample_rate: 48000
speaker: i2s_audio_speaker
sources:
- sendspin_media_source
volume_increment: 0.05
volume_initial: 0.15
volume_min: 0.05
volume_max: 0.95
switch:
- platform: gpio
pin:
number: GPIO10
inverted: true
restore_mode: ALWAYS_OFF
name: Mute
internal: False
text_sensor:
- platform: sendspin
type: title
name: Track Title
- platform: sendspin
type: artist
name: Artist
- platform: sendspin
type: album
name: Album
# Include addon packages
packages:
monitor_memory: !include addons/monitor_memory.yaml
Here is partial the log of compile:
INFO ESPHome 2026.3.1
INFO Reading configuration /config/esphome/media-player-kit.yaml...
INFO Updating https://github.com/esphome/esphome@ff8ce89556748509d7ee8724e12d9d43d3c8c1e8
INFO Generating C++ source...
INFO Applying high-performance lwip settings (PSRAM guaranteed): 512KB TCP windows, 512 mailbox sizes
INFO Applying high-performance WiFi settings (PSRAM guaranteed): 512 RX buffers, 32 TX buffers
INFO Setting CONFIG_LWIP_MAX_SOCKETS to 11 (TCP=7 [api=3, sendspin_websocket_client=1, sendspin_websocket_server=3], UDP=2 [mdns=2], TCP_LISTEN=2 [api=1, ota=1])
INFO Compiling app... Build path: /data/build/esp32-media-player
Processing esp32-media-player (board: esp32-s3-devkitc-1; framework: espidf; platform: https://github.com/pioarduino/platform-espressif32/releases/download/55.03.37/platform-espressif32.zip)
--------------------------------------------------------------------------------
HARDWARE: ESP32S3 240MHz, 320KB RAM, 16MB Flash
- contrib-piohome @ 3.4.4
- framework-espidf @ 3.50503.0 (5.5.3)
- tool-cmake @ 4.0.3
- tool-esp-rom-elfs @ 2024.10.11
- tool-esptoolpy @ 5.1.2
- tool-ninja @ 1.13.1
- tool-scons @ 4.40801.0 (4.8.1)
- toolchain-xtensa-esp-elf @ 14.2.0+20251107
Reading CMake configuration...
Dependency Graph
|-- noise-c @ 0.1.11
......
Memory Type Usage Summary
βββββββββββββββββββββββ³βββββββββββββββ³βββββββββββ³βββββββββββββββββ³ββββββββββββββββ
β Memory Type/Section β Used [bytes] β Used [%] β Remain [bytes] β Total [bytes] β
β‘βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β Flash Code β 827124 β β β β
β .text β 827124 β β β β
β Flash Data β 227240 β β β β
β .rodata β 226984 β β β β
β .appdesc β 256 β β β β
β DIRAM β 115047 β 33.66 β 226713 β 341760 β
β .text β 75119 β 21.98 β β β
β .data β 19896 β 5.82 β β β
β .bss β 18920 β 5.54 β β β
β .vectors β 1028 β 0.3 β β β
β .noinit β 84 β 0.02 β β β
βββββββββββββββββββββββ΄βββββββββββββββ΄βββββββββββ΄βββββββββββββββββ΄ββββββββββββββββ
Total image size: 1150407 bytes (.bin may be padded larger)
Note: The reported total sizes may be smaller than those in the technical reference manual due to reserved memory and application configuration. The total flash size available for the application is not included by default, as it cannot be reliably determined due to the presence of other data like the bootloader, partition table, and application partition size.
RAM: [= ] 11.9% (used 38900 bytes from 327680 bytes)
Flash: [= ] 14.2% (used 1150151 bytes from 8126464 bytes)
Building .pioenvs/esp32-media-player/firmware.bin
Creating ESP32S3 image...
Successfully created ESP32S3 image.
merge_factory_bin([".pioenvs/esp32-media-player/firmware.bin"], [".pioenvs/esp32-media-player/firmware.elf"])
Info: bootloader.bin not found - skipping
Info: partition-table.bin not found - skipping
Info: ota_data_initial.bin not found - skipping
Info: esp32-media-player.bin not found - skipping
Using FLASH_EXTRA_IMAGES from PlatformIO environment
Merging binaries into /data/build/esp32-media-player/.pioenvs/esp32-media-player/firmware.factory.bin
Merging binaries with esptool
SHA digest in image updated.
Wrote 0x128e60 bytes to file '/data/build/esp32-media-player/.pioenvs/esp32-media-player/firmware.factory.bin', ready to flash to offset 0x0.
Successfully created /data/build/esp32-media-player/.pioenvs/esp32-media-player/firmware.factory.bin
esp32_copy_ota_bin([".pioenvs/esp32-media-player/firmware.bin"], [".pioenvs/esp32-media-player/firmware.elf"])
Copied firmware to /data/build/esp32-media-player/.pioenvs/esp32-media-player/firmware.ota.bin
======================== [SUCCESS] Took 215.58 seconds ========================
INFO Build Info: config_hash=0xaee93ddd build_time_str=2026-03-29 12:01:03 +0200
INFO Successfully compiled program.
And here is some of the log:
[12:05:44][I][wifi:1551]: Connected
[12:05:44][C][wifi:1232]: Signal strength: -22 dB ββββ
[12:05:44][I][sendspin.ws_server:064]: Starting server on port: 8928 (max connections: 2)
[12:05:47][D][sendspin.ws_server:098][httpd]: New client connection on socket 59
[12:05:47][D][sendspin.hub:307][httpd]: No existing connection, accepting as current
[12:05:47][D][sendspin.hub:759][httpd]: Connected to server Music Assistant with id 4c052f56b4e3465b90c3ddd747741ba4 (reason: discovery)
[12:05:47][I][sendspin.hub:328][httpd]: Connection handshake complete: server_id=4c052f56b4e3465b90c3ddd747741ba4, connection_reason=discovery
[12:05:47][D][sendspin.hub:874]: Group update - state: stopped, id: b5316095-d61d-44f7-827e-b2d6991341dc, name:
[12:06:16][D][sensor:124]: 'SRAM Free' >> 182.1 kB
[12:06:16][D][sensor:124]: 'PSRAM Free' >> 5.93 mB
[12:06:16][D][sensor:124]: 'IRAM Free' >> 182.1 kB
[12:06:16][D][sensor:124]: 'Max Allocatable Block' >> 172.0 kB
[12:08:34][D][sendspin.hub:501]: Persisted last played server: 4c052f56b4e3465b90c3ddd747741ba4 (hash: 0xD545CA51)
[12:08:34][D][sendspin.hub:874]: Group update - state: playing, id: b5316095-d61d-44f7-827e-b2d6991341dc, name:
[12:08:34][D][sendspin.hub:621][httpd]: Stream Started
[12:08:34][D][sendspin.hub:624][httpd]: Requesting high performance networking for playback
[12:08:34][D][media_player:113]: 'NONE' - Setting
[12:08:34][D][media_player:120]: Media URL: sendspin://current
[12:08:34][D][media_player:126]: Announcement: no
[12:08:34][D][sendspin_media_source:129]: sendspin_id: current
[12:08:34][D][sendspin_media_source:176]: Started sync task
[12:08:34][D][sendspin_media_source:184]: Starting
[12:08:34][D][sendspin_media_source:189]: Running
[12:08:34][I][sendspin_media_source:483][Sendspin]: Processed new codec header
[12:08:35][D][speaker_source_media_player:285]: State changed to PLAYING
[12:08:35][D][i2s_audio.speaker:102]: Starting
[12:08:35][D][i2s_audio.speaker:106]: Started
[12:08:35][D][ring_buffer:034][speaker_task]: Created ring buffer with size 38400
[12:08:36][D][i2s_audio.speaker:111]: Stopping
[12:08:36][D][i2s_audio.speaker:116]: Stopped
[12:08:36][D][i2s_audio.speaker:102]: Starting
[12:08:36][D][i2s_audio.speaker:106]: Started
[12:08:36][D][ring_buffer:034][speaker_task]: Created ring buffer with size 38400
[12:08:37][D][i2s_audio.speaker:111]: Stopping
[12:08:37][D][i2s_audio.speaker:116]: Stopped
[12:08:39][D][i2s_audio.speaker:102]: Starting
[12:08:39][D][i2s_audio.speaker:106]: Started
[12:08:39][D][ring_buffer:034][speaker_task]: Created ring buffer with size 38400
[12:08:40][D][i2s_audio.speaker:111]: Stopping
[12:08:40][D][i2s_audio.speaker:116]: Stopped
[12:08:41][D][text_sensor:120]: 'Track Title' >> 'Conni geht zum Film Track 01'
[12:08:41][D][text_sensor:120]: 'Album' >> 'Conni geht zum Film'
[12:08:43][D][i2s_audio.speaker:102]: Starting
[12:08:43][D][i2s_audio.speaker:106]: Started
[12:08:43][D][ring_buffer:034][speaker_task]: Created ring buffer with size 38400
[12:08:43][V][sendspin.time_burst:037]: Starting new time burst
[12:08:43][V][sendspin.time_burst:070]: Sent time message 1/8
[12:08:44][D][i2s_audio.speaker:111]: Stopping
[12:08:44][D][i2s_audio.speaker:116]: Stopped
[12:08:44][V][esp32.preferences:117]: Saving 1 items...
[12:08:44][V][esp32.preferences:166]: nvs_get_blob('3228453220'): ESP_ERR_NVS_NOT_FOUND - the key might not be set yet
[12:08:44][V][esp32.preferences:128]: sync: key: 3228453220, len: 4
[12:08:44][D][esp32.preferences:144]: Writing 1 items: 0 cached, 1 written, 0 failed
[12:08:45][D][i2s_audio.speaker:102]: Starting
[12:08:45][D][i2s_audio.speaker:106]: Started
[12:08:45][D][ring_buffer:034][speaker_task]: Created ring buffer with size 38400
[12:08:46][D][sensor:124]: 'SRAM Free' >> 158.8 kB
[12:08:46][D][sensor:124]: 'PSRAM Free' >> 5.82 mB
[12:08:46][D][sensor:124]: 'IRAM Free' >> 158.8 kB
[12:08:46][D][sensor:124]: 'Max Allocatable Block' >> 148.0 kB
[12:08:46][D][i2s_audio.speaker:111]: Stopping
[12:08:46][D][i2s_audio.speaker:116]: Stopped
[12:08:46][V][sendspin.time_burst:070]: Sent time message 2/8
[12:08:49][D][i2s_audio.speaker:102]: Starting
[12:08:49][D][i2s_audio.speaker:106]: Started
[12:08:49][D][ring_buffer:034][speaker_task]: Created ring buffer with size 38400
[12:08:50][D][i2s_audio.speaker:111]: Stopping
[12:08:50][D][i2s_audio.speaker:116]: Stopped
[12:08:51][V][sendspin.time_burst:070]: Sent time message 3/8
[12:08:51][D][sendspin.hub:709][httpd]: Stream ended - player:1 artwork:1 visualizer:1
[12:08:51][D][sendspin.hub:874]: Group update - state: stopped, id: b5316095-d61d-44f7-827e-b2d6991341dc, name:
[12:08:51][V][sendspin.time_burst:070]: Sent time message 4/8
[12:08:51][D][sendspin_media_source:195]: Stopping
[12:08:51][D][sendspin_media_source:200]: Stopped
[12:08:51][D][speaker_source_media_player:285]: State changed to IDLE
Can anyone identify where the problem is? Thanks in advance for helping!
