An Arduino auto ranging ohmmeter is easy to implement using an Arduino Uno or other Arduino development boards. And depending on the implementation, it can rival the accuracy of commercial digital ohmmeters available in the market.

To better appreciate an auto ranging Arduino ohmmeter, let us first create a simple ohmmeter using an Arduino Uno development board. After studying the underlying theory behind its operation, we will assemble a more accurate, full-pledged auto ranging ohmmeter.

## The Simple Arduino Ohmmeter

A simple Arduino ohmmeter schematic diagram is shown below. It uses an Arduino Uno development board and a 10kΩ reference resistor (**R _{ref}**) in series with the resistor being tested (

**R**).

_{x}The following Arduino IDE sketch will display the value of the unknown resistor **R _{x}** on the Arduino IDE’s serial monitor.

#define Rref 10000.0 void setup() { Serial.begin(9600); } void loop() { uint16_t x = analogRead(A0); float Rx = Rref * x/(1024 - x); Serial.println(Rx); delay(2000); }

Here is a screenshot of the output of the sketch shown above. A resistor with a value of 4.7kΩ and a tolerance of 1% was used as **R _{x}**. The output shows a value of 4.670kΩ. However, it sometimes fluctuates to 4.649kΩ. The measured value looks close enough to the actual value of the resistor. Considering that a 1% tolerance is equal to 47Ω, we expect to get a value between 4.653kΩ and 4.747kΩ.

## Prelude to Arduino Auto Ranging Ohmmeter

### How is resistance measured?

In an Arduino ohmmeter, the unknown resistance of a resistor is measured indirectly using Ohm’s Law.

The Current (I) flowing into a circuit is equal to the impressed Voltage (V) divided by the circuit Resistance (R).Ohm’s Law

Using the above equation, if we know the voltage (V) across the resistor and the current (I) flowing through it, we can calculate its resistance value.

The voltage (V) across the resistor is easily measured by connecting it to the ADC (Analog to Digital Converter) pin of an Arduino development board. **But we need a way to calculate the Current (I) flowing thru it so we can compute the Resistance R.**

### The Voltage Divider Circuit – Computing the Current (I)

There is a technique used to compute the current (I) thru an unknown resistor. The technique involves placing another resistor with a known value in series with the unknown resistor. The resulting circuit is known as a Voltage Divider Circuit. Please see Figure 4 below.

In the voltage divider circuit above, **R _{ref}** is the resistor of a known value and

**R**is the unknown resistor being measured.

_{x}**V**will be read and measured by an ADC, hence, let us assume that this is a known voltage.

_{Rx}The input voltage **V _{ref}** is divided between the two resistors in series,

**R**and

_{ref}**R**. Therefore,

_{x}and the voltage **V _{Rref}** across the known resistor

**R**is,

_{ref}Since **R _{ref}** is of a known resistance and we already know the voltage across it, we can now compute the value of

**I**, the current passing thru it.

_{Rref}The current **I _{Rref}** is the same current flowing thru the unknown resistor

**R**. So, it follows that,

_{x}Finally, to compute the resistance of the unknown resistor, **R _{x}**, we substitute Equation 0.4 in the resistance formula below.

Rearranging Equation 0.5, we get the final equation for computing **R _{x}**.

### Analog to Digital Converter – Measuring Voltage Across the Resistor

The voltage across the resistor being measured is fed to the ADC of an Arduino development board. Arduino Uno’s ADC has a resolution of 10 bits or 2^{10}, which is equal to 1024. This means that the reference voltage for the ADC is divided by 1024. Representing** **the ADC output reading with the variable **x**, **V _{Rx}** can be computed using the formula:

Also, given the value of **V _{Rx}**, which is the input to the ADC, we can find the value of

**x**by using the formula:

Caveat:See Reference on analogReadResolution()

The Arduino’s Due, Zero and MKR Family boards have 12-bit ADC capabilities but are by default set to 10-bit resolution. If they are run in 12-bit resolution by calling analogReadResolution(12), the constant 1024 must be replaced with 4096.

Using Equation 1 and Equation 2.0 as mentioned above, we can compute the value of the unknown resistor **R _{x}** if we have the ADC output reading

**x**.

In an Arduino IDE sketch, we may use the following code to compute the value of **R _{x}**:

#define Rref 10000.0 void setup() { uint16_t x = analogRead(A0); float Vrx = x * 5.0/1024 //compute voltage across resistor float Rx = Rref * Vrx /(5.0-Vrx); //compute resistance

### Computing Rx as a Function of x

The Equation 1 above for computing the value of the unknown resistor **R _{x}** is based on a pre-computed value of

**V**. Actually there is a more simple formula for figuring out the value of

_{Rx}**R**. The output value

_{x}**x**of the ADC can be used to directly compute

**R**. The formula is:

_{x}Notice the similarity of Equation 1 & Equation 3. The voltages, **V _{ref}** and

**V**, were simply replaced with their equivalent ADC values.

_{Rx}Let’s do a little exercise. We’ll try to prove that Equation 1 and Equation 3 are indeed equal to each other.

First, using the voltage divider circuit in Figure 2, the value of the voltage **V _{Rx}** (again using Ohm’s Law) is,

**V _{Rx}** is fed into the ADC, so we can use Equation 2,

Equating Equation 4 and Equation 2.0, we have,

Using the cross multiplication method,

Move **V _{ref}** and

**1024**to the right side of the equation.

Cancel out **V _{ref}**.

We need to remove the variable **R _{x}** that is on the right side of the equation. Multiply the terms of the numerator and then separate the two terms.

Move the second term containing the variable **R _{x}** to the left side of the equation.

Factor out **R _{x}**.

Multiplying both sides of the equation with 1024, we get,

Finally move the term in the parenthesis to the right side of the equation.

This shows that we can directly use the ADC output** x**, which is the value from the analogRead() function, to compute the value of **R _{x}** without the need to compute the value of

**V**.

_{Rx}### The Ohmmeter Accuracy

Referring to Figure 4 above, let’s compute **V _{Rx}** in terms of the two series resistors.

Now, assume the following resistor values: **R _{ref} = 10KΩ** and

**R**. Let’s compute

_{x}= 10KΩ**V**using Equation 4.

_{Rx}Compute** x **using Equation 2.1.

Let us do the same computation for the values of **R _{ref} = 10KΩ** and

**R**.

_{x}= 1KΩAgain, compute for **R _{ref} = 10KΩ** and

**R**.

_{x}= 100ΩUsing the three (3) computed ADC values, compute **R _{x}** using Equation 3.

Below is a table of the above computations.

R_{ref} |
R_{x} (Actual) |
V_{Rx} |
ADC (x) |
R_{x} (Computed) |

10kΩ | 10kΩ | 2.5V | 512 | 10.00kΩ |

10kΩ | 1kΩ | 0.4545V | 93 | 0.9989kΩ |

10kΩ | 100Ω | 0.0495V | 10 | 98.6Ω |

If you compare column 2, **Rx (Actual)** and column 5, **Rx (Computed)** of the table shown above, you will notice that there are discrepancies between the actual **R _{x}** values and the computed

**R**values of row 2 and row 3. Only the first row has the exact value of the computed

_{x}**R**value. Also, take note that row 2 has a lower discrepancy compared to row 3.

_{x}To clearly see the problem, let us take a second set of computations. This time, instead of a **10kΩ R _{ref}**, let’s use a value of

**1kΩ for R**.

_{ref}**Rref = 1kΩ and Rx = 10kΩ**

====================================

**Rref = 1kΩ and Rx = 1kΩ**

====================================

**Rref = 1kΩ and Rx = 100Ω**

Here is the table for the second set of computations.

R_{ref} |
R_{x} (Actual) |
V_{Rx} |
ADC (x) |
R_{x} (Computed) |

1kΩ | 10kΩ | 4.545V | 931 | 10.01K |

1kΩ | 1kΩ | 2.5V | 512 | 1.00K |

1kΩ | 100Ω | 0.4545V | 93 | 99.89 Ohms |

Studying the two tables will highlight the facts about the voltage divider circuit being used to measure the resistance of the unknown resistor **R _{x}**.

- The most accurate measurement of the value of
**R**occurs when_{x}**R**and_{x}**R**are equal._{ref} - The higher the difference of the values of
**R**and_{x}**R**the less accurate the measurement will be._{ref},

To reduce the error in the measurement of resistance, a solution is to use different values for **R _{ref}**. It can be implemented by manually switching reference resistors from a bank of resistors during a measurement.

Or better yet, automatically select and switch the proper value of **R _{ref}** electronically, and controlled by software.

**That leads us to an Arduino auto ranging ohmmeter**.

## Arduino Auto Ranging Ohmmeter, Part 2

## Related Articles on Arduino Auto Ranging Ohmmeter

### Hardware

NodeMCU ESP32S Pin Configuration

NodeMCU V3 ESP8266 Pinout and Configuration

How to Save and Restore ESP8266 and ESP32 Firmware

How to Test NodeMCU V3 Using Esptool

How to Connect a DS3231 to NodeMCU V3

### Software

How to Install Arduino IDE on Windows 10

How to Set up Arduino IDE for ESP8266 Programming

How to Install Esptool on Windows 10

## References on Arduino Auto Ranging Ohmmeter

Ohmmeter Using Arduino – circuitstoday.com – diode in series with reference resistors

Arduino Based Auto-Ranging Ohmmeter – simple-circuit.com – transistor switch

Resistomatic – an Arduino-based autoranging ohm-meter -blog.rareshool.com – simple resistor bank, no diodes, no transistors

Arduino Digital Multimeter

How accurate is an Arduino Ohmmeter?

Why ADC/1024 is correct, and ADC/1023 is just plain wrong!

Online Equation Writer