Android Headphone Jack Button Wiring?

596 Views Asked by At

I am trying to figure out how to use the headphone jack to trigger an action in my app, using a custom button. I have some code in place that will detect when I press a button on a headset plugged into the port, but if I plug a TRRS cable into the port and short the pins, I get nothing.

I found this: https://source.android.com/devices/accessories/headset/plug-headset-spec

But it says that R1 is supposed to have 0 ohms, so won't shorting it cause it to do something? The headset has no external voltage to it, so I didn't think I'd have to apply voltage to my circuit. And what does R1 represent? Play, pause, mute, or other? Can anyone point me in the right direction to sort this out?

1

There are 1 best solutions below

0
sureshot007 On

Ok, I figured it out. After much testing with many resistors, I finally realized how it works.

On the TRRS plug, there are 4 rings - R1 (tip) and R2 are the spearkers, R3 is ground, and R4 (base) is for the microphone.

Shorting R4 to R3 is supposed to trigger the "play/pause" button action.

The part I didn't understand is that the circuit expects there to always be resistance on the circuit due to the microphone. So, when you plug it in, there needs to be at least 1100 ohms of resistance across R4-R3 in order for the phone to think there is a microphone plugged in. There is a lot of variance on how much resistance. In my testing, 1100 ohms worked, as did 4400 ohms. Without this resistance, it thinks there is only speakers, and ignores any button signals.

Where I screwed up is that I thought it needed the resistance only when the button was pushed. Nope, it needs to be there constantly, so you put the resistor in the circuit in parallel with the switch.

Hope this helps someone else out in the future that also might not have a great handle on hardware.