# Detecting open/closed (impedance) condition between pins of external unit

I’m trying to detect the impedance condition between pins on an external unit. The external unit is not powered (at this stage).

There is a connector block that covers the pins for termination purposes and there are three pins (5, 6 and 7).

Typically this test is done with a multimeter, but I am looking to replicate it with an Arduino. The resistance between two pins is measured, and the expected results are shown below:

5 & 6 = open condition (i.e. maximum impedance)
5 & 7 = closed condition (i.e. less than 5 ohm)
6 & 7 = open condition

So if the Arduino measures an open condition between 5 & 6, a green LED comes on. If it measures a closed condition, a red LED comes on etc etc.

I’ve attempted using the program below (excluding constants):

void setup() {
// initialize the LED pins as an output:
pinMode(led, OUTPUT);
pinMode(ledGreen0, OUTPUT);
pinMode(ledRed0, OUTPUT);

// initialize serial communications:
Serial.begin(9600);
}

void loop()
{
// setting arduino led low
digitalWrite(led,LOW);

// read the value of the A0:
int A0 = analogRead(condition0);

// condition between 5 and 6
if(A0 < 1){
digitalWrite(ledGreen0,HIGH);
digitalWrite(ledRed0,LOW);
} else {
digitalWrite(ledRed0,HIGH);
digitalWrite(ledGreen0,LOW);
}
// print the analog value:
Serial.println(A0);
delay(10); // delay in between reads for stability

Am I on the right lines or have I over-complicated the program? I was also wondering whether there might be a much simpler way of doing this too. Any guidance is appreciated.

``````int A0 = analogRead(condition0);
``````

You are reading the voltage from an unpowered device? How's that working for you?

PaulS: ``` int A0 = analogRead(condition0); ```

You are reading the voltage from an unpowered device? How's that working for you?

In the example of pins 5 & 6:

I've applied 5V to pin 6, then I have a link from pin 5 through a resistor to ground. Finally taking a link from between pin 5 and the resistor to A0.

The external unit is not powered (at this stage).

What happens at a later stage?

jremington: What happens at a later stage?

The unit becomes powered and the relays inside are energised. And then the conditions become:

• 5 & 6 open (as before)
• 6 & 7 closed

A potentially serious problem with your approach is the possibility of "ground loops" -- a common situation where the grounds of different devices are at different potentials. This can easily destroy an Arduino, and sometimes even a laptop that is powering an Arduino.

Unless you are certain that the mystery device outputs are isolated from ground, the safest approach is to use optoisolators.

jremington: A potentially serious problem with your approach is the possibility of "ground loops" -- a common situation where the grounds of different devices are at different potentials. This can easily destroy an Arduino, and sometimes even a laptop that is powering an Arduino.

Unless you are certain that the mystery device outputs are isolated from ground, the safest approach is to use optoisolators.

Thanks for the feedback. I shall certainly consider this point further.

Would you still recommend my approach providing I use optoisolators, or do you see a better solution to identify the conditions between the pins?

Optoisolators would be a perfectly fine and very safe solution, and can also be read by a digital input. No need to waste an analog pin.