Friday 20 February 2015

Arduino as Voltmeter

First let's forget about Arduino
Voltmeter is used to measure voltage between two points. we always measure/connect the voltmeter parallel to the load.

do you ever get the doubt
why do i always connect voltmeter in Parallel to the load not in Series?

voltmeter

simple answer for that is the voltage is same in the parallel circuit. The same voltage that represent in load is same that will go through the voltmeter (But Why? I didn't understand the answer for it)


Using Arduino to Measure Voltage :
Arduino ADC's are capable of Measuring voltage with-in range of 0-5 volts. so if we wanted to measure voltage below 0-5 volts we simply connect the point where we wanted to measure voltage and two grounds and by performing analogRead() we can know the voltage at that point.

But What if we wanted to measure the voltage greater than 5 volts using Arduino?
we can don this by using Voltage Divider.
Voltage divider is nothing more than two resistors connected in series with battery. As Name implies the two resistors in series are used to divide the applied voltage.
voltage divider

the applied voltage V = Vr1 + Vr2

Vr1 = V * R1 /(R1 + R2)
Vr2 = V * R2/(R1 + R2)

which is also known as voltage divider rule.

from the above formula's if we know the voltage at the One resistor we can find the overall voltage supplied to the voltage divider circuit.
from Ohm's law. v directly proportional to R.
by using different combinations of Resistor we can reduce the voltage at the measuring point at which Arduino is used to measure the voltage at R2,by using that value we can measure the overall voltage with the help of the above formula.
Arduino Voltmeter
typical combinations of R1 and R2 is 100k and 10k respectively for 0 to 55 volts measurement

Arduino ADC has an 10 Bit Resolution or 4.9 mv for unit.

The code to find the voltage is

#define R1 100000 // Value of R1 Resistor
#define R2 10000 // Value of R2 Resistor
void setup(){
Serial.begin(9600); // start the serial communication
pinMode(A0,INPUT);
}//end of setup
void loop(){
int vr2 = analogRead(A0);
vr2 = vr2 * 0.0049;
Serial.print("The voltage is");
Serial.print(vr2*(R1+R2)/R2);
}

No comments:

Post a Comment