# Arduino Ohm Meter?

Hi Guys, I was wondering whether it is possible to use an Arduino as an ohm meter? I have seen a lot of documentation on Arduino voltmeters but nothing for measuring resistance.

Thanks Guys, Alex

Sure it’s possible. If you pull up an analog input pin with a resistor, then any unknown resistance connected to the pin and ground would cause the measured voltage to be reduced. You would need to scale and reverse the measurement value and I’m not sure of the usable resistance range that would result but those that like playing with the math could work it out.

By the way most ohm meters utilize the a similar (fixed voltage or current) method to determine a resistance value, being a passive component a resistor cannot be measured without applying some external voltage/current source to it.

Lefty

Thanks Lefty, i wired up a 10k pullup resistor and using the analogRead statement i get a value between 0 and 1023 on resistors connected between the pin and gnd. Does anyone know the math for converting the result from analogRead statement into a readable resistance value?

Thanks again, Alex

Another way to measure resistance with the Arduino's voltage-measuring analog inputs, is to build a constant-current circuit. This is a fairly simple transistor circuit that will make a constant, pre-determined current flow through a resistor. Then, you can measure voltage across the resistor and use Ohm's Law.

http://en.wikipedia.org/wiki/Current_source

The only slightly tricky part will be making a current source with a PNP transistor, so that the load (the unknown resistor) can be connected to Ground.

Hi Guys, I had a play around and have got the code working. thanks AWOL, the link was very helpful.

I know you guys can probably do this in your sleep but i thought i would post the code anyway.

``````int analogPin = 0;     // potentiometer wiper (middle terminal) connected to analog pin 3
// outside leads to ground and +5V
int raw = 0;           // variable to store the raw input value
int Vin = 5;           // variable to store the input voltage
float Vout = 0;        // variable to store the output voltage
float R1 = 10;         // variable to store the R1 value
float R2 = 0;          // variable to store the R2 value
float buffer = 0;      // buffer variable for calculation

void setup()
{
Serial.begin(9600);             // Setup serial
digitalWrite(13, HIGH);         // Indicates that the program has intialized
}

void loop()
{
raw = analogRead(analogPin);    // Reads the Input PIN
Vout = (5.0 / 1023.0) * raw;    // Calculates the Voltage on th Input PIN
buffer = (Vin / Vout) - 1;
R2 = R1 / buffer;
Serial.print("Voltage: ");      //
Serial.println(Vout);           // Outputs the information
Serial.print("R2: ");           //
Serial.println(R2);             //
delay(1000);
}
``````

Thank you all very much for your help, Alex

hmm does this Sketch really work?

I tried it with different resistor but the Arduino never got it right... e.g. for a 15k Arduino says 6.7...

could some one help me! Thx! Geko

I didn't run that sketch but I would expect if R1 was 10k and R2 was 15k you would get the following:

Vout = 3 volts buffer = (5/3)-1 = .66666 R2 = R1/buffer = 10/.6666 = 15.00

GekoCH, What did value of Vout did you get?

Voltage: 1.97 R2: 6.35

Geko

Geko, try swapping the 10k and 15k resistors.

WOW! You'are great! But why this config:

5v------10k---------Resistor------GND | Analog

befor it was

5v------Resistor---------10k------GND | Analog

Connecting the 10k resistor to +5v matches the calculation used in the code.

have fun!

I know you guys can probably do this in your sleep but i thought i would post the code anyway.

... you definitly did right. guys like me appreciate finding simple code. it's always good when you start to read as much as you can.

thx !