Hi,
I am building a volt meter and would like to measure 0-100V but find that the readings are inaccurate, compared to 3 different brand digital multimeters, which all show roughly the same voltage.
The battery bank consist of 2x 12V batteries, which measures 25.6V on a DMM. On the Arduno serial monitor, however I get between 24.6V and 25.10V, measured every 1000ms.
The voltage divider consist of a 1Mohm resistor for R1, which measures 998000ohm on the DMM, and 3x 1Kohm resistors on R2 measuring 29200ohm. I used these values in the sketch as part of the calculation.
When I measure the values on A0 + ground, with my DDM set to "2V" I get readings of .609 - .701v, yet the serial console shows readings between 668.18 and 745
millivolt: 668.18
input_voltage: 24.94
millivolt: 722.73
input_voltage: 25.26
millivolt: 672.73
input_voltage: 25.58
millivolt: 731.82
input_voltage: 21.91
millivolt: 590.91
input_voltage: 27.66
millivolt: 786.36
input_voltage: 20.47
millivolt: 700.00
input_voltage: 24.94
millivolt: 704.55
input_voltage: 24.94
The sketch:
/*
Voltage divider based on: http://www.lediouris.net/RaspberryPI/ADC/monitor-12v.html
0V - 100V
R1: 1000Kohm
R2: 3x 100Kohm
*/
float voltageOnA0 = 0.0;
float input_voltage = 0.0;
float temp=0.0;
float r1=998000.0;
float r2=29200.0;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
pinMode(A0, INPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float millivolt = sensorValue * (4.65 / 1023.00) * 1000; // 4.65 was measured on the Arduino 5V and AREF pins
Serial.print("millivolt: ");
Serial.println(millivolt);
delay(1000);
//Conversion formula
int analog_value = analogRead(A0);
temp = (analog_value * 4.65) / 1023.0; // 4.65 was measured on the Arduino 5V and AREF pins
input_voltage = temp / (r2/(r1+r2));
if (input_voltage < 0.1)
{
input_voltage=0.0;
}
Serial.print("input_voltage: ");
Serial.println(input_voltage);
Serial.println();
}
How do I get the same readings as on my DMM?