Help detecting a connector

hi guys and girls, i was wondering if anyone can help me, Im working on a project where I have a multi purpose connector, the idea is that in one usecase a charger would be connected, and in another use case some GPIO pins would be accessed. I need to distinguish between the use cases, and also know when no connector is present.

I have a gnd and three gpio pins set as input., at the moment im using one gpio shorted to ground to detect when a connector is present for one use case. A seperate GPIO is shorted to gnd to detect the second use case. this however isnt ideal as the GPIO needs to be used for other things. in each use case, the code checks if the pins are shorted to gnd in order to respond.

If I had access to 5v also then I would put a different value resistor in each connector and do an analogRead on the pin, but with only a GND im stumped.

can anyone think of a better way of doing this with just the GND and three GPIO? I could possibly set a GPIO as HIGH during setup and measure the result of analogRead on the other, then set it back as an input.... but that would briefly spike any connected gear with 5V on that line.

any help wouldbe greatly appreciated

Please post the schematic.

And which Arduino, you may be able to set the internal pullup on the analog pin and different resistors between the connector pins and GND.

1 Like

Some processors even have "strong" and "weak" internal pull up resistor options. :slight_smile:

I have done this on the AVR.

@anon57585045 .
That's why I asked "which Arduino".

I know, just waiting. I'd like to see the entire scheme. Including at least a glimpse of the "connected gear".

it will be running on a portenta h7

See reply #2.

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966#schematics-or-circuit-diagrams

thanks for your suggestion, I have set the Analogue IO as input with pullups, then using a 100k resistor and a 22k resistor I can distiguish between which cable is attached to the unit at bootup.
thanks a million.

You would be better off using an external pull up resistor for that. The internal resistance varies quite a lot.

Actually, reading contacts this way is a very common Arduino trick. It's just that you didn't mention a lot of details, such as whether you had an extra pin available, or expected to do this detection via an active signal pin. In other words, whether you have signal lines that are indifferent to resistive sense resistors in parallel.

We get a lot of posts here, where what seem like obvious statements, turn out not to be.

yes, the connector pin in question was being used before to sense if it was connected to GND at bootup with digitalRead. So as it happens all I had to do was switch it to an analogue pin on the arduino and use analogRead instead, allowing a variety of different options at bootup based on the resistor used.
if I were to use an external pullup resistor, what would be a good value to use?

If you had good results with the internal pull up, you can just mimic it with something in the range of 25k - 36k.

thanks

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