2021-01-25 07:33 PM
I've been using (int32_t)NTC_GetAvTemp_C(pTemperatureSensor[0]) to read temperature but the draw back is that it is in integer deg C, I'd like a float with at least 1 digit resolution., i.e. 38.2. I'd like to use NTC_GetAvTemp_d() but don't know the definition. It is returning an int16_t value. Around 38C I get back a value of 17600.
This is what I know about the procedure:
/**
* @brief Returns latest averaged temperature measured expressed in u16Celsius
* @p pHandle : Pointer on Handle structure of TemperatureSensor component
* @r AverageTemperature : Current averaged temperature measured (in u16Celsius)
*/
__weak uint16_t NTC_GetAvTemp_d( NTC_Handle_t * pHandle )
{
return ( pHandle->hAvTemp_d );
}
Can someone tell how to interpret "u16Celsius" ?
Note: Since I have the NTC coefficients I could write my own routine but I was trying to use the available procedures without creating redundant code, not to mention reducing the software/ADC timing overhead.
2021-03-01 11:32 PM
Dear @BTrem.1
I don't know exactly what is u16celsius used for this function.
Whatever you can use the conversion used to have celsius integer in the converting function (int32_t)NTC_GetAvTemp_C to had one or more digit (depending of sensor sensitivity) by writing your own converting function.
According to the source code, the algorithme used to convert in celsius integer is:
wTemp = ( int32_t )( pHandle->hAvTemp_d );
wTemp -= ( int32_t )( pHandle->wV0 );
wTemp *= pHandle->hSensitivity;
wTemp = wTemp / 65536 + ( int32_t )( pHandle->hT0 );
Best regards
==
Laurent Ca...