Detecting when an aux cable is conneceted on a TRRS breakout board

Hello everyone,

I'm working with an Adafruit TRRS Jack Breakout Board and need to detect when a plug is inserted by turning the ESP32’s internal LED on when connected and off when removed.

I'm using the RSw pin on the breakout board for detection, as it’s floating when the plug is connected. I've combined the Left and Right audio pins into a mono signal with two 10K resistors, then passed the signal through a 100nF capacitor to remove any DC component before sending it to pin 35. The RSw pin (yellow) is connected to pin 32 on the ESP32.

Here is the code that I'm using with no result

define AUX_DETECT_PIN 32  // Connect either RSw or LSw here
#define LED_PIN 2          // ESP32 built-in LED

void setup() {
  pinMode(AUX_DETECT_PIN, INPUT_PULLUP); // Use internal pull-up to handle floating
  pinMode(LED_PIN, OUTPUT);
}

void loop() {
  int auxStatus = digitalRead(AUX_DETECT_PIN);

  if (auxStatus == HIGH) {
    // Pin is floating, aux cable is connected
    digitalWrite(LED_PIN, HIGH); // Turn on LED
  } else {
    // Pin is grounded, no aux cable is connected
    digitalWrite(LED_PIN, LOW);  // Turn off LED
  }
  delay(100); // Small delay to debounce
}

Sleeve - This is the microphone pin (the sleeve or S in TRRS).
Right - This is the right audio pin (the first ring or R in TRRS).
RSw - This is the right switch pin. When the plug is not inserted, this pin is connected to the right contact. When the plug is inserted, this pin will float.
LSw - This is the left switch pin. When the plug is not inserted, this pin is connected to the left contact. When the plug is inserted, this pin will float.
Left - This is the left audio pin (the tip or T in TRRS).
Ring - This is the ground ring pin (the second ring or R in TRRS).

Do I need a pull-up resistor for RSw, or should I connect both RSw and LSw? Any insights or suggestions would be greatly appreciated!

Thank you!

This is a problem because you want the DC component of the jack for it to work. So having a series 0.1uF is going to block the information you need for it to work.

Please supply a link to this jack board.

You might want to look at this How to get the best out of this forum before you proceed any further.

Here's the link to the TRRS breakout board: https://www.adafruit.com/product/5764. The mono conversion from the Left and Right pins is functioning as expected, and I can confirm data input so that part works well.

The main issue I'm facing is detecting when the aux cable is connected. I’m attempting to use the RSw pin for this detection, but haven’t had any success so far. From my understanding, I should be able to detect the cable connection by using either of the switch pins (RSw or LSw), rather than needing both.

It is your circuit with the series capacitor.
Work out the time constant R*C and you will see that this signal is too short to detect.

You need the DC information about the state of those jack plugs and you need to detect a change by your software reading those levels.

Even without converting the Left and Right channels to mono and removing those components, I'm still unable to reliably detect the presence of the aux cable using the RSw pin.

RSw - This is the right switch pin. When the plug is not inserted, this pin is connected to the right contact. When the plug is inserted, this pin will float.

You can't detect a floating pin because it can read as anything. Normally the last thing you read the pin as, and over time it could be any logic level. So you need a pull resistor to the opposite logic level you get when the plug is not inserted.

Have you made the other changes like removing that series capacitor?