# Impedance of headphone jacks and detecting connection

I was wondering if someone can illuminate the impact of a headphone output's impedance, but more importantly if my assumption is correct that my question actually pertains to impedance!

I have been using a circuit which worked great... until with another audio source (ie computer, ie soundcard) it stopped working as it did before and I was left scratching my head why. As you can see with the circuit below:

• 2 100k resistors mix down left/right channels to mono
• a 100k pullup resistor
• a Schottky diode to prevent negative voltages coming to the Arduino digital input

The reasoning here is that if the audio jack isn't connected (ie supplying a low voltage audio signal) my digital pin will detect the 5V pullup and therefore be able to determine that my audio jack isn't connected to anything. This worked great until I needed to apply this circuit to a different motherboard and I saw that the pullup was in fact actively biasing the input upwards resulting in my digital input pin detecting HIGH while in fact the audio signal was active.

Initially my pullup was 10k. Then on another motherboard I started noticing the biasing, which was prevented by increasing it to 100k. However on the motherboard I'm working with now, even the slightest pullup biases the signal upwards.

It leads me to question what it is about difference audio sources (audio boards) which exhibits this variation in outcomes. Can anyone explain what's going on? Is my unfounded hunch of impedance anywhere near true? I'd love to know.

And eh... if you have a killer tip about detecting when an audio jack is connected or not I'd love to know too, but the above is my main question

If all resistors are 100k, then if only one contact is made, you will have 2.5 V (or somewhat less) on the Arduino input - which is not a valid logic level.

If both contacts are made, you will be down to 1.6 V which is a plausible LOW, but you would be better to have R2 and R3 as say, 33k.

I presume the Schottky is to isolate the audio from the logic. Schottkys are however, somewhat leaky. This is good insofar as it means that the Arduino input is not left floating when the jack is inserted, but may not provide adequate isolation. A silicon diode would probably be better, but how are you going to not have the input floating?

Ugh, yes that makes sense about changing the values of the resistors. Also thanks about the tip for a silicon diode rather than Schottky. You're right about why I'm using it.

Do you have any insights on what could cause difference motherboards/soundcards to be more or less prone to being biased by the pullup? On my laptop (macbook) and another motherboard that I was working with before, it wasn't an issue.

How about a diode pump to detect the music ? Diode/capacitor/pull down resistor ?

So that's what that's called!! I stumbled upon this last week and love how it works. Yes, a diode pump would be great as a mechanism to detect active audio.
My main question was if anyone had some insight into why I was seeing these differences between difference motherboards, and if those differences pertain to varying impedance or some other characteristic of the motherboard/soundcard. But yes, diode pump... thank you for teaching me that name!

Usually there is a series capacitor on the output to block the DC bias. ...Since the soundcard probably runs from a single (positive) 5V supply, the amplifier-output is normally biased so the signal can swing (relatively) positive and negative, and with the capacitor blocking the bias it can swing truly positive and negative.

I don't know of an easy way to check if there's a connection (assuming no signal).

Usually the (AC) impedance is low. It should be low compared to the load. Headphones are typically about 32 Ohms and line inputs are typically 10K. I think most soundcards (and all laptops) can drive headphones, the AC impedance is in the low-Ohm range.

With the diode, you also need a pull-down resistor on the Arduino input to keep it from floating-up. (That can be 1M so it doesn't mess-up your other bias calculations).

The problem is the diode voltage drop... You won't get anything if the signal is less than about 0.6V with a regular diode or 0.2V with a Schottky. That might be OK if you have a "loud signal" but sometimes it's a problem. (I suppose you could add bias to that...)

Your series diode has the same issue... Usually, the diode is "backwards" and in parallel with the Arduino input to protect the Arduino from negative voltages. You also need a series current-limiting resistor which you already have so the diode doesn't "short out" the audio signal. But, the Arduino already has "small" built-in "protection diodes" and with a 10K or greater series resistor you won't burn-out the diodes.

There is similar op-amp circuit called a Peak Detector (or "envelope follower"). It generally requires dual power supplies if you want it to go all they way down to zero and up to 5V. I've made a few sound activated lighting effects and they ALL use a peak detector. (Note that you do loose any frequency information... The peak detector only gives you loudness.

False assumption I'm afraid, audio outputs are sometimes DC-blocked with a capacitor, sometimes not. If blocked your circuit will simply charge the DC-blocking capacitor and rise up to 5V anyway.

You need to detect the AC impedance, not DC resistance.

You can get audio jacks with internal switches - usually intended to act as a feed-through to an internal speaker when nothing is plugged in. Will not tell you if audio is present, but will tell you if the plug is inserted into the jack.

You could also use a jack intended for audio plus microphone, that has top-ring-ring-sleeve connections. With a speaker only plug, the sleeve and 2nd ring will both contact the sleeve, allowing you to detect the short as an indication the plug is inserted.

Thank you!

Agreed. For my case I didn't care about the audio or even the level. Logical LOW meant audio jack connected and HIGH meant disconnected.
I've since played with some op amps too to boost the level to a [0-5]V range. I was applying a peak detector circuit after the op amp (which is afaic close to the diode pump pattern, wouldn't you say?). Finally I applied an op amp as a comparator with a low threshold (~0.25V), which let me determine digitally whether there was any audio playing or not.

Sigh - Damnit, I just wanted to know it the audio jack was connected or not but I'm not mad I learned some things along the way Thanks for your additions.

Interesting, thanks! How does one detect/measure AC impedance?

@david_2018 Thanks for those ideas! In my case the internal switch either shorts with one of the audio channels (inserted) or it's floating (not inserted). Without influencing the audio channel, how would you detect these states?

Its not as straight-forward, you have to inject a signal and measure the response. The injection could be a current signal or through a known resistor or capacitor (forming a potential divider with the impedance to measure).

Well, I'm going leave this until the next time I encounter this issue then. Thanks for all the input!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.