I2S ESP32 Stereo output two MAX98357A

Hi there, I’m trying to get two MAX98357A boards to work in stereo mode using latest ESPHome on ESP32 (devkit1). However regardless of using stereo mode argument in the code, sound from both speakers work in mono regime.

status_led:
  pin:
    number: GPIO2
    inverted: true

i2s_audio:
  - id: i2s_out
    i2s_lrclk_pin: GPIO14
    i2s_bclk_pin: GPIO27
  - id: i2s_in
    i2s_lrclk_pin: GPIO13
    i2s_bclk_pin: GPIO12

media_player:
  - platform: i2s_audio
    name: ESPHome I2S Media Player
    dac_type: external
    i2s_audio_id: i2s_out
    i2s_dout_pin: GPIO25
    mode: stereo

    
# Example configuration entry
microphone:
  - platform: i2s_audio
    i2s_audio_id: i2s_in
    i2s_din_pin: GPIO26
    adc_type: external
    id: mic_i2s
    pdm: false

voice_assistant:
  microphone: mic_i2s

I have used the following diagram to hook DAC modules (mine hooked to different pins):

Can someone holp to sort this out?

I don’t know much if anything about these boards so I could be very wrong. :slight_smile:

But the wiring diagram shows both amp boards wired to exactly the same signal. Do you not have to toggle a pin on the board for left or right channel?

there is no such a code in ESPHome to separate left and right channels with external DAC unfortunatelly. Stereo signal carry signal separation so LRCLK can understand which channel it should decode and play.
As far as I understood, the problem might be with ESPHome itself. I might be wrong.

UPDATE: Figured out stereo output. Problem was in MAX98357A configuration. By default it is configured to mix outputs using 1M resistor (to VDD) so to configure it to left and right channels, SD needs to be pulled-up to VDD with jumper (0 Ohms) that is going to be LEFT channel and with 370-470K resistor to VDD to output Right channel.
All perfect now.
By the way I get really nice sound quality despite this is only class D amplifier.

and here is my little project printed for stereo WiFi player ))

and here is my code:

captive_portal:

status_led:
  pin:
    number: GPIO2
    inverted: true

i2s_audio:
  - id: i2s_out
    i2s_lrclk_pin: GPIO14 
    i2s_bclk_pin: GPIO27
  - id: i2s_in
    i2s_lrclk_pin: GPIO32 #ws
    i2s_bclk_pin: GPIO33 #sck

# LR to be grounded

media_player:
  - platform: i2s_audio
    name: ESPHome I2S Media Player
    dac_type: external
    i2s_audio_id: i2s_out
    i2s_dout_pin: GPIO25
    mode: stereo

    
# Example configuration entry
microphone:
  - platform: i2s_audio
    i2s_audio_id: i2s_in
    i2s_din_pin: GPIO26 #sd
    adc_type: external
    id: mic_i2s
    pdm: false

voice_assistant:
  microphone: mic_i2s
3 Likes

Would you be kind enough to share the connection diagram of the components of your I2S ESP Stereo… Thank you!

@elik745i those speakers look massive… Is the amp able to drive them nicely?
What are the specs of the speakers?