cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F030 Temperatur Sensor

RSeye.1
Associate II

i tried to use the internal temperatur sensor but its a little bit strange

when the tempertur goes up the value from the adc goes down

is that right or is my config for the adc wrong ?

7 REPLIES 7
Uwe Bonnes
Principal III

Higher temperature give lower output voltage. You are right.

RSeye.1
Associate II

do you have an example how to calculate the temperatur ?

or which value whould by 0 °C ?

the examples i found are only for other stm chips with 2 calibration values

Have you looked at the datasheet:

0693W00000NrQznQAF.png 

0693W00000NrR19QAF.png

yes i did but the calculation i tried is wrong

i think its much easier if the datasheet gives some examples

to start with

for example from the datasheet of a lm95071

0693W00000NrR7aQAF.png 

this makes it clear how it has to be calculated

so can you tell me the hexvalue of the ad at 0°C with a vdd of 3.3 V ?

Don't forget to also look in the Reference Manual - that's where programming details are to be found (the datasheet concentrates on physical characteristics):

0693W00000NrRKzQAN.png0693W00000NrRLEQA3.png 

thank you very much

that was the the hint i was searching for

KiptonM
Lead

The HAL has macros to help.

In this case ADC_Data.word[2] is the ADC result from reading the Voltage Reference

And ADC_Data.word[1] is the ADC result from reading the Temperature Sensor.

uint16_t refv = __HAL_ADC_CALC_VREFANALOG_VOLTAGE(ADC_Data.word[2],ADC_RESOLUTION_12B);

uint16_t temp = __HAL_ADC_CALC_TEMPERATURE(refv,ADC_Data.word[1],ADC_RESOLUTION_12B);

 The thing that got me was that the Temperature Sensor and the Voltage Reference both need a sample time of 5 microseconds or 160.5 clocks in my case. Way higher than I initially assumed.