Skip to main content
Associate II
September 15, 2026
Question

STM32G030C8T6 temperature sensor and oversampling issue

  • September 15, 2026
  • 4 replies
  • 18 views

I’m trying to use ADC oversampling and noticed that temperature value is distorted in that case.

I have configured ADC with 7 external inputs, temperature sensor input and Vref input. Vcc/Vcca is 3.27V, sampling time is 7.5 cycles.

When oversampling is disabled - I’ve got averaged raw value 2115 for analog input (voltage 1.64V), 1005 for temperature sensor and 1582 for Vref. When oversampling is enabled (no matter 2x or 16x, with shifting to same count of bits as added by oversampling) - I’ve got 2115 for analog input, 1107 (!!) for temperature sensor and 1584 for Vref. So, only temperature sensor input value differs. And, as result, I’ve got 63*C instead of 33*C when oversampling is enabled.

What’s wrong with oversampling? Can it be fixed by some kind of settings? Or I must forget about it and use software oversampling instead?

I’m using latest CubeIDE 2.2.0 and CubeMX 6.18.1 with latest libs 1.6.3.

4 replies

Andrew Neil
Super User
September 15, 2026

Please post a minimum but complete example which illustrates the issue.

 

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.
TDK
September 15, 2026

There is a minimum sampling time requirement for the temperature sensor. Increase yours to meet this. How much you need to increase depends on what your ADC clock is.

 

"If you feel a post has answered your question, please click ""Accept as Solution""."
NiTr0manAuthor
Associate II
September 17, 2026

There is a minimum sampling time requirement for the temperature sensor. Increase yours to meet this. How much you need to increase depends on what your ADC clock is.

 

I’ve increased sampling time up to 160 cycles at tests. Nothing is changed.

 

Ozone
Principal
September 17, 2026

> I’ve increased sampling time up to 160 cycles at tests.

Number of cycles is not the important criterium.
What is the resulting sample time ?