2018-07-02 01:38 PM
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); }
}
2018-07-02 01:53 PM
Hello,
you are already reading absolute temperature.
Best regards,
Tilen
2018-07-02 02:14 PM
'
My question is how can I make the MCU measure the absolute temperature?'
I think you may find it helpful to read the datasheet relevant section. Your questions are answered there, by the most authoritative source ever.
2018-07-02 04:32 PM
So does this difference between real temperature and the one I measure makes sense? Because I read some people had only a difference of about 3 degC.
2018-07-02 07:14 PM
As I recall the calibration for temperature is at 3V on the L4 series. If you base your conversions on 3.3V for the ADC range you have to adjust the temperature samples. One way to automate that is checking the 1.2V internal reference first, to get a better determination of what voltage is on your VDDA pin. If you power directly from a battery it's mandatory to calibrate your ADC with VREFINT as the VDDA drops, otherwise your samples drift significantly as the battery runs down.
Jack Peacock
2018-07-03 01:42 AM
Your sensor in inside package, thus if package heats, sensor will read higher temperature.