Speakers and headphone jack with I2S input

How can I make a PCB with I2S output from espuino software to have stereo speaker output and a headphone jack?
When the jack is inserted, the speaker should stop playing, is this software supported in espuino or should I have that on the hardware design?

Exactly what you want is already available: Kopfhörerplatine basierend auf MS6324 und TDA1308 bzw. LM4808M.
It makes use of a headphone jack „pj-306b“ which features an integrated switch (in fact it’s two of them) that I use to pull HP_DETECT to GND in order to let ESPuino if headphones are plugged in. That means: normally HP_DETECT is high and will be pulled down to GND if headphones are plugged in. With DETECT_HP_ON_HIGH you can invert this behaviour.

We already used MS6324, UDA1334 and PCM5102 for such purposes, but others might work as well. You need to make sure to use an amp because otherwise it’s not powerful enough.

That’s useful to know. Thank you! Does this have stereo output for speakers also? I see the MAX98357A on the base board but that gives mono output.

Sorry if I have wrong info or confusion.

Another question, does the software control switching between headphone and speakers using this HP_DETECT pin? If so, where does it do it in the software?

We have mini4L which includes 1x MAX98357a. But optionally, with a MAX98357a-breadboard, it can be extended with a second MAX98357a. So you could connect two speakers.
Mini4l is used as carrier-pcb for esp32-develboards.

Yes.

Great! Thank you for the detailed answer… as I understand we’ll need 3 ICs, 2 MAX98357A for stereo speaker output and 1 UDA1334A for the headphone jack with PA_N signal for enabling/disabling the speakers when HP_DETECT signal is found. I will share the schematics for review on this thread.

Here we go: the schematics for the headphone-pcb I designed two years back or so for UDA1334: Schematics_UDA1334.pdf (60,7 KB)
Advantage over MS6324 is, that it features an on/off pin. However, in the end it’s not really important (in my opinion).
Disadvantages: obsolete, more difficult to integrate. That’s why I moved on to MS6324.

As already mentioned above: you need an amp as well.

Thank you for the links… to get my schematics started I made up a diagram as below… will this work with ESPUINO platform?
IMG-20240504-WA0002

In general it should.
But don’t expect too much support with S3 as just a few of us have been testing it.

Thanks! I am unsure if the speakers will have stereo output in this circuit.

Side note,
I am connecting PAM8403’s SHDN pin to PA_EN for ESPUINO