2017-01-31 10:25 PM
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
Temp(degree) = (V_sense - V_25)/Avg_slope + 25
Method 2: Page 251 in
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-sensor2017-01-31 11:07 PM
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...
2017-02-01 12:27 AM
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).
2017-02-01 12:41 AM
what temp are you getting,
42.2C is about 12C above ambient.
2017-02-01 01:11 AM
I got almost the correct ambient temperature (25 degree at room temperature). However in the reference manual, it says that there may be an offset in the measured/calculated temperature. This offset varies from device to device and it may reach 40 degree. So if you want to measure the absolute temperature, you have to perform an extra calibration.
2017-02-01 02:01 AM
what is your ambient temp ?
12C ?
2017-02-02 12:33 AM
I got 22oC ambient temperature at room temperature
2017-02-22 02:22 AM
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.
2017-02-22 04:10 AM
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);
}
�?�?�?�?�?�?�?�?�?