If you've ever wanted your Arduino to find the pH of a solution, needed to interface a pH probe or wanted to make your own pH sensor. This is an ideal project for you. The idea of this project is to interface common inexpensive Marine/Lab/Horticulture pH probes with the Arduino style prototype boards that are very common these days. Having a very high impedance signal poses a few design issues, thankfully we have modern op amps which take care of most of these concerns. Taking that and a few other considerations into account we can still produce a cost effective and accurate interface that even someone new to electronics can build themselves.
Length: 1.5" (excluding BNC dimensions)
Requires regulated 5V DC.
USB enabled Arduino Bootloaded ATmega32u4
Analog Front End: input +-.5V output: 0 to VCC
|Anatomy of a pH probe and amplifier|
- Very low input Bias op amp stage(or separate amp) for probe gain
- stable clean offset op amp stage for proper output voltages
- noise filtering and decoupling caps
- positive and Negative supply
- Optional: Gain control and Offset control
- Optional: Add µC for output digitization
- @pH 7 output of probe is 0 volts, @pH7 voltage is negative
- Total pH range is 0(strong acid) to 14(strong base)
- If probe generates -59mV/pH unit then our effective range would be +/- 7*59mV or +/-.414volts
- Depending on temperature the voltage generated per pH unit varies from -54mV@0c to -74mV@100c
Here are graphs showing the affect of temperature on probes and a degraded probe vs an ideal probe:
As the above graphs show, as probes age they tend to offset a tiny bit in either direction and also weaken their output potential. Luckily both of these can be compensated for either in software, or by adding gain and offset control in the circuit.
In order to build an adequate amplifier there are a few considerations other then those pointed out by the ideal probe section. One consideration is the very high impedance that a pH probe has. pH probes use a special glass bulb which has "holes" in it that allow the ions to flow throw, though very highly impeded.
A typical probe has an impedance of anywhere between 10M? and 100M?, and since 100M?*1nA=.1v even having a single stray nano amp can throw our measurement off by almost 2 entire ph units. The goal then is to choose an op amp that is adequate enough that will not load down the probe but that also has characteristics which will keep both the cost down and the accuracy up. When combined with the previous considerations about probe age and drift, a basic roadmap is made on how we can simply and effectively amplify and interface a pH probe signal.
A very basic design we can utilize is a simple unity gain amp, a buffer circuit to separate the high impedance probe from our "low" impedance multimeter. We will build this design first for a couple reasons, the first being it is an effective way to compare our probes to the ideal probe model. the second reason being its really easy to build and can take only a few seconds, and demonstrates a base for how the offset(in an inverting config) will alter the signal. While I suppose you could use an LM358 for this I would recommend at very least the ST TL072 or a CA3140 this is to be sure not to load down the probe and get false readings.
If we use the ideal probe numbers we should see an output of .414v at 0pH, 0v at 7pH and -.414 at 14pH. I had one aged probe read .150v at 4pH and -.04v at 7pH. .150-(-.04)=.190v/3(7pH-4pH)=63.3mV/pHunit which is our revised step number vs the ideal step of 59mV/pHunit. This gives us a useful baseline to compare our circuits while negating most of the error associated with different probes aging rates etc...
The diagram below describes the interaction of an amplifier with a fixed gain and offset building on from the very basic unity gain amp design.
|Voltage evolution through simple fixed Gain/Offset circuit (Using Ideal probe characteristics)
Assuming X = 4.7, and output range should be 0-5v
Vout =(1+X)*Vin(simplified non inverting op-amp gain formula)
5.7*.414 = 2.36(*2= 4.72 total voltage swing)
Vaout=~5v=Vin+Voffset - Offset range acid side
Vbout=~0v=-Vin+Voffset - Offset range base side
5-2.36=2.64>Voffset>0-(-)2.36=2.36 Lets pick 2.5v for our offset in this example
Voffset=2.5v (/2 1.25v this will be our Vin for the offset circuit as we will see later)
Thus making our effective output range
As shown above, there isn't really much to this very basic circuit. If you are familiar with op amps you will see a standard non-inverting configuration hooked up to a differential amplifier(configured as an offset stage) the net result of this circuit will mimic what we designed in the block diagram. The capacitors are added for stability(and noise blocking at certain Fqs) and aren't tuned in this schematic nor are the values of the resistors. The ratios are the important part(G=1+(R2/R1)=5.7, G2=1+(R4/R3)=2) as we can see from the schematic and prior math, the offset voltage is doubled which is why we halved it earlier.
With our basic schematic ready lets build a breadboard version and takes some samples from a few probes(old and new) and see how the results stack up to what we should expect to see from the Ideal Probe Model. We will account for the ph calibration in software, calibrating with pH7 and pH4 reference solutions. Once we have our calibration numbers we can map new readings based on the reference readings to calculated unknown pH.
The only thing needed to wire up at this point is the offset voltage, positive and negative rails. Once we feed in our input from the pH probe we can read the voltage out from the end of the 3.3k Resistor at top col 15.(Note trimmer shown is set to proper offset, and is assumed fixed, but well be using this in the adjustable circuit so I just left it on there)
With a bit of quick programming in the Arduino environment, we can perform a calibration step to allow us to use the map function. This is a quick and dirty method of getting our ADC reading into a useful range based on the max/min calibration reading(reading at pH4 and at pH7). after running the calibration a dip in my tap water shows it at about 7.3 pH (map(analogRead(A0),pH4cal,pH7cal,400,700)) my pH pen shows it to be about 7.2, putting us in a reasonable shooting distance which isn't bad for such a cheap un tuned circuit.
Some improvements with filtering caps and possibly a slightly higher gain to account for aged probes can be made at very little cost and effort. Also tuning the resistor values will help quit a bit in both power consumption and over signal quality. Recommended values R1-47K,R2-200K,R3-200K,R4-200K, R5-3.3-4.7K, C1-.47uF,C2-.47uF(additional caps can be place at probe input to ground, and final output to ground these can be 100pF to .1uF depending on noise characteristics)
Another improvement that can be made is adding in a "buffer" configured op amp stage to separate the high impedance end from the low impedance end, and we could also choose a "better" op amp for the initial stage. We will explore all these options and see which one gives us the best bang for buck.
In order to normalize(Zero for 7pH) we will need to add an adjustable offset control to our simple circuit. Since the pH probe should produce 0v at pH7 the gain portion of the circuit will not affect this reading, which is why we adjust it in the offset portion. When combined with gain adjustments we can make a simple circuit that is able to be calibrated much like most commercial pH units.
In the most basic sense the gain controls our slope(think the above graphs) and the offset zeros it around 7. Below is the same simple schematic as above only this incorporates the trimmer pots that will let us adjust for calibration and normalization. A couple more filter caps were added(as suggested in the previous section) as well.
For simplicity I set the trimmers for gain of 3 and followed our block diagram for the recommended offset voltage(1.25v into pin5). The output of the amp when place into pH4 calibration solution was 2.09v and 2.66v in pH7 solution. To find out if this matches what we should be expecting lets do a bit of math, First lets find the range of the difference between the 4 and 7 calibration readings. 2.66-2.09=.570mV, by dividing this by our gain 570/3=190mV we get our voltage swing between the two solutions.
From the ideal pH probe scenario we know that a pH probe should produce about 59mV per pH unit, by dividing our observed range by this step number we can see if our amp is working correctly. 190/59=3.22 which indicates a difference of 3.22pH units from Neutral(7pH) 7-3.22=3.78pH or about 5% off our pH4 solution when using the ideal model. When we use our math from the unity gain example(63mV/step) our accuracy is just under 1%, 190/63=3.01 7-3.01=3.99pH. Once we can check what condition our probe is in, even with a cheaper Op-Amp on breadboard, we can achieve very good results for little investment.
Considering the breadboard version has no noise/stabilization capacitors and the probes are quite aged, on an un calibrated circuit this isn't too bad really. With a bit of calibration or math we can adjust for these slight differences. Add in some properly tuned filter caps and resistor values and you could have one nice pH probe interface(especially when paired with an opa129 or something like the LMC6001 and a unity gain buffer between that and the µC).
All this means is when the concentration is greater on the outside of the probe, the ion flow is inward causing a slight voltage(+) difference between the probes electrodes. This tells us whether we are measuring a base or an acid. The voltage can tell us the concentration of the test solution