ESPHome I2S media player interrupts web radio stream all the time

I’m trying to build ESP32 ESPHome internet radio.

Parts I’m using:

  • ESP32 WROOM
  • PCM5102A DAC
  • PAM8406 amplifier
  • Speaker 8Ω, 3W (some disassembled PC speaker)

Wiring between ESP32 WROOM → DAC:

  • GPIO26 → BCK
  • GPIO25 → DIN
  • GPIO22 → LCK

But I have often stream interruptions. Music is going, then stops for 1-2 seconds, then continues, and this is happening at least once in one minute, which is unacceptable for me :grin:. I think this interruptions are happening more often when playing internet radio, compared with local mp3 file from HA server, but still happens in both cases.

Just before hour or two, I tried to replace ESP32 WROOM with ESP32 Camera board, of course with different wiring, to see if I would have better results. It seems that I have less interruptions with ESP32 Camera module, but they are still presented. I tried to use camera module both way - with internal and external antenna (of course, I de soldered resistor and soldered bridge for external antenna). Most interesting part is that ESPHome log is showing very similar signal in both cases, about -57dB

Wiring between ESP32 Camera → DAC:

  • GPIO2 → BCK
  • GPIO12 → DIN
  • GPIO13 → LCK

I would be glad to provide any additional info needed, does anybody has some useful hint, where to search for root cause? Or from your experience, could this be network related or encoding/decoding, maybe bad DAC, IDK?

This is my YAML (different PINs would be for WROOM, below is for CAM):

esphome:
  name: esp32-music-test
  friendly_name: ESP32 Music Test
  on_boot:
    then:
      - delay: 20s
      - media_player.volume_set:
          id: player
          volume: 20%
      - delay: 2s
      - media_player.play_media:
          id: player
          media_url: 'https://edge9.pink.rs/rockstream'
          #media_url: 'http://stream.live.vc.bbcmedia.co.uk/bbc_radio_one'

esp32:
  board: esp32dev
  framework:
    type: arduino

logger:

api:

ota:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  ap:
    ssid: "ESP32-Music-Test-Hotspot"
    password: "some password"

captive_portal:

i2s_audio:
  i2s_lrclk_pin: GPIO13
  i2s_bclk_pin: GPIO2

media_player:
  - platform: i2s_audio
    name: ESP32 Music Test
    dac_type: external
    mode: mono
    id: player
    i2s_dout_pin: GPIO12

Found accidentally my old thread while searched something similar over internet. So sad that anybody was not interested :sob:. Did not found solution in mean time, and stopped using these devices at all. From perfect working solution - two boxes I made, with ESP8266 and DFPlayer mini, which were play local music from SD card, triggered with motion sensor together with lights, when someone enter to bathroom and in toilet, and which was work perfectly for months, I wanted more :grin:. Wanted internet radio and ended with interruptions, so I turned off both boxes, and no music for the months, because I am lazy to pack everything back with DFPlayer, and maybe hope that will find some solution for internet radio :grin:

I’m looking for the same project but so far I only flashed a ESP32 devkit with arduino project (works with internal i2s dac) :frowning:

I think soon i will be curious too. I will try to create own home radio servise

Hi! I made my speaker based on this tutorial on the esp32wroom board
My Local Voice Assistant Device With Wake Word In Home Assistant | Smart Home Circle
Most of the time it works fine. Sometimes it stops for 1-2 seconds, but usually it plays fine for a few hours, I think that’s normal.
I don’t know if the esphome media player library has buffering, and how much buffering it has. But obviously it’s not very big, and it’s designed for a good connection. Since the esp board connects to your network via 2.4GHz band wifi, which is pretty heavily loaded with a lot of devices, it’s generally not surprising that there would be occasional lapses in connectivity.
Try installing a wifi scanner app on your smartphone (there are many different ones, the point is the same). Check what channel your router, to which your speaker is connected, is running on. See how many other devices are running on that channel, try to find a freer one (lol) and tune your router to it.

Will compare this tutorial with my setup these days, thanks.Regarding wifi channel, this is something I gave up (exactly why you wrote lol in brackets). Living in building, so all the channels are crowded, so I have impression that best bet is to set channel to auto.

I don’t think you have pinout errors in your board, otherwise it won’t play anything at all.
What is the distance between the speaker and the router? I mean, the radio conditions for router and speaker are not the same. It is quite possible that the router sees some channel as more free, while at the speaker’s location this channel is more “noisy”.
Yes, radio interference is a very complicated thing. I live in the suburbs, but even here there are a huge number of wifi networks and I’ve had problems even setting up some pretty powerful equipment for a radio bridge between my house and my wife’s house. I ended up having to go to the 60GHz band for the radio bridge.
Unfortunately, most ESP32 boards only work in the 2.4 band. There seem to be a few models that have a 5GHz band, maybe that would be a good solution since that band is cleaner.

Thank you for the detailed info, but too much hassle. If I never buy Sonos or something similar (lot of money for bathroom and toilet music :grin:), and if I ever catch some spare time in my life which goes to hell with my new job :unamused:, I will switch back to ESP8266 + DFPlayer Mini + local music from DFPlayer SD card - this worked flawlessly and had really good sound quality.
For this ESP32 FM radio - as much you pay, as much you get :grin:.

Hi, has anyone tried something like this on a classic esp32 without psram? I haven’t been successful yet.

I have tried it.
The experience was very bad.
I think it was caused by the insufficient performance of esp32.
Later I used other hardware to implement it.
The keywords are openwrt+usb sound card+squeezelite