Pages: [1]   Go Down
Author Topic: Measuring resistance  (Read 1670 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
God Member
*****
Karma: 0
Posts: 572
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What is the best way to measure a resistance?

The only method I can find floating around on the net is to connect a capacitor and resistor in parallel across a digital pin and measure the time required for the capacitor to discharge.

Is it possible at all to do it using an analog input pin?

There must be an easier way!

Thanks,

Alex

Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You can measure/calculate a resistance using an analog input.  Wire your circuit up like the push button tutoria: http://www.arduino.cc/en/Tutorial/Pushbutton but replacing the pushbutton with the resistance you want to measure.  This makes a voltage divider, with the voltage in between the two resistances equal to:

voltage = 5 * x / (R + x)

where R is the known (pull-up) resistor and x is the unknown resistance you're trying to measure.  When you read this voltage with analogRead() you get a number between 0 and 1023, with 0 corresponding to 0 volts and 1023 corresponding to 5 volts, making the formula:

analog input = 1024 * x / (R + x)

Often, this value is all you need.  If you really need to know the actual resistance, use this formula (assuming I did my math right):

x = AR / (1024 - A)

where A is the value you got from analogRead().
Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 572
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Awesome.

Thanks heaps for your reply... I'll get to it!

Alex

Logged

Pages: [1]   Go Up
Jump to: