ADC reading overflow between pins

Hello,

I am finding that my ADC pins are affecting each other’s analog read values when I sampling them consecutively within a software timer.

a = analogRead((int)A1);
b = analogRead((int)A0);

While sampling, if I leave A1 floating, I would expect an adc reading value of 300. But if I pull A0 to 3V3, I noticed that my A1 adc reading will go up to something like 1650. Which isnt too good haha.

To my understanding of microcontrollers, there is a separate ADC module within it that gets configured for each read for a pin and sample rate setting… So if I try reading different pins too quickly, I understand that my readings could possibly cross over. I don’t understand the impedance/capacitance factors at play though but I’d think the straight forward solution is either adding a delay between reads or taking a hit on accuracy through modifying the ADC’s internal sampling rate. Is that the case?

However, I dont see any mention of “setADCSampleTime” in the Boron reference guide specifically. Vscode finds the function but it doesnt find any of the parameter constants definitions referenced in the Photon reference guide. So Im a little stuck. Should I directly change the micro’s internal registers? I noticed some dusty forum posts about ADC issues in past deviceOS releases but they seem very specific and possibly solved.

Overall, my mission is to sample these ADC pins consecutively at a fairly high frequency, lets say 1000Hz - 3000HZ. Let me know if my design is the actual problem :slight_smile:

Hi,
I believe that this is a normal behavior regarding to high frequency and RFI/EMI and you can read about that here:

Also setADCSampleTime(duration) is not sported in Gen3 device which is in reference documentation here.
analog_gen3

You can try @rickkas Analog to digital conversion using DMA for Particle Gen 3

Here is example how to sample 2 channels A0/A1.

Please note ! This feature is experimental

1 Like

You can’t reliably measure a floating pin. You can bias the input with a large value resistor (like 1M ohm) to GND or 3V3, but the ADC will never produce accurate readings for a floating pin.

1 Like

Yeah honestly. I think that might be the heart of the issue. I was testing with a just a Boron but I think it should be tested while the board is connected to its actual sensor shield.

I will give this a shot as well! Thanks!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.