Skip to main content
Associate II
February 10, 2026
Question

ADC measurement issue

  • February 10, 2026
  • 5 replies
  • 789 views

Hello all,

Currently I have been working on a project which involves reading values using ADC. This is the following connection:

 

SohamC_0-1770726822035.png

AD8495 is used as an ambient temperature sensor. The connections given in the image are taken from the datasheet for adr8495. I have connected the output to channel A0 of my ADC on board with STM32F407ZGT6. The configuration of ADC is as follows.

 
static void MX_ADC1_Init(void)
{
 ADC_ChannelConfTypeDef sConfig = {0};

 hadc1.Instance = ADC1;
 hadc1.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4;
 hadc1.Init.Resolution = ADC_RESOLUTION_12B;
 hadc1.Init.ScanConvMode = ENABLE;
 hadc1.Init.ContinuousConvMode = DISABLE;
 hadc1.Init.DiscontinuousConvMode = ENABLE;
 hadc1.Init.NbrOfDiscConversion = 3;
 hadc1.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
 hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
 hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
 hadc1.Init.NbrOfConversion = 3;
 hadc1.Init.DMAContinuousRequests = DISABLE;
 hadc1.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
 if (HAL_ADC_Init(&hadc1) != HAL_OK)
 {
 Error_Handler();
 }

 sConfig.Channel = ADC_CHANNEL_VREFINT;
 sConfig.Rank = 1;
 sConfig.SamplingTime = ADC_SAMPLETIME_480CYCLES;
 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
 {
 Error_Handler();
 }

 sConfig.Channel = ADC_CHANNEL_0;
 sConfig.Rank = 2;
 sConfig.SamplingTime = ADC_SAMPLETIME_84CYCLES;
 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
 {
 Error_Handler();
 }

 sConfig.Channel = ADC_CHANNEL_1;
 sConfig.Rank = 3;
 if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
 {
 Error_Handler();
 }
}

The issue I am facing is as follows: Whenever I power the board using STLINK using 5v provision on it, and the adr8495 is powered as well, the ADC works properly showing the reading with respect to the ambient Temperature of the room.

But whenever I power the circuit using a Linear Power supply 5V, the ADC measurements change and are drastically reduced. I have checked all the common issues like grounding , any short connections,

but I have not been able to find an issue. One thing that might help is whenever I power the board using STLINK-V2 the 3.3Pin on the board is stable around 3.25V , and whenever Linear power supply is used the Pin is stable around 3.35V

I also came up with the idea of using VREFINT as for measuring the Vref that the board is actually getting powered by, and use that value for the engineering conversions i.e Converting raw ADC values to millivolts.

Can anyone provide any suggestion? Do ask if you have any query related to connections or the firmware.


Edited to apply proper source code formatting - please see How to insert source code for future reference.

5 replies

Andrew Neil
Super User
February 10, 2026

Welcome to the forum.

Please see How to write your question to maximize your chances to find a solution for best results

In particular, What board are you using, and what ST-Link ?

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.
SohamCAuthor
Associate II
February 10, 2026

The board is EU M4 demo, Board link.

The stlink used is STLINK V2.

Andrew Neil
Super User
February 10, 2026

That's not an ST board, you'll have to dig into the schematics to see the implications of the different ways of powering it.

Note that STM32F407 clones exist.

 

Are you using a genuine STLink ?

How to recognize a genuine ST-LINK/V2 versus a cloned one

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
Super User
February 10, 2026

> But whenever I power the circuit using a Linear Power supply 5V, the ADC measurements change and are drastically reduced.

Be more precise. What values are you getting and what values are you expecting instead?

If VREF+ is changing, it is expected that ADC values will also change.

Showing the full schematic would help.

"If you feel a post has answered your question, please click ""Accept as Solution""."
SohamCAuthor
Associate II
February 11, 2026

Whenever I power the board using STLINK, via the 5V provision, the stm32f407 gets 3.25V at its 3.3PIN. As expected the adr8495 produces the voltage with respect to temperature i.e 5mV/C, but the ADC reads only 80-90 milivolts, when the actual adr8495 output is around 140mV. 
This led me to belive that the ADC Vref is getting change or anything related to it.

And even if the Vref was changed I used the VREFINT pin to know the Vref and use that for my calculations. s mentioned in the datasheet , this VREFINT is mapped to an ADC channel, and stm32f407 has 1.21V(typ) internal regulator based on which it calculates the Vref.
So even if the Vref changed it should have been handled in the firmware, so why does this still happen, such a drastic change from ~140 to ~80. 

Ozone
Principal
February 11, 2026

> Whenever I power the board using STLINK, via the 5V provision, the stm32f407 gets 3.25V at its 3.3PIN.

I don*t understand how you mean that.
The ST-Link provides only +3.3V via the (SWD) debug connection. Regardless how the ST-Link itself is powered (+5V via USB).

> This led me to belive that the ADC Vref is getting change or anything related to it.

The ADC Vref is derived from VDDA, andis only as stable as this supply.

> As expected the adr8495 produces the voltage with respect to temperature i.e 5mV/C, but the ADC reads only 80-90 milivolts, when the actual adr8495 output is around 140mV. 

I would highly suggest to validate your ADC inputs another way, to not chasing ghosts here.
Use a stable and known external voltage e.g. a battery (perhaps with a voltage divider), and apply one or more known voltages to the ADC inputs. And check that shorting the ADC inputs to ground yields zero results (+/- one or two bits).

To properly convert the thermocouple amplifier output, check the output impedance of this device (ADR8495), the input impedance of the F407 ADC, and the necessary sampling times.

SohamCAuthor
Associate II
February 11, 2026

STLINK purchase link:   In this there is a provision of 5V , which I used in the circuitry and measured on a DSO. It gave a stable 4.8-5V.

You might be correct , I could have used it wrong until now, but it has worked.

 

Further I did some changes in the firmware on how to use the VREFINT in increasing the accuracy according to this video , you can see on minute 9:38.

This resulted in change of reading. The vref obtained using STLINK V2 was around 3.199, 

And the Vref measured using a linear power supply was 3.26V-3.27V

 

This still did not solve the issue , the measured adr8495 output was still around 80-90mV

Ozone
Principal
February 12, 2026

> In this there is a provision of 5V , which I used in the circuitry and measured on a DSO. It gave a stable 4.8-5V.
> You might be correct , I could have used it wrong until now, but it has worked.

Which does not mean this pins is meant to supply a target, and deliver enough current.
You would have to check with the schematics, which are probably not publicly available.
But this remark in the user manual is more than a hint.
And the F407 is not really a low-power MCU.

> This still did not solve the issue , the measured adr8495 output was still around 80-90mV

You need to separate matters here.
Check the ADC channel with a stable, low impedance DC source first - e.g. a battery as mentioned.
Best is to check each channel alone, and then both in combination.
If this yields about identical results, proceed with your thermocouple amplifier.

Besides external factors like reference voltage and input impedance, there are internal ones' like the sampling time, inter-sample delay and sampling frequency. As a first-order approximation a SAR-ADC input stage can be viewed as a RC element, whose bandwitdh must fit that of the input signal.
In short, if the thermocouple results differ significantly from those with a DC source try longer sampling times.

SohamCAuthor
Associate II
February 16, 2026

>In short, if the thermocouple results differ significantly from those with a DC source try longer sampling times.

I have connected the thermocouple to an amplifier circuit with high current output. Thus the sampling time should not be an issue for that.

I thought of this before and even tried it but there was no difference since I realized it later that the current output was high. The output of this amplifier is connected to the ADC via RC filter. 

TDK
Super User
February 16, 2026

You should simplify the problem as @Ozone suggests, including powering the board from a non-programmer source. What you are describing should work if the design is correct, but it isn't. So there is an issue somewhere.

The more your show the more the more likely the issue will be spotted.

"If you feel a post has answered your question, please click ""Accept as Solution""."
MasterT
Lead II
February 17, 2026

Interfacing adc with external circuitry is not easy task. Unfortunately, app. note doesn't provide an example schematic, so customer have to solve a few issues: 

 injected current should never exceed stated in data sheet limits, 5 mA or so.  Modern common OPA can easily supply 20-100 mA when powered from anything else except same 3.3V power source as an stm32 adc.

This brings up input protection, that again is not easy to solve for high precision analog signals.

I'd  recommend buffer adc inputs by low voltage R2R outputs op-amp, powered by analog domain 3.3V, and buffer may have resistors at its own inputs.  CMOS/ JFET high input impedance op-amp keep good precision even with high value of resistors, that may be necessary for circuits exposed to long lines or harsh external environment

  

Ozone
Principal
February 17, 2026

> Interfacing adc with external circuitry is not easy task.

I can only second that.
Which is why I use to keep my external input stages simple, and test them separately.

> I'd  recommend buffer adc inputs by low voltage R2R outputs op-amp, powered by analog domain 3.3V, and buffer may have resistors at its own inputs.

Occasionally I supply the opamps with 5V since the types at hand don't nearly reach rail levels. In this case I add a 3.1V zener diode to protect the ADC input.

> CMOS/ JFET high input impedance op-amp keep good precision even with high value of resistors, ...

Although in my limited experience, they are more prone to oscillations.


But to circle back to the OP's issue :
I would (again) recommend to validate the ADC itself with a precise low-impedance voltage source, which could be a battery in the simples case (checked with a good multimeter).
If the ADC measurements for this setup are good, the problem must be the thermocouple + amplifier stage.
The basic method of elimination.

MasterT
Lead II
February 17, 2026

@Ozone wrote:

> Interfacing adc with external circuitry is not easy task.

I can only second that.
Which is why I use to keep my external input stages simple, and test them separately.

> I'd  recommend buffer adc inputs by low voltage R2R outputs op-amp, powered by analog domain 3.3V, and buffer may have resistors at its own inputs.

Occasionally I supply the opamps with 5V since the types at hand don't nearly reach rail levels. In this case I add a 3.1V zener diode to protect the ADC input.

Both advices are naive and counterproductive.

Using zenners as a clamp does not really  protect anything, since internal dynamic impedance of zenners at 3.3V well above 50 Ohms, do your math to get overvoltage level with 100 mA injected current. Secondly, zenners start to conduct below specified voltage and consequently introduced huge amount of non-linearity into measured data/ results.

Testing a driver separately from the load (adc in this case)  is also ill-advised. SAR ADC is quite specific load, that practically not possible to simulate or replace by linear RC alternative. For high precision, opa driver selection is could be done only based on hardware tests, since data sheets for opa provide load specification / charts for Resistive loads only