7 years, 5 months ago.

External/ Internal ADC voltage reference

I have to read the battery voltage that is being used to power the stm32-l152re chip. Please help as to how i can measure the battery voltage ? It all comes down to how we can set a reference voltage for ADC measurement.

thnaks

Check the schematic for the mbed Nucleo stm32-l152re board. I bet you will see the Vref input pin already connected to the 3.3V supply. I believe mbed libraries already assume you are using an external voltage reference. Someone can correct me, but all you should have to do is to connect your stable voltage reference to the Vref pin and use the regular AnalogIn API.

posted by Graham S. 14 Nov 2016

2 Answers

7 years, 5 months ago.

Hi Karran,
I don't know your actual hardware circuit but this is an example to measure the external voltage with physical voltage value.
Please refer following program which I made today for your reference and works well (at least on my board).
https://developer.mbed.org/users/kenjiArai/code/NucleoL152_Volt_meter/
L152 CPU has a 1.22V internal reference voltage.
We can read it very simple way and use it.
https://developer.mbed.org/questions/75910/How-to-get-the-value-of-inbuilt-vref-int/
You need to equip voltage divider because your battery voltage is higher than VDD(3.3V).

7 years, 5 months ago.

Some additional hints through these programs. Take a deep dive into the reference manual for the chip as well. There is also a calibration white paper from ST out there somewhere that should help.

https://developer.mbed.org/users/hudakz/code/Internal_Temperature_F103RB/ https://developer.mbed.org/questions/75910/How-to-get-the-value-of-inbuilt-vref-int/