Contents
How does the STM32 temperature and voltage sensor work?
Amongst them is an internal, factory-calibrated temperature sensor and a supply voltage sensor (that specifically senses VDDA, the analog supply voltage rail) connect to channels 16 and 17 of the internal ADC. While I usually like the STM32 documentation, it was quite hard to implement code that produced realistic values.
Which is the correct formula for stm32f0 internal temperature?
While the STM32F0 reference manual contains both formulas and a short section of example code, I believe that some aspects of the calculation are understated in the computation: Section 13.9 in RM0091 provides a formula for computing the temperature from the raw temperature sensor output and the factory calibration values.
How to read internal temperature from ADC conversion?
I’m trying to read internal temperature sensor. Each time, the value from ADC conversion is 296 which results in negative temperature. Should I add something to the code below, enable some peripher…
Why are there two ADC values in STM32?
Because calculation using the average values is crap. I don’t know why, but STM doesn’t promote their calibrated values much. Every device has two ADC raw values taken at 30 °C and 110 °C at 3.3 V stored internally. Using those values, you end up with more reasonable temperature values without performing calibration.
What’s the minimum sample time for a temperature sensor?
The minimum sample time for the temperature sensor is 10uS which requires that you choose the maximum sample time in ADC1->SAMPR (that just barely gets you to 10us). The internal voltage reference also requires at least 10us sample time.
How to calculate the internal reference voltage in STM?
If you use the STM libraries then you should configure Channel 17 as a regular channel and then enable via ADC_TempSensorVrefintCmd (ENABLE);. Assuming the typical value of 1.2V, you then can calculate the measured voltage via as follows: x mV = sample_chx * 1200mV / sample_ch17.
How to measure battery voltage using internal voltage reference?
Measuring battery voltage using the internal voltage reference also has some error (about 40mv low) that I can’t account for and this may be related to the error in the temperature sensor since it is dependent on the voltage. I am using CKMODE=PCLK/2->ADC_CLK=16MHz SMPR=160.5clks (max), and 16x oversampling.