cancel
Showing results for 
Search instead for 
Did you mean: 

Why are STM32L451VETx internal temperature sensor readings too low?

DBurr
Senior

Hi, I'm using the STM32L451VETx and I'm configuring the ADC to read from the internal temperature sensor however the readings are lower than expected. Typical readings at around 21 degrees Celsius are only 3 degrees Celsius. I can see some change in the temperature if I apply cold or heat to the IC so I believe it's sensing temperature. I'm using the HAL macro "__HAL_ADC_CALC_TEMPERATURE". I have the ADC configured to scan 5 channels into DMA, the other channels that I'm reading are all correct. I noticed also that changing the sampling time for the temperature sensor changes the ADC reading but none of the available options work to produce accurate temperature readings. All of the ADC config is done through CubeMX. Any suggestions for what I may be doing wrong?

Thanks,

Doug Burrell

1 ACCEPTED SOLUTION

Accepted Solutions

I finally got the temperature sensor working with reasonable values. The key was running the HAL ADC calibration function.

Thanks for your help @Community member​ !

View solution in original post

9 REPLIES 9

ADCx_CCR.CH17SEL is set?

What are the ADC values you read out for the temperature sensor? What is VREF+/VDDA voltage? What are the TS_CAL1/TS_CAL2 values in system memory?

JW

DBurr
Senior

Yes to ADCx_CCR.CH17SEL being set.

The ADC temperature sensor values are around 0x360 at room temperature. The TS CAL1 and 2 values are 0x412 (30oC) and 0x565 (130oC), so in that sense compared to the calibration values the temperature being 3oC makes sense. VDDA and VREF+ voltage are both 3.3V.

Try measuring only the temperature channel, maybe also not using DMA just polling.

JW​

Thanks for the suggestions. If I measure just the temperature channel and in polling mode, it still reports similar values, ~20 degrees Celsius too low. I will try on different devices too, maybe the device I have has faulty calibration data, that seems unlikely but you never know.

> it still reports similar values, ~20 degrees Celsius too low

Humm.

Try the VREFINT channel - does it return reasonable value, compared to the value stored in system memory for VREFINT?

What hardware is this? Are you absolutely sure VREF+ is 3.3V, and rock stable? Did you measure it directly on VREF+ pin, best with oscilloscope? How is it connected, exactly? Don't you use the internal VREFBUF? Is VREF- grounded?

You don't switch off the temperature sensor between measurements, do you? If yes, you'd need to observe the startup time given in DS, before measuring. And do you observe the minimum sampling time given for temperature sensor in DS?

JW

It's on a custom board, I will try to dig up a nucleo dev board here to try on.

I've got it now reading the VREFINT ADC channel and using this to factor into the temperature calculation and it is closer but still 7 degrees Celsius lower. The VREF voltage is actually closer to 3.4V. Yes VREF- is grounded.

I don't think the temperature sensor is being shut down between measurements but will check.

Thanks,

Doug

> The VREF voltage is actually closer to 3.4V.

How did you establish that? How is VREF+ actually connected? Did you observe it using an oscilloscope?

JW

The 3.4V was the calculated value from the ADC reading of VREFINT. I did also measure it with a multimeter and it was 3.29V. What could cause the multimeter reading and the ADC measured reading to be different like that?

I found a nucleo dev board and ran some basic code on it to measure the temperature sensor and it seems to be accurate. I'll try just that same basic code on my board.

I finally got the temperature sensor working with reasonable values. The key was running the HAL ADC calibration function.

Thanks for your help @Community member​ !