So I’ve been hunting this issue of a MAX98357 external DAC connected to an ESP32-S2. Using the following, copy-pasted example resulted in crackling sound:
i2s_audio:
i2s_lrclk_pin: GPIO03 # -> LRC
i2s_bclk_pin: GPIO05 # -> BCLK
speaker:
- platform: i2s_audio
id: speaker_kerstdorp
dac_type: external
channel: mono
sample_rate: 44100
i2s_dout_pin: GPIO07 # -> DIN
media_player:
- platform: speaker
id: media_player_kerstdorp
name: "Media Player Kerstdorp"
announcement_pipeline:
speaker: speaker_kerstdorp
format: NONE # disables transcoding in Home Assistant
(note, this is a stripped down, minimalistic version as I was debugging like madman)
This is a new, single-core board, so for a long time, I’ve suspected that the issue was that I2S DMA was somehow interrupted by the wifi traffic, or esp-idf bug, or some issue caused by new hardware.
Well, it wasn’t.
Long story short, I bumped into a nice little note by complete accident.
So it turns out that MAX98357 is just a chip. When buying a cheap board on aliexpress, you generally get the necessary bypass capacitors left out. That means that all the electrical spikes from ESP32 inject noise directly into the power supply of the MAX98357, causing the crackles.
As soon as I added a 0.1 and a 10 uF bypass capacitor (simply soldered between the power supply’s GND and VCC - do double-check polarity), crackles disappeared completely.
So I’m just leaving this here, maybe I’ll spare a few days of debugging for someone:
- ESP32-S2 if perfectly capable to play streaming MP3s via I2S without crackling or artifacts using esphome’s basic examples.
- Even the venerable ESP8266 is capable of doing this.
- I2S utilizes DMA, which is more than capable of handling audio output without interruptions or crackles or other noticable artifacts.
- You really need to read the manufacturer’s document – would have spared me days