# Speakers and headphone jack with I2S input

**URL:** <https://forum.espuino.de/t/speakers-and-headphone-jack-with-i2s-input/2990>\
**Category:** Hardware\
**Created:** [2. Mai 2024 um 20:45 UTC](https://forum.espuino.de/t/speakers-and-headphone-jack-with-i2s-input/2990 "2024-05-02T20:45:31Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![kelapuress](https://forum.espuino.de/user_avatar/forum.espuino.de/kelapuress/32/3792_2.png) [@kelapuress](https://forum.espuino.de/u/kelapuress)\
**Post date:** [2. Mai 2024 um 20:45 UTC](https://forum.espuino.de/t/speakers-and-headphone-jack-with-i2s-input/2990/1 "2024-05-02T20:45:31Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![biologist](https://forum.espuino.de/user_avatar/forum.espuino.de/biologist/32/66_2.png) [@biologist](https://forum.espuino.de/u/biologist)\
**Post date:** [3. Mai 2024 um 05:35 UTC](https://forum.espuino.de/t/speakers-and-headphone-jack-with-i2s-input/2990/2 "2024-05-03T05:35:55Z")

</div>

Exactly what you want is already available: [Kopfhörerplatine basierend auf MS6324 und TDA1308 bzw. LM4808M](https://forum.espuino.de/t/kopfhoererplatine-basierend-auf-ms6324-und-tda1308-bzw-lm4808m/1099).  
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](https://github.com/biologist79/ESPuino/blob/856445d157902c57ebc80ff76a05af87bae999cd/src/settings-lolin_d32_pro_sdmmc_pe.h#L106) 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](https://github.com/biologist79/ESPuino/blob/856445d157902c57ebc80ff76a05af87bae999cd/src/settings-lolin_d32_pro_sdmmc_pe.h#L105) you can invert this behaviour.

We already used MS6324, [UDA1334](https://forum.espuino.de/t/kopfhoererplatine-basierend-auf-uda1334-pj306b/705) and [PCM5102](https://forum.espuino.de/t/kopfhoererplatine-mit-pcm5102a-und-tda1308/40) 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.

---

<div class="post-metadata">

**Author:** ![kelapuress](https://forum.espuino.de/user_avatar/forum.espuino.de/kelapuress/32/3792_2.png) [@kelapuress](https://forum.espuino.de/u/kelapuress)\
**Post date:** [3. Mai 2024 um 06:29 UTC](https://forum.espuino.de/t/speakers-and-headphone-jack-with-i2s-input/2990/3 "2024-05-03T06:29:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kelapuress](https://forum.espuino.de/user_avatar/forum.espuino.de/kelapuress/32/3792_2.png) [@kelapuress](https://forum.espuino.de/u/kelapuress)\
**Post date:** [3. Mai 2024 um 06:30 UTC](https://forum.espuino.de/t/speakers-and-headphone-jack-with-i2s-input/2990/4 "2024-05-03T06:30:10Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![biologist](https://forum.espuino.de/user_avatar/forum.espuino.de/biologist/32/66_2.png) [@biologist](https://forum.espuino.de/u/biologist)\
**Post date:** [3. Mai 2024 um 06:47 UTC](https://forum.espuino.de/t/speakers-and-headphone-jack-with-i2s-input/2990/5 "2024-05-03T06:47:43Z")

</div>

> [@kelapuress](#):
>
> Does this have stereo output for speakers also? I see the MAX98357A on the base board but that gives mono output.

We have [mini4L](https://forum.espuino.de/t/espuino-mini-4layer/1661) 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.

> [@kelapuress](#):
>
> Another question, does the software control switching between headphone and speakers using this HP\_DETECT pin?

Yes.

> [@kelapuress](#):
>
> If so, where does it do it in the software?

> <https://github.com/biologist79/ESPuino/blob/856445d157902c57ebc80ff76a05af87bae999cd/src/AudioPlayer.cpp#L274>

---

<div class="post-metadata">

**Author:** ![kelapuress](https://forum.espuino.de/user_avatar/forum.espuino.de/kelapuress/32/3792_2.png) [@kelapuress](https://forum.espuino.de/u/kelapuress)\
**Post date:** [3. Mai 2024 um 09:03 UTC](https://forum.espuino.de/t/speakers-and-headphone-jack-with-i2s-input/2990/6 "2024-05-03T09:03:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![biologist](https://forum.espuino.de/user_avatar/forum.espuino.de/biologist/32/66_2.png) [@biologist](https://forum.espuino.de/u/biologist)\
**Post date:** [3. Mai 2024 um 09:45 UTC](https://forum.espuino.de/t/speakers-and-headphone-jack-with-i2s-input/2990/7 "2024-05-03T09:45:56Z")

</div>

Here we go: the schematics for the headphone-pcb I designed two years back or so for UDA1334: [Schematics\_UDA1334.pdf](https://forum.espuino.de/uploads/short-url/k0OYhtWt9QfrcdfHFKFlZEuaSDd.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.

> [@kelapuress](#):
>
> we’ll need 3 ICs

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

---

<div class="post-metadata">

**Author:** ![kelapuress](https://forum.espuino.de/user_avatar/forum.espuino.de/kelapuress/32/3792_2.png) [@kelapuress](https://forum.espuino.de/u/kelapuress)\
**Post date:** [4. Mai 2024 um 19:57 UTC](https://forum.espuino.de/t/speakers-and-headphone-jack-with-i2s-input/2990/8 "2024-05-04T19:57:24Z")

</div>

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](https://forum.espuino.de/uploads/default/original/2X/6/6773c99ebf9859ba0dac2b226239eaa3e7c7749c.jpeg)

---

<div class="post-metadata">

**Author:** ![biologist](https://forum.espuino.de/user_avatar/forum.espuino.de/biologist/32/66_2.png) [@biologist](https://forum.espuino.de/u/biologist)\
**Post date:** [4. Mai 2024 um 20:20 UTC](https://forum.espuino.de/t/speakers-and-headphone-jack-with-i2s-input/2990/9 "2024-05-04T20:20:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kelapuress](https://forum.espuino.de/user_avatar/forum.espuino.de/kelapuress/32/3792_2.png) [@kelapuress](https://forum.espuino.de/u/kelapuress)\
**Post date:** [5. Mai 2024 um 08:03 UTC](https://forum.espuino.de/t/speakers-and-headphone-jack-with-i2s-input/2990/10 "2024-05-05T08:03:00Z")

</div>

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
