cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G0B1: internal temperature sensor

xlrl
Associate II

I am trying to measure/calculate the internal temperature of an STM32G0B1VE design.

The algorithm used is taken from the reference manual RM0444 Rev 5 pages 376-378:

Temperature in degreesC = ((TS_CAL2_TEMP-TS_CAL1_TEMP) / (TS_CAL2-TS_CAL1)) * (TS_DATA-TS_CAL1) + TS_CAL1_TEMP

The calibration values are taken from the data sheet, see stm32g0b1ve.pdf (DS13560 Rev 1) page 25.

TS_CAL1_TEMP = 30 (defined in data sheet)

TS_CAL2_TEMP = 130 (defined i data sheet)

TS_CAL1 = 0x3FF (speficic to my controller, retrieved from 0x1FFF75A8)

TS_CAL2 = 0x560 (specific to my controller, retrieved from 0x1FFF75CA)

measured = 0x39F

If I run the calculation, I get 3°C. Is there something I did wrong?

Attached is a minimal STM32CubeMX/STM32CubeIDE example

1 ACCEPTED SOLUTION

Accepted Solutions
One way would be to multiply the raw adc value by 1.1 (3.3/3.0).
If you feel a post has answered your question, please click "Accept as Solution".

View solution in original post

11 REPLIES 11
TDK
Guru

Is your VDD the same as in the cal values? I believe they’re taken at 3.0V.

what raw adc value do you get?

If you feel a post has answered your question, please click "Accept as Solution".
xlrl
Associate II

You mean raw value for VRefInt?

TDK
Guru

No, for the temperature sensor. But if you have it, yes that one too.

If you feel a post has answered your question, please click "Accept as Solution".
xlrl
Associate II

VRefInt raw 0x5d5, VBat raw 0x55f

xlrl
Associate II

Raw value for temperature was 0x39F (my calculation is a bit off -> ~0°C)

Okay, but you didn’t answer my very first question. What is VDD on your board?
If you feel a post has answered your question, please click "Accept as Solution".
xlrl
Associate II

Yes you are correct. VDD is 3.3V. I guess I have to take this into account. But where/how exactly?

One way would be to multiply the raw adc value by 1.1 (3.3/3.0).
If you feel a post has answered your question, please click "Accept as Solution".
xlrl
Associate II

This sounds reasonable. By using the updated value I get ~26°C