Showing results for 
Search instead for 
Did you mean: 


Associate II

Hello everyone, we want to read the value from the temperature sensor with ADC using the stm32f431kbu6 microprocessor. We use the code mentioned below.


#define TS_CAL_1 (*((uint16_t*)0x1FFF75A8)

#define TS_CAL_2 (*((uint16_t*)0x1FFF75CA)


float mcuTempCalculate (uint16_t tempADCval, uint16_t VrefIntADCval)


float temperature = 0;

temperature=(((130.0f-30.0f)/(TS_CAL_2-TS_CAL_1))*(3.3/3.0 * tempADCval - TS_CAL_1))+30.0f;

return temperature;


However, we read the temperature value as 6-8V. temADCval value is 863. Where might the problem be? Can you help?


> #define TS_CAL_2 (*((uint16_t)0x1FFF75CA)

An asterisk (*) is missing after uint16_t here.


Actually, I forgot to add (*) in my code. While writing here, I am getting the values ​​I specified, even though there is (*).

Pavel A.
Evangelist III

we read the temperature value as 6-8V.

Cannot read higher than Vref. Check your ADC measurements. By the way VrefIntADCval is not used in your function and the compiler should print a warning.


  • Make sure you're using the same VREF+ voltage (3.0V per the datasheet) as what was used to get TS_CAL values. If your voltage is different, then adjust.
  • Use max sampling time or use a sampling time that meets the temperature sensor requirements per the datasheet.

> we read the temperature value as 6-8V

6-8V is a voltage range, not a temperature. Perhaps you meant 6-8F?

> STM32L431KBU 

> stm32f431kbu6 

It's difficult to provide specific feedback when your post and code have typos. Copy/paste should be working.

If you feel a post has answered your question, please click "Accept as Solution".

Unexpected temperature sensor readout is a recurring theme here, try to search.

Often, calibration as outlined in reference manual, helps. Other possible sources of problems here.