Hello,
I'm trying to use a simple voltage divider to monitor the battery level on a li-ion battery pack.
My controller (ESP32) can accept 3.3V max analog input. I can use a regular divider to easily calculate the resistor values such that the max output remains 3.3V or less for a fully charged battery at ~13.4V
However the problem is that a "dead" battery is ~9.6V for example. The result is that my voltage divider output range is 2.3 - 3.3V since the ratio of output to input is maintained. How can I scale the output from 0 - 3.3V so that the analog channel on my controller has more resolution to determine the battery percentage? Or am I overthinking this and a range of 1V is enough to get a decent reading?
I've been trying to search for a solution but maybe I am not using the right terms.
Thank you
Hello there,
For myself i tend to like to go to a higher resolution ADC. You can get an external 15 bit ADC pretty cheap that is already mounted on a small PC board, maybe 3 for $10 USD.
If you dont want to do that then the next idea is to subtract a constant voltage from the reading and then adjust the uC code to account for it.
This means if you want to measure 10 volts with a range of 8 to 12 volts then you use a voltage reference or divider to subtract 8 volts from the voltage, then measure the resulting voltage.
When you subtract 8 from 10 you get just 2 volts. That means that 2 volts now means you really have 10 volts, and 4 volts means you really now have 12 volts. If you then read 0 volts that means your actual voltage is 8 volts. So your range is now from 0 to 4 volts but you are actually measuring from 8 to 12 volts.
Let's say you are measuring from 9.6 to 13.6 volts. That's a range of 4 volts. If you multiply 4 by 0.825 you get 3.3 volts.
If you subtract 9.6 volts from the reading you get 0v at the low end, and 4 volts at the high end, and if you multiply that (divider) by 0.825 you get 0v at the low end and 3.3v at the high end.
You do have to actually subtract that 9.6 volts though and you can use a voltage reference diode set up for 9.6 volts. Alternately you could use an op amp and subtract that way, but you should use a voltage reference diode for the constant voltage reference not a zener.
We could draw up a little circuit if you like.
I found the subtraction method to be interesting because if your battery goes too low you really don't need to know the voltage, you just need to know the undervoltage threshold was reached and that means something is really wrong. For your example if your battery was down to 3 volts you would not need to know it was at 3.001 volts or 3.000 volts, you already know something is really wrong so it doesn't really help to know the actual voltage.
I am using something like this for a solar project but i like a little extra headroom at the top. My battery is 12 volts and it can go up to 14.2 or more but i have my ADC set up to go from 0v to 16.384 volts. I don't really need it that high but dont want to have to bother with losing 2 volts just for better resolution when i intend to move to a 16 bit ADC soon anyway. The resolution i get right now with just a 10 bit ADC isn't that bad either, it's about 0.016 volts from 0 to 16.384 volts, so don't really need much better actually.