Stm32L4 internal temperature sensor measurement
Hello, I'm trying to measure the ambient temperature using the nucleo l432kc internal temp sensor . I connect the MCU through the usb to my lapotp. With the code I'm currently using, the output temperature starts at 23 degC when I first connect the MCU and then it settles at 30. I'm guessing this is because the MCU heats up till it reaches 30. Room temperature should be about 24. When I test the sensor at the fridge, it goes down till around 10 which also makes sense (instead of about 5). My question is how can I make the MCU measure the absolute temperature? should I just add an offset? or should I play with the sample time or other parameters? This is the code I'm using mbed compiler:
include 'mbed.h'
include 'stm32l4xx_ll_adc.h'
AnalogIn adc_temp(ADC_TEMP);
int main() {
while(1) {
int temp12 = adc_temp.read_u16() >> 4;
int temp =
LL_ADC_CALC_TEMPERATURE(3300, temp12, LL_ADC_RESOLUTION_12B);
printf('TMP%04d: %d\n', temp);
wait(1); }
}
