cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H743ZIT6 INTERNAL TEMPERATURE SENSOR READING

SITARAM
Associate III

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();
  }

}
8 REPLIES 8
TDK
Guru

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;

 

If you feel a post has answered your question, please click "Accept as Solution".
SITARAM
Associate III
#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 

@SITARAM 

@TDK wrote:

What is the VREF+ value on your board?


The voltage level on VREF+ pin.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

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.

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

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

 

 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 

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

Hello @SITARAM,

You can refer to this example: STM32CubeF4 ADC TemperatureSensor Example. It may assist and guide you in your application with the STM32H743ZIT6 internal temperature sensor reading.

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