I want to measure the battery level of 4 AA (R6) batteries using a voltage divider made of 2 resistors which goes into the internal ADC of a PIC16F microcontroller with a 10-bit resolution. Knowing that the discharge curve is not linear, how can I model it so that I obtain a precise percentage of how much "juice" I've got left? Also, is this idea of a circuit good?circuit Knowing that my current consumption is about 0.5A, how long will the 4 batteries last?


1 Answer 1


You will know how much juice is left by always using well specified, known batteries and a coulomb counter to determine how much energy is left. Still you'd need to make a calculations to take temperature and loading effects into account.

If you can cut or measure power consumption from the battery and measure them in a known (battery) temperature, you can make an estimate by using curves available from the manufacturer of the battery.

If you use a voltage divider in a low energy consumption there is a risk of the voltage divider consuming a good portion of the available energy in the voltage division.

Microcontroller allows you to disconnect the voltage divider, so usually that is the easiest way to minimize the current draw for the voltage divider.

Consumption can also be countered by selecting large values for the divider, but then the ADC input impedance or sampling current might affect the measurement. A voltage follower buffer amplifier circuit can overcome that, or you could use a power monitor IC, but that will add complexity and might end up adding power consumption.

If you use microcontroller ADC remember to select the reference voltage to be something that doesn't change when the battery voltage drops.

  • \$\begingroup\$ Thanks for your input! I need a software implementation of this, not a hardware one (e.g. with a Coulomb counter) - I'd like to keep it as simple as possible. I think the voltage reference is constant because the microcontroller is powered by the buck-boost converter which gives a constant output (am I right?) - If I can't find a precise mathematical function of the ADC value which is dependent of the AA battery I guess i will consider 0% to be 682 = 1V/1.5V * 1023 and 1023 = 1.5V / 1.5V *1023 to be 100%. (the ADC resolution is 10 bit and I know the discharge slope is steep after 1V) \$\endgroup\$
    – Andreiul
    Commented Mar 7, 2022 at 21:21
  • \$\begingroup\$ If you don't get the value from manufacturer then you can check another battery with the same chimistry and capactity to get ball park figures, but only the non-loaded figure will be a good match. Buck boost -converter will operate as you stated, but in practice it will have a minimum voltage, after which the output starts to drop. \$\endgroup\$
    – Ralph
    Commented Mar 8, 2022 at 6:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.