Strange Long Term Oscillation on ADC


I have an extremely high quality pH electrode hooked up to an Arduino MEGA that we're using for a product we're making.

Now everything looks good. The voltage is stable as hell over extremely long times when checked.

However, on the Arduino end analogRead shows a curious trend. The values seem to oscillate quite a bit (close to 1 pH in difference, which is obviously intolerable from a sensor that should do 0.01pH).

Here's an image showing what I'm talking about: (oh sorry apparently not, as I need to post a regular message before I'm allowed to post one with a link.. see the first response to this post for a link to the image)
The phenomena is best seen in the (unnamed) Sample 6.

What's truly bizarre is how long the oscillation is. From peak to peak is close to 1 MINUTE, which is highly problematic as it makes smoothing pretty much useless - we can't possibly have a machine that needs a sample size of 5 minutes or more to be properly smoothed.

Any idea what might be causing this?

And here's the link I referred to in my post:

maybe your solution Ph is between two values and this is why it doesn't stop oscilliating. We can get the same phenomenon with all electronic measurement devices.

and btw, the different "samples" in your picture, it was all the same and the Arduino detected it as different?

We are actually using a 7.01 pH standard, where the pH meter was for all those samples. We had also given the sensor a fair amount of time to sit in there to avoid the "shifting pH" to create trends in the sample.

Also checked with an external pH sensor - the sample is fine (and 7.01), what isn't fine is what arrives from analogRead.

maybe this will help you.

Also note that rather significant seeming differences in even rather large samples.

The STDEV in Sample 4 is... very strangely low compared to all the other samples.

Don't exclude anything retarded here... something related to the power source of the Arduino (a laptop), grounding it etc (we aren't using any of the GND portals, the Pins with anything in them on the board are 2x ADC inputs and 6x Digital Outputs). I'm sure we're guilty of some very basic mistake.

I assume the link implies you suspect the problem is in our electronics? It's a bit curious if it is, as we definitely have a steady 2.525mV coming out of them...

Surely stability of +-5mV on the voltage end (with no oscillation) implies that the 10-bit analog output shouldn't be swinging around particularly much (with the 1024 samples and 5V range, I would actually think that a +-5mV variation would result in a +-1 variation on the analogRead, not a +-17 variation...)

All in all, very puzzling.

No, the link implie that I do not know, but want to help.

which is highly problematic as it makes smoothing pretty much useless

But, wouldn't you actually need to smooth the signal to get an accurate reading?

Time to wait for the experts :wink:

wait, I found this:

Having worked with pH probes in a refinery, I can tell you that they always have to have external very very high impedance buffering and DC gain amplifiers, with manual drift adjustments. Drift is a constant battle, as well as cleaning of the probe on a regular basis and calibrating with a buffering solution. Also the pH scale is a logarithmic scale and the 10 bit A/D converter in the Arduino is probably not a good match if reasonable accuracy is needed. And last, any analog measurement that can have a valid negative value cannot be measured by an Arduino, as it is strictly a 0 to some positive voltage value (depending on reference used), no negative values allowed.

Ok to play around with, but if it's at all a serious application I think the Arduino needs lots of external circuitry help for pH measurement.


I think this is your problem. But you should post your schematic here, so when the experts come, they will be able to help you right away.

Yes you need a schematic of how you are wiring it up. It sounds like you haven't got the ground reference wired up correctly especially as you say:-

we aren't using any of the GND portals

If there is no ground then this is the sort of thing you will get.