# Simple measurment of resistance with microcontroller

What is a simple way to measure resistance (in this case 0-100 kOhm) using micro-controller (I'm using STM32, it has 12-bit ADC, timer, but no comparator). I want it simple (not too many components) and cheap.

The first idea I had was to use ADC with voltage divider. However it brings down the problem to measuring voltage across known resistor what is hyperbolically dependent on the measured resistance, so actual precision varies greatly over the range of values of unknown resistor. It also requires the known resistor to be much smaller value than known one, but this should be fine if big precision is not required.

Requirements:

• Range: 0-100 kOhm
• Precision: at least 1 kOhm, preferred <100 Ohm, but actually I am curious (thinking about - other possible applications which might require better precision) how high (with precision) we can get without making too complicated circuits.
• What is the input impedance of your ADC? – starblue Oct 27 '13 at 12:39

Use a voltage controlled precision current source to feed a known current into the resistor. If the measured reading is either too low or too high, adjust the current source to be more appropriate. Take several readings and average.... Maybe 50 readings to counter the lack of bits in your ADC .

For high valus of resistance you will need to buffer the signal to the ADC with a unity gain opamp circuit because the ADC's input is quite low impedance.

The current source can be built using a DAC to set the demand. It'll need two transistors and two opamps for maximum flexibility.

You may think this is too complex but if you change your mind let me know. It is a decent method I might add.

The problem you encounter with a voltage divider is that that not only the voltage changes with different resistors but also the current through the overall resistance. So these three change with different measurements.

To measure resistance, you need to keep a constant current through your probe. If the current is constant the voltage-drop of the resistor is directly associated with the resistance due to U=I*R. (V=I*R)

If you want to measure 0-100kOhm with a Vadc, max=5V you have to apply 5V/100kOhm = 50µA using a 12bit ADC you can measure a minimum voltage of 5/2^12 = 1.22mV which is a minimum resistance of 1.22mV/50µA = 24.41Ohm which is simultaneously your precision.

If you use the resistance to be measured in series with a capacitor, and can sense the voltage on the capacitor, the RC time constant of the resulting circuit will be proportional to the resistance. A common measurement approach is to charge the cap to some level and then time how long it takes to discharge by some percentage. If one arranges things so the cap may be charged either through a known resistance or the unknown one, one may reasonably accurately determine the unknown one.