Skip to main content
duybienle
Associate II
Feb 1, 2017 6:25 AM UTC
Question

right formula for calculating temperature sensor using STMF401RE Nucleo?

Posted on February 01, 2017 at 07:25

I'm using STM32F401RE Nucleo board to measure the ambient temperature. After the sampling process, I receive a digital value from ADC_CHANNEL_TEMPERATURE and I want to convert this digital value into degree celcius. I searched on the internet for this and I found two different methods:

Method 1: Page 226 in

http://www.st.com/content/ccc/resource/technical/document/reference_manual/5d/b1/ef/b2/a1/66/40/80/DM000968pdf/files/DM000968pdf/jcr:content/translations/en.DM000968pdf

Temp(degree) = (V_sense - V_25)/Avg_slope + 25

Method 2: Page 251 in

http://www.st.com/content/ccc/resource/technical/document/reference_manual/c2/f8/8a/f2/18/e6/43/96/DM000319pdf/files/DM000319pdf/jcr:content/translations/en.DM000319pdf

Temp(degree) = ( ( (110 - 80)*(TS_DATA - TS_CAL1) ) / (TS_CAL_2 - TS_CAL_1) ) + 30 Where: - TS_CAL2: temperature sensor calirbation value at 110 degree - TS_CAL1: temperature sensor calirbation value at 30 degree - TS_DATA: temperature sensor output from ADC

It confuses me which one is the correct formula for calculating the temperature in degree celsius. Although Method 1 is from reference manual of STM32F401, the temperature result doesn't look correctly. While Method 2 from reference manual of STM32F0 series, it looks more reasonable.

Still I don't know which formula should I apply when using STM32F401RE Nucleo board ?

Thanks

#stm32f401-nucleo #temperature-sensor
This topic has been closed for replies.

8 replies

T J
Senior III
Feb 1, 2017 7:07 AM UTC
Posted on February 01, 2017 at 08:07

I use the code for the '091

it works well, sitting at 42.2C

and you have a typo, it should be -30, not -80...

duybienle
duybienleAuthor
Associate II
Feb 1, 2017 8:27 AM UTC
Posted on February 01, 2017 at 08:27

Thanks. Yes, the result is more resonable when using the code in RM0091 than in RM0368, and you're right I made a typo there. However it still confuses me. As far as I know STM32F401RE Nucleo is a STM32F401 series, and the RM0368 should be the right documentation for it, not the RM0091 (for STM32F0 series).

T J
Senior III
Feb 1, 2017 8:41 AM UTC
Posted on February 01, 2017 at 08:41

what temp are you getting,

42.2C is about 12C above ambient.

lorenzo meneghello
Associate III
Feb 22, 2017 10:22 AM UTC
Posted on February 22, 2017 at 11:22

Hi all,

I'm also trying to set the internal sensor but I can't understand how to convert the ADC value in Celsius.. I'm 

using the code in RM0091 but it return bad result i.e. ambient temperature 18°C the uC read 0x876 with TS_CAL1= 0x704 TS_CAL2 = 0x53B so the result is about 46°C but if try to cool down the uC the temperature is always ~46°C.. 

Any idea?

Thanks.

T J
Senior III
Feb 22, 2017 12:10 PM UTC
Posted on February 22, 2017 at 12:10

I use this on my '091

I get 35c at the start and slowly ramps 42c after some time... at 28c ambient...

maybe you can show me , if I have made a mistake...

I expected to see a higher temp, but maybe it is not correct.

void readProcessorTemperature (void){ // ADC_Channel_AVE[AVE_ADC_ChannelCounter], HAL_ADC_Channel_Buffer[((ADC_RowCounter -1) & 0x0F)][Show_ADC_ChannelCounter]);// showing the last value from DMA of all channels 
//Temperature computation code example// Temperature sensor calibration value address #define TEMP110_CAL_ADDR ((uint16_t*) ((uint32_t) 0x1FFFF7C2))#define TEMP30_CAL_ADDR ((uint16_t*) ((uint32_t) 0x1FFFF7B8))#define VREFINT_CAL ((uint16_t*) ((uint32_t) 0x1FFFF7BA))#define VDD_CALIB ((uint16_t) (330)) // 3.3V rail#define VDD_APPLI ((uint16_t) (328)) // actually reads 3.28V on multimeter 
 int32_t AveTemperatureADC = ADC_Channel_AVE[VTemp_Ad16]; // from DMA continuous read
 double processorTemp; processorTemp = (double) AveTemperatureADC * VDD_APPLI / VDD_CALIB /16; processorTemp -= (double) *TEMP30_CAL_ADDR ; processorTemp *= (double) (110 - 30); processorTemp /= (double)(*TEMP110_CAL_ADDR- *TEMP30_CAL_ADDR); processorTemp += 30; processorTemperature = (int32_t) ((double)processorTemp *100);
}
�?�?�?�?�?�?�?�?�?