Phipps Electronics

Order within the next 

FREE SHIPPING OVER $199

50,000+ ORDERS

WORLDWIDE SHIPPING

SSL SECURED

Building an Ohm-Meter with Arduino

Contents

Introduction

Often times, as a hobbyist you may not own a multimeter, Or, maybe you own one but you need to figure out the value of a resistor but you’re too lazy to get up and fetch your multimeter. You don’t even know how to read the colour codes. Maybe, you’ve got a big pile of resistors in your arsenal and need to find a desired valued resistor ASAP.
In such moments of crisis, this little trick may prove itself handy. All you will need is an Arduino and 1 known valued resistor.

Schematic

Here, we are attaching 2 resistors in series. The value of one is known and the other is unknown. We are reading the analog input of the node in the middle of the 2 resistors through our analog pin 1. From that, we can also determine the voltage of that point.
By applying the voltage divider rule, we can determine the value of the unknown resistor.

Voltage Divider Rule

The voltage divider rule states, that when resistors or loads are connected in series and voltage is applied. The voltage of the connecting points are fractions of the applied voltage and the value of that voltage depends on the value of the resistors and the applied voltage itself.

The formula is stated below,
The voltage across the unknown resistor =

In our case, we have 2 resistors in series and intending to measure the voltage across the unknown resistor which is directly connected to the ground.

Analog Input

We are already familiar with the analogRead() function. What this function basically does is, ask the function to read the voltage of a specific analog input pin. The Function reads the analog voltage of the point where that specific pin is connected, then converts the analog value of that voltage to a digital value as the Arduino has 10-bit Analog to Digital converter associated with the Analog input pins.

What Does a "10-bit Analog to Digital Converter" Mean?

It means, the Arduino divides the supply voltage of 5V into (2^8) or 1023 pieces.
The value of each piece is – (5/1024) = 4.88mV

It then checks the voltage that you are trying to read and what is the maximum multiplier of 4.88mV does the input voltage reach? That maximum multiplier of the minimum step size voltage is the output you get from the analogRead() function.

So, when the output is 0, we know that the voltage of that point is 0V and when the output is 1024, it means the voltage of that point is – 1024 * 4.88mV = 5V

The Code

				
					void setup() {
     Serial.begin(9600);
}
void loop() {
     float unknown_r_drop = analogRead(A0); // Voltage drop of unknown Resistor
     float known_r_value = 1000.0; // Value of known Resistor - 1k in my case
     float voltage_per_step = (5.0/1023.0); // Calculating the voltage value of each step size
     float v_drop_across_unknown_r = (voltage_per_step * unknown_r_drop); // Computing the voltage drop across Unknown Resistor
     float unknown_r_value = ((known_r_value * v_drop_across_unknown_r) / (5-v_drop_across_unknown_r)); // Determining the unknown value
     String resistor_value;
     resistor_value = String(unknown_r_value);
     Serial.println("Unknown Resistor value = " + resistor_value );
     delay(1000);
}
				
			

Preview

Code Explanation

We are reading the voltage across the unknown resistor. We already know the value of the first resistor. According to the voltage divider rule:

Next, let us consider that the analogRead() function gives us the value “X”

After expanding the equation, we end up with this:

We have just coded this simple equation and the Arduino calculates the unknown resistance with not exact accuracy, but you will be able to determine the value of the resistor.

Note, this technique will not work for all values of resistors. If you try to measure a resistor of a really large value keeping a relatively small valued known resistor, it may tell you that the value is infinity.

Now, why does that happen? We know through the voltage divider rule that the voltage drop is bigger across the bigger values of resistors. So, when a big valued resistor is attached, almost all the supply voltage drops across it, therefore, the analog to digital converter converts it to a value of 1023, which makes the below part of the equation zero, making the output value close to infinity. In such a case, use a larger valued of resistor as the known resistor.

SUBSCRIBE FOR NEW POST ALERTS

Subscribe to be the first to know when we publish a new article!
List Subscriptions(Required)

POPULAR POSTS

Scroll to Top