# How to estimate battery voltage in STM without extra component [closed]

I want to make a portable data logger. So it should be a battery-powered device. One of tasks that I should do is estimating battery voltage and displaying it but because of the power problem I don't want to use voltage divider and ADC. I'm exploring circuit of a similar device in market. I'm sure that there is no voltage divider with resistors and there is no additional IC in circuit because I explore completely the circuit and I know role of each component in circuit. Microcontroller is stm32f103cBt6.

I can't understand how the device estimate battery voltage without any additional circuitry. How they do that in your opinion?

Thanks

• Voltage is an analog value. You will need some sort of ADC, even if it's not the one built into the MCU. Oct 7, 2017 at 8:14
• "because of the power problem" what do you mean by that? You don't need to measure battery voltage thousands of times per second Oct 7, 2017 at 8:23
• You don't have to leave the resistive divider connected all the time, only when measuring. Oct 7, 2017 at 8:30
• This question makes absolutely no sense as it stands. The microcontroller has an ADC. From your answer below, it looks like you were really asking how do you calculate a voltage without a reference voltage. And your answer was...you don't. Oct 12, 2017 at 23:26
• Some of the STM32F4's have ADC's in them, however you'd have to keep the voltage under 5v (some of them 3.3V). All you need is a voltage and current measurment. This site is not for opinon questions VTC Oct 13, 2017 at 15:34

Thank you for your replies. But I find the solution. There is an internal 1.2v voltage reference in STM32 microcontrollers called 'VREFINT'. This voltage can be measured from channel 17 of ADC1. Reference of conversion is VDDA that is connected to VCC of circuit. So we can calculate VCC of circuit with the value of converted 'VREFINT'.

• ...assuming VCC is connected directly to the battery, but that doesn't actually work very well for many battery technologies. It might (just) work for primary lithium ion though, or 2 flashlight batteries in various chemistries. Oct 14, 2017 at 6:44

You did not provide a schematic. I will assume that MCU Vcc is battery voltage.

One way (with a divider) is to place a MOSFET next to ground (or use MCU pin to do switching). You turn the FET on when you want to measure the battery voltage and turn off when the divider is not needed.

Another way is to measure MCU internal reference voltage against its Vcc. Your MCU ADC must be able to select Vcc as reference voltage and its internal reference as the input channel. This is the only way that does not require a single external component.

• Re " ... This is the only way ..." -> Dangerous challenge :-). I've seen people use an RC watchdog timer frequency variation with voltage measured by the uC's crystal controlled clock to measure voltage. No more parts than were used for std purposes. Then ... :-) Oct 7, 2017 at 11:03
• "...for practical purposes" :-) RC timing depends also on temperature, so it should be taken into account.
– filo
Oct 7, 2017 at 13:32