Showing results for 
Search instead for 
Did you mean: 

STM32L011 Temperature sensor calibration (Possible bug in library)

Associate II

Hi all,

I am trying to use internal temperature sensor on Nucleo L011K4 and using macro from LL library (__LL_ADC_CALC_TEMPERATURE_TYP_PARAMS) I get complete garbage.


STM32CubeMx 5.0.1

LL libraries used, no HAL

ADC is running in DMA mode with HW oversampling by 8, 12.5 clock S&H time (should be enough for TEMP sensor) and each ADC EOS this value again averaged in SW.

When I looked closely to datasheet and reference manual I wrote my code without this macro and I still getting nonsense data out of it. I found that TS_CAL2 value from Factory Option bytes is far different than expected value, so when I used 670 constant instead - and I got something real temperature finally.

Question 1: why at production calibration value is like 1.5 times bigger than supposed to be?

Question 2: Is there a bug in LL macro? It looks like there one unnecessary multiply by 1000

Question 3: Do I need to recalibrate temp sensor at 130C or can use different temperature?

Question 4: Can I store calibration value in option bytes and how?

Question 5: Is TS_CAL1 value can be used if I calibrate it by myself? I want measure temperature using 2 points calibration.


Note that the calibration at the factory was done using Vdda=3V, but the Nucleo eval board uses Vdda=3.3V. Did you account for this difference?

Would you be able to:

  1. Provide the raw ADC counts that you read at room temperature
  2. Measure and provide the actual Vdda voltage (AREF, connector CN4, pin13)
  3. Provide a second measurement at a different temperature (cold or hot)