Skip to main content
Visitor II
July 15, 2025
Solved

STM32 ADC Scan Mode – Getting Unrealistically Values from Multiple NTC Channels

  • July 15, 2025
  • 5 replies
  • 579 views

Hello,

I’m trying to measure temperature using NTC sensors on four different ADC channels of my STM32 Nucleo‑H7 board. I could previously connect potentiometers to the same pins and get flawless ADC readings with the same code and CubeMX settings. I only added a function to convert NTC readings to temperature and didn’t change any other configuration.

I connected the NTCs to PA6, PA7, PC4, and PC5. In my loop, I call HAL_ADC_Start(), then four times HAL_ADC_PollForConversion() and HAL_ADC_GetValue() to retrieve the raw ADC values. When I measure the sensor output directly with a multimeter, I see about 1.65 V, but the ADC reads ~0.03 V, resulting in completely unrealistic temperatures.

I never had this issue with potentiometers on the same pins and code. Why am I getting such low readings with the NTCs? Is my channel assignment wrong, the pin mode incorrect, or could hardware jumpers/shielding be affecting it?

Has anyone experienced something similar or have suggestions? Thanks!

    This topic has been closed for replies.
    Best answer by durna

    I've solved the problem. It was in CubeMX settings. Thanks for everything

    5 replies

    Technical Moderator
    July 15, 2025

    Hello @durna 

    Did you performe ADC calibration before measuring the temperature? 

    durnaAuthor
    Visitor II
    July 15, 2025

    Hello @Saket_Om 

    yes as it appears in the code

    Explorer
    July 15, 2025

    Input impedances and sample times play an important role as well.
    What impedances and currents/voltages we are talking about here ?

    durnaAuthor
    Visitor II
    July 15, 2025

    The following values are valid in my setup:

    Divider impedance (Thevenin): 10 kΩ (NTC) ∥ 10 kΩ (fixed) ≈ 5 kΩ

    Divider current I = 3.3 V / (10 k + 10 k) ≈ 165 µA

    Node voltage (multimeter): ~1.67 V ⇒ ADC raw value ≈1.67/3.3-65535 ≈ 33 000

    Sampling circuit time constant:

    S/H capacitor ≈ 4 pF, switch R_ON ≈ 100 Ω ⇒ τ = R-C ≈ 5 kΩ-4 pF ≈ 20 ns

    ADC sampling times:

    I actually ran the ADC at a 15 MHz clock with a ÷10 prescaler, so the ADC clock is 1.5Mhz


    so the S/H capacitor must be fully charged. Despite this, the raw reading is ~600 (≈ 0.03 V)

    durnaAuthor
    Visitor II
    July 15, 2025

    Everything seems to be correct both hardware and software wise, but the temperature readings are really ridiculous. I've been trying for 2 days and still can't figure it out

    durna_0-1752576959593.png

     

    Super User
    July 15, 2025

    Do values change if you increase sampling time to max?

    Use DMA to convert multiple channels, but maybe get a single channel working first.

    Explorer
    July 16, 2025

    > Use DMA to convert multiple channels, but maybe get a single channel working first.

    I would definitely second that.
    Perhaps simplify it even more, using continuous conversion for the single channel.

     

    > Node voltage (multimeter): ~1.67 V ⇒ ADC raw value ≈1.67/3.3-65535 ≈ 33 000

    What do you mean here ?
    The part marked in red is mathematically not correct, there is something like operator precedence in mathematical equations, too.

    You probably mean "1.67/3.3 * 65535", i.e. scaling the voltage to a unsigned 16-bit value.

    durnaAuthorAnswer
    Visitor II
    July 21, 2025

    I've solved the problem. It was in CubeMX settings. Thanks for everything