I wish to measure the voltage on a 12 v deep cycle battery. Fortunately, it is not in an automobile or other situation with large voltage spikes.
A voltage divider (if used) to keep the voltage below 5V max would look something like 3 x 10K resistors. The junction of the lower 2 resistors would be input to A0 of the Arduino Uno (which I am using). Using this arrangement means that for a .5v change on the battery, the Arduino will see about .5 x .33 or .167V which equates to about .167 x 1024 = 170 points of analog input (which is probably too small a range for my purposes).
Looking at my attached diagram, I want to create a 10v voltage supply using a resistor and zener diode. I am guessing I would need about 560 ohm resistor (R1) to provide about 5mA current to the zener. Is this enough current to keep the zener clamping the voltage at 10V and remain stable?
Can I use a 10v zener (or stack 2 5v zener diodes) to establish 10v supply and connect this to the ground connection of the Arduino?
Finally, I would attach the +ve battery terminal to A0 (or another analog input) on the Arduino. With luck, the Uno would see the voltage drop across the resistor only which would cycle between 2.5 and 3 volts as the voltage changes from 12.5 to 13 volts. I would still add over voltage protection on the analog pin just in case! In effect this will provide about 3 times the range for the analog input. And if this would work.....
Looking forward to answers. If possible, let me know any pitfalls out there which would mess this up.
A voltage divider (if used) to keep the voltage below 5V max would look something like 3 x 10K resistors. The junction of the lower 2 resistors would be input to A0 of the Arduino Uno (which I am using).
You only need two resistors, but let's assume a 10/30 voltage divider which could be made with three 10K resistors.
You'll read 1023 with 15V applied, which is a resolution of about 3mV. How much resolution do you need?
Zeners are a bad solution in voltage measuring dividers.
They drift with temperature and are non-lineair.
A simple resistor divider with the right code can read to ~0.02 volt.
An opamp that subtracts 10volt can be 3x better.
Good enough for a lead/acid battery.
If you want better, you have to keep track of charging/discharging, add a self-discharge timer, temp sensors, etc.
Leo..
Zeners drift with temperature. Since I will have a constant temperature environment, should not be too great a problem. And the newer ones are more temperature stable.
I am using a resistor divider (using 3 x 4.6k ohm) resulting in a .167 volt resolution which will work for the time being. Obviously this is the simplest answer.
Unfortunately, I was really interested in floating the ground voltage to +10 to battery ground and making this the ground point(0 voltage) for the Uno. Thus putting +13 battery volts to A0 is only +3V to ground as far as the Uno is concerned. Since I am fairly new to electronics, I was hoping that my questions would be answered (proving either I knew what I was looking at or - most likely - lost in space).
I will look into the opamp idea to see how I can subtract 10v.
Try this.
Good enough resolution for a 12volt lead/acid battery.
Divider uses only 75uA from the battery.
Leo..
/*
0 - ~17volt voltmeter
works with 3.3volt and 5volt Arduinos
uses the internal 1.1volt reference
10k resistor from A1 to ground, and 150k resistor from A1 to +batt
(1k8:27k or 2k2:33k are also valid 1:15 ratios)
100n capacitor from A1 to ground for stable readings
*/
float Aref = 1.075; // change this to the actual Aref voltage of ---YOUR--- Arduino (1.000 - 1.200), or adjust to get accurate voltage reading
unsigned int total; // A/D output
float voltage; // converted to volt
//
void setup() {
analogReference(INTERNAL); // use the internal ~1.1volt reference, change (INTERNAL) to (INTERNAL1V1) for a Mega
Serial.begin(9600); // ---set serial monitor to this value---
}
//
void loop() {
analogRead(1); // one unused reading to clear old sh#t
for (int x = 0; x < 16; x++) { // 16 analogue readings and 1/16 voltage divider = no additional maths
total = total + analogRead(1); // add each value
}
voltage = total * Aref / 1024; // convert readings to volt
// print to serial monitor
Serial.print("The battery is ");
Serial.print(voltage);
Serial.println(" volt");
total = 0; // reset value
delay(1000); // readout delay
}
The analog input is designed for optimal source impedance of about 10k. I normally strive for about 45k.
Be sure to put the capacitors in the circuit. Primary cap, on analog input to ground of about .01 - .1 uf.
Other caps around the system will probably help also.