Measure 12V Battery Voltage with High Accuracy

Hello there!

I recently build myself a DIY solar system and created a web interface using a Raspberry Pi to display graphs and general data. My system uses a 12.8V LiFePO4 battery with a capacity of 100 Ah. Obviously I need to get an accurate voltage reading of the battery to calculate a somewhat accurate percentage of the battery charge. For example 13.1V correspond to about 40% charge, whereas 13.2V are already 70%. My charge controller does provide a voltage reading, but it is only accurate to one decimal place, so I cannot determine anything between 40% and 70%, which is obviously not accurate enough. My plan is to connect an Arduino Nano via USB to the Pi and read its voltage measurement using Serial.

The problem I faced: 12-14V is way to much for the 0-5V range of the Arduino analog input pin. Voltage dividers don't provide enough accuracy, since they do not shift, but scale voltage down. The ADC has 1024 steps from 0-5V. If I scaled down the voltage by a factor of three, a change from 13.1 to 13.2 would only correspond to a change of 0,0334V of the voltage divider, which are less than 7 steps of the ADC.

My question is: What can I do to measure the voltage of a 12V battery very accurately using the Arduino Nano ADC? Preferably using a simple circuit without any ICs or bought chips. Thanks!

I use an ESP32 to read my LiFePo4 batteries in my solar project. I use a 10K variable resistor as R2, Voltage Divider Calculator, and a multi-meter to bring the battery readings in line with the meter. Perhaps such a scheme may work for you or not.

Good luck.

That pretty much ends the discussion.

How does a 12.8 volt battery measuring 13.1 correspond to a 40% charge? That doesn't sound
right but maybe I am missing something.

edit:
I looked at a 12v battery voltage vs charge and yes that could be correct.

You could shift vs. scale by putting a Zener diode in series, along with a resistive protection circuit. But you would have to calibrate the entire system because the Zener voltage isn't perfectly accurate.

However, your basic premise is flawed. That kind of battery does not lend itself to accurate capacity measurements based only on voltage. At best, you could do it but any method of scaling/shifting to increase the accuracy is futile, as the measurement itself does not yield an accurate prediction to the same degree.

If you want a voltmeter that reads out 12V to 14V, you need a good quality, stable voltage reference and a lot of analog circuitry. The battery capacity depends on battery internal temperature, also. The more current the battery supplies also limits its capacity: faster discharge leads to self heating and lessens the charge that can be delivered.

The commercial devices monitor multiple parameters to make an estimate - they record and store the history of the charge voltage and current, and obtain temperature from the battery in some cases. So it's not just an instantaneous reading.

That's what I am trying to do. But over time there would be a large drift because efficiency is never 100% and it's very dependent from so many different factors. My approach is to calibrate the system every night (with no load connected to the battery), but for that I need an accurate voltage reading.

If you use a voltage divider you still get 1024 steps for your full scale voltage , which is 12/1024 = 0.0134 volts . Scaling with a divider doesn’t affect this !! ( ~ 130 steps between 12-14 volts )
You can’t better that unless you have external electronics .
You should anyway use the internal voltage reference to give around 1.1 volts full scale and a divider to suit .
Don’t forget too your battery will have a different voltage on charge , off charge and supplying a load .

I have tackled the problem of concentrating the resolution of the ADC into the useful range of a 12V lead-acid battery -- 10.4..15V. There are a few things I know work alright:

I started with a 10V zener and a small load resistor to effectively hive off 9.5V and place the battery voltage into the range of the ADC. You have to calibrate for the actual zener voltage and temperature coefficient of the diode and also for the dynamic resistance of the diode -- but in fact this has worked well for me and it is a simple solution.

I have used a precision shunt regulator like TL431 in place of a zener in exactly the same way, however these have a slight dropout so with a 10V reference the lowest battery voltage you can sense is ~11V which is a bit too high for a lead-acid range. It does work well and needs no real compensation since the reference is pretty stable.

When I needed real precision, I put together an op-amp circuit to map the voltage range and also used a 4.096V precision voltage reference. This worked very well, but requires calibration of the input voltage range. It is temperature and input voltage stable, which is nice.

BATV_0211
BATV_0209

4 posts were split to a new topic: 12volt LiFePO4 battery and buck converter

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.