2024-06-10 12:34 AM - last edited on 2024-06-10 03:31 AM by SofLit
Hi St-community
I'm having variations in temperature readings from the internal sensor on my STM32F103 MCU. The readings seem to differ at different time when , I restart power supply.
I'm using the following code to measure temperature:
//code
void measureTemperature(void){
Measured.temperature = (V31 - VSENSE * Measured.rawADCValues[3]) / AVG_SLOPE + 31.0f;
if (Measured.temperature >= 90) {
ProtectionVals.faults.overTemperature = 1;
}
}
#define VREFINT 3.289f
#define ADCMAX 4095.0f
#define VSENSE (3.3f / 4095.0f)
#define V31 1.57f
#define AVG_SLOPE 0.0043f
I've verified that the code is functioning correctly, but I'm unsure why the temperature readings fluctuate after power supply restart.
Any insights or suggestions to ensure consistent temperature readings across power cycles would be greatly appreciated.