cancel
Showing results for 
Search instead for 
Did you mean: 

Internal temperature sensor

josescxavier
Associate II

I'm trying to read the internal temp sensor of a STM32F030F4Px but datasheet isn't clear about how to calculate it.

Vsense = ( 1686 / 4095 ) * 3.3 = 1.35V

Temp = ((1.43 - 1.35) / 4.3 ) + 30 = 30.01C

In the code example it isn't any clear because I got:

ADC1->DR = 1686

TEMP30_CAL_ADDR = 1770

VDD_CALIB = VDD_APPLI = 3300

temp = (1770-1686) * 1000 = 84000

temp = 84000/4300 +30 = 49.5C

Actual room temperature is 22C.

What am I doing wrong?

thank you

6 REPLIES 6
S.Ma
Principal

You measure the plastic packaged sealed silicon chip temperature.

Because it drains current to operates, it is a heat generator.

The measured internal temp would match ambiant just after the chip is cold powered up, assuming SW would be bug free...

Rogers.Gary
Senior II

Assuming your address for stored values are correct, replace the ones below with yours and try this. Works well on STM32F4xx:

//stored calibration constants for STM32F4

#define TEMP30_CAL     ((uint16_t*) ((uint32_t) 0x1FFF7A2C))

#define TEMP110_CAL    ((uint16_t*) ((uint32_t) 0x1FFF7A2E))

           //perform temperature read using STM32F4 internal sensor

           ADC_SoftwareStartConv(ADC1); //Start the conversion

           while (ADC_GetFlagStatus(ADC1, ADC_FLAG_EOC) == RESET);

           uint16_t TS_DATA = ADC_GetConversionValue(ADC1);

           // factory calibration coefficients stored at macro pointer locations

           float32_t tmp = (float32_t) ((( (110 - 30)*(TS_DATA - *TEMP30_CAL) ) / (*TEMP110_CAL - *TEMP30_CAL) ));

How do you justify the difference result on both methods?​

I don't think I have that temp110 Cal value​

Rogers.Gary
Senior II

Check page 743 of the reference manual, there's an example there.

Mohamed Aymen HZAMI
ST Employee

Hello,

The temperature sensor inside the chip is dedicated to the measurement of silicon temperature.

Best Regards,

Mohamed Aymen.