Skip to main content
RSeye.1
Associate
June 8, 2022
Question

STM32F030 Temperatur Sensor

  • June 8, 2022
  • 7 replies
  • 2072 views

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 ?

This topic has been closed for replies.

7 replies

Uwe Bonnes
Chief
June 8, 2022

Higher temperature give lower output voltage. You are right.

RSeye.1
RSeye.1Author
Associate
June 8, 2022

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

Andrew Neil
Super User
June 8, 2022

Have you looked at the datasheet:

0693W00000NrQznQAF.png 

0693W00000NrR19QAF.png

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
RSeye.1
RSeye.1Author
Associate
June 8, 2022

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 ?

KiptonM
Senior III
June 8, 2022

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.