Close

Derivations for the voltage and current measurements (For anyone interested)

A project log for Lithium-Ion Battery Monitor Library for Arduino

A simple library to monitor battery voltage in small Arduino projects

matthew-james-bellafaireMatthew James Bellafaire 08/20/2019 at 02:240 Comments

Chances are this has been worked out before, I don't know, I didn't really look. But here is the process that was used to determine how to calculate the battery voltage and current. (its like circuits 101 all over again). 

Terms:

First assume the ratio of the 1.1V reference to the battery voltage is equal to the ADC reading of the reference to the ADC reading of the battery voltage. (this is mostly true)

Solve for Vbat and substitute 1.1V for Vbg since its constant. 

And that's about it for the voltage calculation, onto current. First we find the voltage at the sense resistor using the same assumption as before that the ratio of the voltage is equal to the ratio of the ADC readings: 

Solving for Vsense and substituting 1.1V for Vbg

Using Ohm's law the current can be found by dividing the change in voltage by the resistance: 

Now substituting in the above equations and simplifying yields Iread

That's everything, since everything's now in terms of ADC values its fairly straight forward to simply get the values in software and calculate both the voltage of and current draw from the battery. All the units check out and a few sample calculations I ran seem to show that these equations work well enough (accuracy of the ADC throws current readings off by a few percentage points). If I overlooked something please let me know. 

Discussions