# What is the best way to acquire voltage information of a battery powered microcontroller project?

I would like to track the battery that supplies my microcontroller.

I was thinking at a simple voltage divider bridge wired to an ADC input.

As my divider bridge will be permanently connected, I suppose the resistors will consume current all the time.

I wonder if there is not a more energy-efficient way to measure it.

EDIT 1 :

1. My microcontroller is an STM32L422. I know I could use the ADC of the VBAT pin of the uC to measure this voltage (p38 of the datasheet) but I read p73 of the datasheet that the VBAT max was of 4V. Problem, my battery can go high as 4.2V, so I can't use it directly.
2. I will probably run my uC at 8MHz for HSE and at 32KHz for LSE.
3. I'm using standard li-ion battery like this one for instance (4.2V max)
4. My charge management IC is the MCP73831, here is the datasheet
5. My LDO voltage regulator is the XC6220

EDIT 2 :

There is the the power section schematic :

Where :

• Vbat being the battery voltage, the one that I'm trying to monitor
• +5VDC_(24V) = a possible 5V input from a 24VDC to 5V regulator.
• +5VDC_(USB) = a possible 5V input from an USB power source.
• +3VDC = The voltage used for the uC and all the other components.
• Which (specific) microcontroller? Some have an internal reference voltage source, while others use their DC supply voltage as reference (not so useful). – glen_geek Dec 10 '19 at 17:02
• OF course there is, but you have no specs. Define you goals. Specs tolerances , accuracy , range, temperature, power consumption. battery cutoff. UV detection. etc – Tony Stewart Sunnyskyguy EE75 Dec 10 '19 at 17:08
• A.Girafe - I haven't yet flagged your question as a duplicate of the following one, but from the info in your question, you seem to be asking about the same thing: "Low current divider for battery voltage monitoring". It would help if you can review that linked question and either (a) you agree that yours is the same question (so we can close yours as a duplicate of that one), or (b) you edit your question and add more details to explain where your question is different to that one, so readers know where to focus their answers. Thanks. – SamGibson Dec 10 '19 at 17:31
• @A.Girafe I believe this answer is what you are looking for. – Maple Dec 13 '19 at 9:17
• Pull-up/down resistors cannot be too high because that would affect FET switching characteristics. Even though it is said that no current flows through the gate, it is only true for stable condition. Due to gate capacitance some current has to flow to charge it. Same goes for ADC sample-and-hold capacitors. Make divider too high and there will be not enough current to charge it during sampling period. How to choose them? Well, I am curious to see a simple answer myself. Maybe make another question? – Maple Dec 13 '19 at 12:04

The voltage divider you mention is the easiest way but it doesn't mean it's the appropriate. however, if you want to go for it, to reduce the current the resistors draw, use large values (Ohm's law, I=V/R), just make sure the relation of both resistors complies to your ADC resolution vs the battery voltage.

There is also Battery Chargers IC that provide extensive telemetry of battery via I2C. Check for instance LTC4162.

If you provide more info about what you want to do, such a battery capacity, uC used etc, maybe you can get a better answer

• I added some informations about my circuit. The battery charger IC providing this information is a good idea ! I can't to do that on this project since the IC was already chosen but I will keep it in mind next time. – A.Girafe Dec 11 '19 at 9:42
• It's not just the ADC "resolution" one must also consider the ADC loading - in some MCU's those sampling caps can take a fair bolus of charge in comparison to high impedance dividers. – Chris Stratton Dec 11 '19 at 21:14

On some microcontrollers there is a analog switch before the ADC and another to select the reference voltage. In your circuit, pick a voltage reference (needs to be lower than the min supply voltage you want to detect) and connect into a ADC input channel. Select the ADC reference on the controller to the supply voltage.

The reference voltage is often available on board the device.

Measure the real voltage reference in relation to the reference of the ADC.

Say for a 10 bit ADC the usual equation is ($$\ DN_{adc}\$$ is the adc reading), $$V{ch1} = \frac{DN_{adc}}{2^{10}} V_{ref}$$ but now $$\V_{ref}\$$ is unknown because it is $$\V_{DD}\$$, and $$\V{ch1}\$$ is the voltage of a real known reference, $$\V_{extn}\$$. So now you can calculate $$\V_{DD}\$$ $$V_{DD} = \frac{2^{10}}{DN_{adc}} V_{extn}$$

Microchip Application Note AN1072 describes this technique.

• In practice the Vref needs to be the largest possible battery voltage, divided down to something less than Vdd of the MCU, as most MCUs can't handle a Vref higher than the MCU supply. – Lundin Dec 13 '19 at 12:23