MAX98357 I2S crackling audio - SOLUTION

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 :confused:
1 Like

Ive been yelling that from my rooftop for 2+ years!!!
Ive also lost all hope in the masses doing it also… People would rather argue in their own post about how they already tried using ChatGPT without success and i guess that in their brain, they think if GPT couldn’t answer their question then why bother reading through any of that technical jargon and trying to make themselves better/wiser since GPT is being replaced for having a brain that they have to use and also, they prefer using their heads as a hat holder… Im starting to think that we’re way overdue for another asteroid and that would be less painful than watching the masses gladly give away the ability to think/learn because AI is better,faster, and easier in their opinion… look no further than the example of all the people now who think everyone that disagrees with them is a fascist and their genius idea is to fight against diversity of opinions by using core tactics of a true fascist regime and they’ll cleverly call themselves antifa for “anti fascist” lol. If anyone one disagrees with that or doesnt like that factual example, well then your a fascist and must be silenced and harassed just like the “Brown Shirts” did for the little mustache man…

Thanks social media and now AI is the tool to just make it worse at an accelerated rate…

1 Like