Arduino Ohmmeter

7.4K134

Intro: Arduino Ohmmeter

Arduino UNO Ohmmeter

Using a Wheatstone Bridge configuration. We will calculate the resistance of an unknown resistor using Kirchoff's Laws.

Part (1) Voltage Divider

Part (2) Calculating for Unknown Resistance

Part (3) Finished Product with Program

This example use the following:

(1) Arduino UNO

(1) External Battery Pack with (3) 1.5 Volt AA Batteries

(3) 10k Resistors

(1+) Test Resistors

(1) Software program capable serial port and ANSI emulation.

[NOTE] All electrical circuits must be handled with caution. Also I'm just an amateur trying to learn theory not a certified electrician. So if you make this circuit and are not certified. You are also an amateur trying to learn theory. Thus if you hurt yourself or your property from this post by proceeding to read or carry out actions to create the circuit that makes you in agreement that you're fully responsible for your actions.

Part 1 [Voltage Divider]

Using a voltage divider R1 and R3. [Note R1 and R3 must be the same] We can get the voltage of a external battery.

Read A0 Pin * 2 = external battery voltage (Reference between R1 and R3)

Example (1):

A0 reads 2.25 volts

2.25 * 2 = 4.5 external battery voltage.

With this arrangement of a voltage divider even if the external battery falls to 4.4 volts we can still get a good reading from our circuit.

Example (2):

A0 reads 2.2 volts

2.2 * 2 = 4.4 external battery voltage.

STEP 1: Part 2

Part 2 [Calculating for Unknown Resistance]
Using the Voltage Divider in a series circuit we discovered the external battery voltage from the left bridge. Now we will create right bridge. The right bridge it will consist of R2 a known resistance. From the right bridge and Kirchhoff's law of resistance we will determine the resistance of an unknown resistor at R4 or Rx using this formula:

(Rx)ohms = 10k * A1 / ((A0 * 2) - A1)

(try to match image)

A0 = voltage read from A0 pin

A1 = voltage read from A1 pin

Example (3)

Rx = Uses 470 ohm (gold band +/- 5% difference 23.5)

A0 = 2.25 (2250mv)

A1 = .20 (200mV)

Rx = 10,000ohm * 200mV / ((2250mV * 2) - 200mV)

Rx = 2,000,000 / 4500 - 200

Rx = 2,000,000 / 4300

Rx = 465 ohm

STEP 2: Part 3

Part 3 [Finished Product with Program]

(Attached are the txt file about how it works and the program)


I know this project has some weakiness yet to be discovered by myself or more likely others. However for the most part it does show how voltage and resistance measurements can take place using a Wheatstone Bridge. Allowing for other sensors to operate like a strain gauge, light sensitive diode, temperature sensor and much more.

For the software used mostly Hyperterm and VT100J emulation.

However using Putty Translation (CP866 manually type it in) with font based OEM and ANSI.

Anyone willing be to offer some *constructive* criticism to make the circuit more accurate is welcome.

Attached is the sketch for the microprocessor on the uno board: Here is the raw code:

// start copy here

#define A0IN 0

#define A1IN 1

int analogamount = 0; // used to convert voltage left bridge

int analogamount1 = 0; // used to convert voltage right bridge

float voltage = 0; // left bridge voltage

float voltage1 = 0; // right bridge voltage

float voltage2 = 0; // used for voltage correction

float answer = 0;

int cv = 0; // counter variable used screen drawing

void setup() {

analogReference(EXTERNAL); // use AREF for reference voltage

Serial.begin(9600);

set_screen();

}

void loop() {

analogamount = analogRead(A0IN);

analogamount1 =analogRead(A1IN);

voltage=analogamount * (4500 / 1024.00);

voltage1=analogamount1 * (4500 / 1024.00);

voltage2 = 0;

set_xy(23,1);

save_cursor_pos();

if(voltage == voltage1) {

set_xy(10,25);

repeat_char(10,0x20);

set_xy(10,47);

repeat_char(10,0x20);

set_xy(14,49);

repeat_char(10,0x20);

} else {

set_xy(10,25);

voltage = round(voltage);

voltage = voltage * .001;

Serial.print(voltage);

if( voltage < 1) { Serial.print("mV"); } else { Serial.print("V ");

}

set_xy(10,47);

voltage1 = voltage1 * .001;

Serial.print(voltage1);

if( voltage1 < 1) { Serial.print("mV"); } else { Serial.print("V ");

}

set_xy(14,49);

voltage2 = voltage * 2;

answer = 10000 * voltage1 / (voltage2 - voltage1); answer = round(answer);

Serial.print( (int) answer+1);

Serial.print(" Ohms ");

}

restore_cursor_pos();

delay(3000);

}

void save_cursor_pos(){

Serial.print("\x1B" "[s"); // save cursor position

}

void restore_cursor_pos(){

Serial.print("\x1B" "[u"); // restore cursor position

}

void repeat_char(int r,char c){

int rx;

for(rx = 0; rx != r; rx++){

Serial.print(c);

}

}

void set_xy(int x, int y){

Serial.print("\x1B[");

Serial.print(x);

Serial.print(";");

Serial.print(y);

Serial.print("H");

}

void set_screen(){

Serial.print("\x1B" "[2J");

set_xy(1,2);

Serial.print("Ohmmeter");

set_xy(3,2);

Serial.print("\xDA");

repeat_char(20,0xc4);

Serial.print("\xC2");

repeat_char(20,0xc4);

Serial.print("\xBF");

set_xy(4,2);

for(cv = 0; cv != 2; cv++){

Serial.print("\xB3");

repeat_char(20,0x20);

Serial.print("\xB3");

repeat_char(20,0x20);

Serial.println("\xB3");

Serial.print(" ");

}

set_xy(6,2);

for(cv = 0; cv != 3; cv++){

Serial.print("\xB3");

repeat_char(20,0x20);

Serial.print("\xB2");

repeat_char(20,0x20);

Serial.println("\xB2");

Serial.print(" ");

}

set_xy(7,25);

Serial.print("R1 (10K)");

set_xy(9,1);

Serial.print("\xC4\xC1\xC4");

repeat_char(19,0x20);

Serial.print("\xB3");

repeat_char(20,0x20);

Serial.print("\xB3");

set_xy(10,1);

Serial.print("\x1B[10;1H" " \xC4 ");

repeat_char(19,0x20);

Serial.print("\xB3");

repeat_char(20,0x20);

Serial.print("\xB3");

set_xy(11,1);

Serial.print("\xC4\xC4\xC4");

repeat_char(19,0x20);

Serial.print("\xB3");

repeat_char(20,0x20);

Serial.print("\xB3");

set_xy(12,2);

Serial.print("\xC2 ");

repeat_char(19,0x20);

Serial.print("\xB3");

repeat_char(20,0x20);

Serial.print("\xB3");

set_xy(13,2);

for(cv = 0; cv != 3; cv++){

Serial.print("\xB3");

repeat_char(20,0x20);

Serial.print("\xB2");

repeat_char(20,0x20);

Serial.println("\xB2");

Serial.print(" ");

}

set_xy(16,2);

for(cv = 0; cv != 3; cv++){

Serial.print("\xB3");

repeat_char(20,0x20);

Serial.print("\xB3");

repeat_char(20,0x20);

Serial.println("\xB3");

Serial.print(" ");

}

set_xy(18,2);

Serial.print("\xC0");

repeat_char(20,0xc4);

Serial.print("\xC1");

repeat_char(20,0xc4);

Serial.print("\xD9");

set_xy(7,46);

Serial.print("R2 (10K)");

set_xy(14,25);

Serial.print("R3 (10K)");

set_xy(14,46);

Serial.print("Rx");

} // end copy here

4 Comments

hi,

How do you get : (Rx)ohms = 10k * A1 / ((A0 * 2) - A1)

It is not that clear,

Regards

This is an interesting topic and I thank you for sharing - I look forward to trying this myself in the near future. One thing I noticed is that the equation states one format but then the actual calculations performed at different.

Equation stated:

(Rx)ohms = 10k * A1 / (A0 * 2) - A1

However it is worked out as the following:

(Rx)ohms = 10k * A1 / ((A0 * 2) - A1)

Order of operations would say that 10k * A1 / (A0 * 2) would be calculated before subtracting A1. Which is correct?


Hi Brian,

the left bridge was there to give
a base line voltage reading.

Know the question was the equation.
However going to work through it.

R1, R3 and R2 = 1k, R4 is going to
be the unknown resistance and the
supply voltage will be 5v

So if the voltage was low say 4.9v
instead of 5v the equation would
still work out.

for instance a simple balanced
voltage divider (with R1 and R3 equal)

5v -----/\/\/\-----/\/\/\-----|:-
R1 | R3
2.5v

4.9 -----/\/\/\-----/\/\/\-----|:-
R1 | R3
2.45v

The left bridge was A0
So A0 * 2 would provide a base line.

Next we would look to A1 and the
entire equation.

5v -----/\/\/\-----/\/\/\-----|:-
R1 | R3
2.5v (A0) 2500mv

5v -----/\/\/\-----/\/\/\-----|:-
R2 | R4
833mv (A1)

So what is the resistance of R4?

R1, R3 and R2 = 1k

A0 = 2.5v (2500 mV)

A1 = .833 (833 mV)

Deeper

R4 = 1k * A1 / ((A0 * 2) - A1) or

R4 = 1k * .833 / ((2.5 * 2) - .833) or

R4 = 1k * .833 / (5 - .833) or

R4 = 1k * .833 / 4.167 or

R4 = 833 / 4.167 or

R4 = 199.9

R4 was actually a 200 ohm resistor this
case.

So the equation would be as you worked
out I think it was a typo on my part
thought I fixed that.

in the program actually multiply before
the subtract so the program worked.

I will correct the error. Thank you
good catch 8)