Circuit to Measure Supply voltage

Thread Starter

joshagirgis

Joined Aug 27, 2018
11
Hi Everyone,

Today I want to build a circuit that measures the supply voltage from a battery! I am using an Arduino for prototyping right now. Basically the concept is to measure a battery supply of 12 volts. I am using a buck regulator to step down the 12 volts to a 5 volt supply for the arduino. However I want to measure the 12 volt supply using an analogPin to tell whether or not we go below 12 volts.

(My system will stop working below 11.9v).

I have tried to step down the 12 volts using a 47.6kohm and 10kohm voltage divider but it was wildly inaccurate. The ADC would measure 2.58 volts when my multi-meter would measure 2.22 volts. This leads me to believe that either the resistors I had were probably 5% trash or that the adc is reading incorrectly, or the multi-meter is trash. As a quick fix, I adjusted my code to the resistance measured on the multi-meter and computed the supply voltage that way.

I just don't like how inaccurate the divider is and how it could a possibly taking up more power than wanted.

Is there an IC or a better way to do this???

I read this and it seems promising but also a little cumbersome.
https://www.electronicdesign.com/mi...er-battery-monitor-circuit-needs-only-one-pin

I appreciate any help :)

Joshua
 

dl324

Joined Mar 30, 2015
16,846
I just don't like how inaccurate the divider is and how it could a possibly taking up more power than wanted.
Measure the resistance of the resistors so you can calculate the actual ratio. If it's still not what you expected, we'll need more information about your circuit.

Assuming the divider had the 10k on the bottom, the voltage you read should have been more like 10/57.6 of 12V, or 2.08V.
 

Thread Starter

joshagirgis

Joined Aug 27, 2018
11
the "10k" = 9.7k and the 47.6K = 46.1K.

Doing out the math for an actual supply of 12.82 volts I get the correct 2.22 volts I measured. BUT YET, I still measure 2.5 with the ADC.

Any ideas?
 

LesJones

Joined Jan 8, 2017
4,174
Have you checked the value of the reference voltage you are using on the ADC ? If that is not the same as the value you are using to convert the count from the ADC to a voltage then that would cause an error.

Les.
 

Thread Starter

joshagirgis

Joined Aug 27, 2018
11
Have you checked the value of the reference voltage you are using on the ADC ? If that is not the same as the value you are using to convert the count from the ADC to a voltage then that would cause an error.

Les.
Hi Les,

I will do that, and get back to you!
 

AlbertHall

Joined Jun 4, 2014
12,345
Have you checked the value of the reference voltage you are using on the ADC ? If that is not the same as the value you are using to convert the count from the ADC to a voltage then that would cause an error.

Les.
Usually the ADC reference is the 5V supply so you need to check exactly what voltage the arduino supply is.
 

ebp

Joined Feb 8, 2018
2,332
Measure the voltage between the Arduino circuit board common at the board and the power supply common at the power supply. There is plenty of room for difference due to connection resistance.
 

Thread Starter

joshagirgis

Joined Aug 27, 2018
11
Does an AREF pin voltage of 4.5 volts explain it?

Also the 5 volt pin produces 4.5 volts as well.

Maybe if I took the buck regulator and put it into the 5 volt pin instead of the USB port
 

Thread Starter

joshagirgis

Joined Aug 27, 2018
11
was probably under the wrong assumption that the 5volt line in the USB of the arduino goes straight to the 5volt rail. I'm going to do some rewiring and let you know how it works. Sorry!!
 
You have to be careful with references. If the ref is Vdd and Vdd = 5V, you don;t have a 5.0 V reference, you have a ratiometric reference which is nominally 5V. That's way different than a precision 5V reference,

If you have a Vdd= 5 v power supply and the reference is 1/2 Vdd, the reference is NOT 2.5 V.
 

dendad

Joined Feb 20, 2016
4,451
Depending on how accurate you want the reading, there are a few things you can do.
One is to use an external reference voltage of good quality, and that is the recommended way instead of the Arduino power.

https://www.arduino.cc/reference/en/language/functions/analog-io/analogreference/

Another is to have a known voltage on another analog input to measure to help calibrate the reading.
Always use good quality resistors, of at least 1% or better. The most important quality of the resistors will be stability, not accuracy. A normal practice is to actually measure the unknown voltage and adjust the code to calibrate the reading. You cannot really just go with a default value if you want accurate readings as the 5V supply, if that is what you are using for Vref, is not really stable, and the resistor actual variations in value from their marked value can be significant.
One instrument I designed (not Arduino) uses a good reference, 0.1% resistors, a multiplexer (MUX) for the analog in and a measured on board test voltage that is stored in EEPROM, measured for each board with a lab multimeter.
First, the MUX selects a grounded zero volts input and measures that. Then it measures the test input voltage that has the value stored in EEPROM. From those 2 readings, it can now calibrate itself and accurately measure the unknown voltage. This device is a MagFlow meter and accurately measures low micro volt flow signals on an 18bit plus sign ADC.
Good layout is another thing to look at for clean measurements. But all this is probably overkill for your application, except good quality resistors. I never use worse that 1% resistors in my designs. Relying on the USB voltage is a real no-no. That will not be stable over different supplies from various PCs.
If you do need to run from USB power, look into an external Vref, and maybe a 4.095V one so the ADC bits are evenly allocated over the Vref range.
 
Top