Skip to main content
Explorer II
August 29, 2024
Question

STM32H743ZIT6 INTERNAL TEMPERATURE SENSOR READING

  • August 29, 2024
  • 3 replies
  • 2052 views

I AM USING A STM32H743ZIT6 CONTROLLER  IN THERMAL CAMERA BUT I READ A INTERNAL TEMPERATURE 138 CELCIUS BUT IN NUCLEO BOARD INTERNAL TEMPERATURE CAME 35 TO 40 CELCIUS (I AM USING 400 MHZ BOTH NUCLEO BOARD AND THERMAL CAMERA) SO WHY IT CAME IN THERMAL CAMERA INTERNAL TEMPERATURE IS A 138 CELCIUS SO I AM GIVEN A MY CODE BELOW ,SO CAN YOU GIVE ME SOLUTION HOW TO MAINTAIN CURRECT TEMPERATURE  OF STM32H743ZIT6 

MAIN.C
int main(void)
{
 HAL_Init();
 SystemClock_Config();
 MX_GPIO_Init();
 MX_ADC2_Init();
 MX_ADC3_Init();
 MX_USART3_UART_Init();
 while (1)
 
 temperature = Get_Temperature(); 
 HAL_Delay(100);
 }
}
float Get_Temperature(void)
{
 
 HAL_ADCEx_Calibration_Start(&hadc3, ADC_CALIB_OFFSET, ADC_SINGLE_ENDED);
 // Start ADC conversion
	 HAL_Delay(100);
	 HAL_ADC_Start(&hadc3);
 HAL_ADC_PollForConversion(&hadc3, HAL_MAX_DELAY);
 adcValue = HAL_ADC_GetValue(&hadc3);

 HAL_ADC_Stop(&hadc3);

// // Read calibration values
 cal1 = *TEMPSENSOR_CAL1_ADDR;
 cal2 = *TEMPSENSOR_CAL2_ADDR;
 
 // Calculate temperature
 temperature_1 = ((float)(TEMPSENSOR_CAL2_TEMP - TEMPSENSOR_CAL1_TEMP) /
 (float)(cal2 - cal1)) * (float)(adcValue - cal1) +
 TEMPSENSOR_CAL1_TEMP;
	
 return temperature_1;
} 
void MX_ADC3_Init(void)
{
 ADC_ChannelConfTypeDef sConfig = {0};

 /** Common config 
 */
 hadc3.Instance = ADC3;
 hadc3.Init.ClockPrescaler = ADC_CLOCK_ASYNC_DIV6;
 hadc3.Init.Resolution = ADC_RESOLUTION_16B;
 hadc3.Init.ScanConvMode = ADC_SCAN_DISABLE;
 hadc3.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
 hadc3.Init.LowPowerAutoWait = DISABLE;
 hadc3.Init.ContinuousConvMode = ENABLE;
 hadc3.Init.NbrOfConversion = 1;
 hadc3.Init.DiscontinuousConvMode = DISABLE;
 hadc3.Init.ExternalTrigConv = ADC_SOFTWARE_START;
 hadc3.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
 hadc3.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR;
 hadc3.Init.Overrun = ADC_OVR_DATA_PRESERVED;
 hadc3.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE;
 hadc3.Init.OversamplingMode = DISABLE;
 if (HAL_ADC_Init(&hadc3) != HAL_OK)
 {
 Error_Handler();
 }
 /** Configure Regular Channel 
 */
 sConfig.Channel = ADC_CHANNEL_TEMPSENSOR;
 sConfig.Rank = ADC_REGULAR_RANK_1;
 sConfig.SamplingTime = ADC_SAMPLETIME_810CYCLES_5;
 sConfig.SingleDiff = ADC_SINGLE_ENDED;
 sConfig.OffsetNumber = ADC_OFFSET_NONE;
 sConfig.Offset = 0;
 if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK)
 {
 Error_Handler();
 }

}
    This topic has been closed for replies.

    3 replies

    Super User
    August 29, 2024

    What is the VREF+ value on your board? If it's not 3.3, you will need to compensate for this. For example, if it's 3.0:

    adcValue = HAL_ADC_GetValue(&hadc3) * 3.0 / 3.3;

     

    SITARAMAuthor
    Explorer II
    August 30, 2024
    #define VREFINT_CAL_ADDR ((uint16_t*) (0x1FF1E860UL)) /* Internal voltage reference, address of parameter VREFINT_CAL: VrefInt ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
    #define VREFINT_CAL_VREF (3300UL) /* Analog voltage reference (Vref+) value with which temperature sensor has been calibrated in production (tolerance: +-10 mV) (unit: mV). */
    /* Temperature sensor */
    #define TEMPSENSOR_CAL1_ADDR ((uint16_t*) (0x1FF1E820UL)) /* Internal temperature sensor, address of parameter TS_CAL1: On STM32H7, temperature sensor ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
    #define TEMPSENSOR_CAL2_ADDR ((uint16_t*) (0x1FF1E840UL)) /* Internal temperature sensor, address of parameter TS_CAL2: On STM32H7, temperature sensor ADC raw data acquired at temperature 110 DegC (tolerance: +-5 DegC), Vref+ = 3.3 V (tolerance: +-10 mV). */
    #define TEMPSENSOR_CAL1_TEMP (30L) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL1_ADDR (tolerance: +-5 DegC) (unit: DegC). */
    #define TEMPSENSOR_CAL2_TEMP (110L) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL2_ADDR (tolerance: +-5 DegC) (unit: DegC). */
    #define TEMPSENSOR_CAL_VREFANALOG (3300UL) 

     THIS UPER SNIPET SHOW OUR VREF VALUE SO WHAT CAN I DO MY TEMPERATURE CAME 130 CELCIUS IN THEMAL CAMERA  GIVE ME SOLUTION 

    Super User
    August 30, 2024

    The voltage is not defined by the code, but rather by the board design. This is something the designer of the board would have specified during the design.

     

    Please don't use all caps in your reply.

    ST Employee
    August 30, 2024

    Hello @SITARAM,

    It seems that you're having problems with the internal temperature values.
    This could be linked to the calculate temperature function. I recommend checking the "__LL_ADC_CALC_TEMPERATURE_TYP_PARAMS" function available in the stm32h7xx_ll_adc.h driver and verifying its parameters.

    Dor_RH_0-1725030818045.png

    You can also refer to the STM32H7 reference manual for detailed information on configuring the internal temperature sensor and ADC.

    I hope my answer has helped you. When your question is answered, please select this topic as solution that answered you, it will help others find that answer faster.

    Thanks for your contribution.

    Dor_RH

     

    SITARAMAuthor
    Explorer II
    September 2, 2024
     TEMPCELSIUS =__HAL_ADC_CALC_TEMPERATURE_TYP_PARAMS(2000,620,3300 ,TEMPSENSOR_CAL_VREFANALOG,temp_sensor,ADC_RESOLUTION_16B);

    when i do this function  then in TEMPCELSIUS VALUE CAME A 3400 CELCIUS WHY THIS Value came give me solution 

    ST Employee
    September 2, 2024

    Hello @SITARAM

    Could you please provide the specific values of the parameters you are using, so I can assist you more effectively?

    Thanks for your contribution.

    Dor_RH

    Technical Moderator
    February 21, 2025

    Hello,

    You can refer to this article: How to measure the junction temperature of an STM32H7