Showing results for 
Search instead for 
Did you mean: 

Temperature issue reading with STM32F103 internal sensor

Associate III

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:



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.