My ESP32S3 + PCM5102A DAC Media player doen't work

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!

Add some hardware information:
SCK is connected to GND by soldering the jumper on PCM5102A board, also H1L, H2L, H4L are soldered to Low. Except H3L, I connected the XSMT pad to GPIO10 to be able to control mute via ESP32.
I additionally connected a pin of the 3.5mm jack to GPIO11, this is used to detect the jack plug.
At this moment I removed all non-core function code in order to test the media player.

For VCC I used 5V to supply to PCM5102A, not sure if this could be a cause, if it can’t be solved by modifying the codes, my last try will be change the hardware setting.

The ring buffer is always the problem. If I output from media pipeline directly to i2s audio speaker, I get those

[12:24:47.206][D][i2s_audio.speaker:102]: Starting
[12:24:47.208][D][i2s_audio.speaker:106]: Started
[12:24:47.208][D][ring_buffer:034][speaker_task]: Created ring buffer with size 38400
[12:24:47.994][D][i2s_audio.speaker:111]: Stopping
[12:24:47.997][D][i2s_audio.speaker:116]: Stopped

When I use the full pipeline setup (with mixer, resampler), then the mixer.speaker had the ring buffer issue.

Just a thought, were you running this previously on arduino? If so when changing to esp-idf did you reload the code via USB with a complete erase? This does something with the partition table and allows the esp32 to work properly. Don’t ask me how or why, I just remember it from a few months back.

Otherwise i can’t see any issues with your code. Not sure about the platformio_options: I’ve not used them for a long time now.

Buffer sizes never really made a difference for me, I just stick with the recomended. Also using flac is the least processor intensive format.

As for wiring, the grounds of both boards are connected I guess its difficult to see from your pic.

Try using the pins I use, I remember having issues using other pins in the early days.

LRC GPIO11
BLC GPIO9
Dout GPIO7

Yes, I always download the bin and use USB to erase and install.
For me it was always ring buffer problem. I am thinking of my network throughout issue, because using of FLAC is worse than MP3. FLAC has bigger size.

Maybe I solder another esp32 and pcm board to see if it is the board’s problem.

I adjust the code like this to compare the difference between using sendspin_source and http_source. Also not change from MP3 to FLAC, sendspin use psram: false

esphome:
  name: $name
  friendly_name: $friendly_name

esp32:
  variant: esp32s3
  board: esp32-s3-devkitc1-n16r8
  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:
  level: DEBUG
  logs:
    sensor: WARN 

sendspin:
  id: sendspin_hub
  task_stack_in_psram: false

media_source:
  - platform: sendspin
    id: sendspin_media_source
  - platform: http_request
    id: http_media_source
    buffer_size: 500000

media_player:
  - platform: speaker_source
    id: external_media_player
    name: None
    media_pipeline:
      format: FLAC
      num_channels: 2
      sample_rate: $sample_rate
      speaker: i2s_audio_speaker
      sources:
        - sendspin_media_source
        - http_media_source
    volume_increment: 0.05
    volume_initial: 0.15
    volume_min: 0.05
    volume_max: 0.95

If I play from HA, it use http_source, here is the log:

[16:12:40.813][D][media_player:113]: 'ESP32 Media Player' - Setting
[16:12:40.816][D][media_player:120]:   Media URL: http://192.168.31.100:8123/api/esphome/ffmpeg_proxy/ecc35aaec7f4605a0381d4a7ba40c9bb/A-2iUevsbLqUgCIOPB-GhQ.flac
[16:12:40.831][D][http_media_source:069]: Starting
[16:12:40.834][D][http_request.idf:043][HTTPRead]: Received response header, name: content-type, value: application/octet-stream
[16:12:40.836][D][http_request:028][HTTPRead]: Header with name content-type found with value application/octet-stream
[16:12:40.838][D][ring_buffer:034][HTTPRead]: Created ring buffer with size 500000
[16:12:40.854][D][speaker_source_media_player:285]: State changed to PLAYING
[16:12:43.039][D][http_media_source:114][HTTPDecode]: Bits per sample: 16, Channels: 2, Sample rate: 48000
[16:12:43.066][D][ring_buffer:034][speaker_task]: Created ring buffer with size 38400
[16:12:43.066][D][i2s_audio.speaker:102]: Starting
[16:12:43.067][D][i2s_audio.speaker:106]: Started
[16:12:43.855][D][i2s_audio.speaker:111]: Stopping
[16:12:43.857][D][i2s_audio.speaker:116]: Stopped
[16:12:43.987][D][i2s_audio.speaker:102]: Starting
[16:12:43.987][D][i2s_audio.speaker:106]: Started
[16:12:43.991][D][ring_buffer:034][speaker_task]: Created ring buffer with size 38400
[16:12:44.673][D][i2s_audio.speaker:111]: Stopping
[16:12:44.675][D][i2s_audio.speaker:116]: Stopped
[16:12:44.742][D][i2s_audio.speaker:102]: Starting
[16:12:44.744][D][i2s_audio.speaker:106]: Started
[16:12:44.745][D][ring_buffer:034][speaker_task]: Created ring buffer with size 38400
[16:12:51.516][D][monitor:057]: SRAM: 137.0kB, PSRAM: 5.23MB, MaxBlock: 128.0kB
[16:12:56.621][D][i2s_audio.speaker:111]: Stopping
[16:12:56.623][D][i2s_audio.speaker:116]: Stopped
[16:12:56.735][D][i2s_audio.speaker:102]: Starting
[16:12:56.736][D][i2s_audio.speaker:106]: Started
[16:12:56.736][D][ring_buffer:034][speaker_task]: Created ring buffer with size 38400
[16:13:00.385][D][i2s_audio.speaker:111]: Stopping
[16:13:00.390][D][i2s_audio.speaker:116]: Stopped
[16:13:00.474][D][i2s_audio.speaker:102]: Starting
[16:13:00.474][D][i2s_audio.speaker:106]: Started
[16:13:00.478][D][ring_buffer:034][speaker_task]: Created ring buffer with size 38400
[16:13:00.889][D][media_player:113]: 'ESP32 Media Player' - Setting
[16:13:00.891][D][media_player:117]:   Command: PAUSE
[16:13:00.906][D][speaker_source_media_player:285]: State changed to PAUSED
[16:13:01.575][D][i2s_audio.speaker:111]: Stopping
[16:13:01.578][D][i2s_audio.speaker:116]: Stopped

There is also ring_buffer issue, which normal isn’t an issue with MP3 format. There is sound with stuttering.
And here is the log when play from MA via sendspin:

[16:11:35.381][D][sendspin.hub:501]: Persisted last played server: 4c052f56b4e3465b90c3ddd747741ba4 (hash: 0xD545CA51)
[16:11:35.382][D][sendspin.hub:874]: Group update - state: playing, id: 80351a26-553a-4dbc-abc6-8c9472ec111e, name: 
[16:11:35.538][D][sendspin.hub:621][httpd]: Stream Started
[16:11:35.540][D][sendspin.hub:624][httpd]: Requesting high performance networking for playback
[16:11:35.556][D][media_player:113]: 'ESP32 Media Player' - Setting
[16:11:35.556][D][media_player:120]:   Media URL: sendspin://current
[16:11:35.561][D][media_player:126]:  Announcement: no
[16:11:35.562][D][sendspin_media_source:129]: sendspin_id: current
[16:11:35.562][D][sendspin_media_source:176]: Started sync task
[16:11:35.562][D][sendspin_media_source:184]: Starting
[16:11:35.565][D][sendspin_media_source:189]: Running
[16:11:35.565][I][sendspin_media_source:483][Sendspin]: Processed new codec header
[16:11:35.582][D][speaker_source_media_player:285]: State changed to PLAYING
[16:11:35.585][D][i2s_audio.speaker:102]: Starting
[16:11:35.587][D][i2s_audio.speaker:106]: Started
[16:11:35.587][D][ring_buffer:034][speaker_task]: Created ring buffer with size 38400
[16:11:36.510][D][monitor:057]: SRAM: 149.8kB, PSRAM: 5.76MB, MaxBlock: 140.0kB
[16:11:36.694][D][i2s_audio.speaker:111]: Stopping
[16:11:36.710][D][i2s_audio.speaker:116]: Stopped
[16:11:38.723][D][i2s_audio.speaker:102]: Starting
[16:11:38.727][D][i2s_audio.speaker:106]: Started
[16:11:38.728][D][ring_buffer:034][speaker_task]: Created ring buffer with size 38400
[16:11:39.543][D][i2s_audio.speaker:111]: Stopping
[16:11:39.546][D][i2s_audio.speaker:116]: Stopped
[16:11:43.514][D][text_sensor:120]: 'Track Title' >> 'Conni auf dem Reiterhof Track 1'
[16:11:43.516][D][text_sensor:120]: 'Artist' >> 'Audio Books'
[16:11:43.519][D][text_sensor:120]: 'Album' >> 'Conni auf dem Reiterhof'
[16:11:43.540][D][i2s_audio.speaker:102]: Starting
[16:11:43.541][D][i2s_audio.speaker:106]: Started
[16:11:43.541][D][ring_buffer:034][speaker_task]: Created ring buffer with size 38400
[16:11:44.314][D][i2s_audio.speaker:111]: Stopping
[16:11:44.331][D][i2s_audio.speaker:116]: Stopped
[16:11:46.072][D][i2s_audio.speaker:102]: Starting
[16:11:46.073][D][i2s_audio.speaker:106]: Started
[16:11:46.074][D][ring_buffer:034][speaker_task]: Created ring buffer with size 38400
[16:11:46.847][D][i2s_audio.speaker:111]: Stopping
[16:11:46.850][D][i2s_audio.speaker:116]: Stopped
[16:11:50.573][D][i2s_audio.speaker:102]: Starting
[16:11:50.576][D][i2s_audio.speaker:106]: Started
[16:11:50.576][D][ring_buffer:034][speaker_task]: Created ring buffer with size 38400
[16:11:51.311][D][i2s_audio.speaker:111]: Stopping
[16:11:51.311][D][i2s_audio.speaker:116]: Stopped
[16:11:51.513][D][monitor:057]: SRAM: 166.2kB, PSRAM: 5.80MB, MaxBlock: 140.0kB
[16:11:52.769][D][sendspin.hub:709][httpd]: Stream ended - player:1 artwork:1 visualizer:1
[16:11:52.786][D][sendspin.hub:874]: Group update - state: stopped, id: 80351a26-553a-4dbc-abc6-8c9472ec111e, name: 
[16:11:52.787][D][sendspin_media_source:195]: Stopping
[16:11:52.788][D][sendspin_media_source:200]: Stopped
[16:11:52.789][D][speaker_source_media_player:285]: State changed to IDLE
[16:12:06.515][D][monitor:057]: SRAM: 173.0kB, PSRAM: 5.86MB, MaxBlock: 140.0kB

With FLAC at MA, there is no sound at all.
If I set time_out: never, there will be no error log, just stuttering or no sound.

First thing is the HTTP source is there to allow HA to play to the player hence why it uses it, Its the only way HA can play to it.

If you set the preferred audio format in the MA player settings to anything it does not allow it to be set back automatic, the option is not there (at least this is how it was a week or 2 back). reset the player to defaults, it will then set the format to automatic, and let sendspin decide what format to send.

try commenting out the buffers and see if letting esphome use the defaults helps.

Your ring buffer is twice the size of mine.

Can you tell i am just guessing as much as you :slight_smile:

Just had a notification from this, Read the last comment.

I think I have read that link before.
I kept the setting in MA to automatically choose format, never changed. I only change the format in my esp32 code.
I did a resoldering, changed VCC to 3.3V, data bins to GPIO 4/5/6.
Commented out the buffer size, the default buffer duration is 500ms. It doesn’t help. I tried from 100ms to 1000ms, no difference.

[17:14:19.652][D][sendspin.hub:501]: Persisted last played server: 4c052f56b4e3465b90c3ddd747741ba4 (hash: 0xD545CA51)
[17:14:19.657][D][sendspin.hub:874]: Group update - state: playing, id: 5bfdf63f-7d0a-4f5c-8933-43851f09059b, name: 
[17:14:19.749][D][sendspin.hub:621][httpd]: Stream Started
[17:14:19.755][D][sendspin.hub:624][httpd]: Requesting high performance networking for playback
[17:14:19.756][D][media_player:113]: 'ESP32 Media Player' - Setting
[17:14:19.756][D][media_player:120]:   Media URL: sendspin://current
[17:14:19.756][D][media_player:126]:  Announcement: no
[17:14:19.762][D][sendspin_media_source:129]: sendspin_id: current
[17:14:19.764][D][sendspin_media_source:176]: Started sync task
[17:14:19.764][D][sendspin_media_source:184]: Starting
[17:14:19.766][D][sendspin_media_source:189]: Running
[17:14:19.768][I][sendspin_media_source:483][Sendspin]: Processed new codec header
[17:14:19.779][D][speaker_source_media_player:285]: State changed to PLAYING
[17:14:19.788][D][i2s_audio.speaker:102]: Starting
[17:14:19.789][D][i2s_audio.speaker:106]: Started
[17:14:19.790][D][ring_buffer:034][speaker_task]: Created ring buffer with size 96000
[17:14:20.726][D][i2s_audio.speaker:111]: Stopping
[17:14:20.729][D][i2s_audio.speaker:116]: Stopped
[17:14:20.849][D][i2s_audio.speaker:102]: Starting
[17:14:20.852][D][i2s_audio.speaker:106]: Started
[17:14:20.853][D][ring_buffer:034][speaker_task]: Created ring buffer with size 96000
[17:14:22.310][D][i2s_audio.speaker:111]: Stopping
[17:14:22.315][D][i2s_audio.speaker:116]: Stopped
[17:14:22.407][D][i2s_audio.speaker:102]: Starting
[17:14:22.425][D][i2s_audio.speaker:106]: Started
[17:14:22.425][D][ring_buffer:034][speaker_task]: Created ring buffer with size 96000
[17:14:23.269][D][i2s_audio.speaker:111]: Stopping
[17:14:23.270][D][i2s_audio.speaker:116]: Stopped

I am out of idea. Maybe it is the hardware issue, cheap board…

But did you read the last comment that said they had a c5 working with the same dac as you are trying to use.

I am guessing your board has issues.

I almost come to that coclusion too. I think it is the esp32-board issue, not the pcm5102a. Only esp has ring buffer.

@cofw2005
I have S3 supermini board and DAC with same chip as yours. Amp is mono with TPA 3118 chip and it has it’s own 12V power supply. Every thing work ok, no stutter or any chirps when play is idle. It is added in Musicassistant and I play music from there.
I have noticed that you didn’t use PSRAM in your code?
Anyway here is part of my code:

psram:
  mode: quad
i2s_audio:
  i2s_lrclk_pin: GPIO12 # -> LRC
  i2s_bclk_pin: GPIO11 # -> BCLK

speaker:
  - platform: i2s_audio
    id: speaker_i2s
    dac_type: external
    buffer_duration: 1000ms
    
    channel: mono
   
    i2s_dout_pin: GPIO10  # -> DIN
   
    
media_player:
  - platform: speaker
    id: media_player_s3
    name: "Media Player toilet"
    
    buffer_size: 240000
    announcement_pipeline:
      speaker: speaker_i2s
      format: NONE   

He has used psram. Tried with and without as far as I know

yes, I tried many different combinations. I now roll back to speaker media player, at least it works with home assistant.
I notice in your code you use format: NONE , didn’t know that is an option.
I am now thinking if my wifi causes something. Gemini said the ring buffer stop because the data in the buffer were empty and can’t get data from upstream in time. The upstream in my case is the http_source or media stream.
In my tries, only MP3 can work. I guess because MP3 has less data transfer.

As I understand, you have some sound from speaker but it is …stutter? In regular intervals or it is work normal for sometime and then gap?
In my case I have tried with all formats and all worked ok, this format: NONE is my last try, probably

This defaults to flac

With speaker media player:
if I use FLAC, it stutters since very beginning. In log I can see regular ring buffer stop/start every 2s. And barely sound out, only a β€œbeep” every 2s. Both from HA and MA.
If I use MP3, I can get sound perfectly playing from HA. But if playing from MA, I get decoder error very soon after start.

With media_source speaker and external http_request:
FLAC: the same, only β€œbeep” no sound.
MP3: there will be no more decoder error, but not as good as speaker media player. Both from HA and MA, only intermittent sounds could be heard.

What wifi signal strength do you have?

in my log I see:
Signal strength: -22 dB β–‚β–„β–†β–ˆ

Yes, that is a very good signal. Did you try to use my YAML, just for test?

I think I have tried similiar code except I never used quad mode for psram. I always use octal.