This is only a preview of the September 2023 issue of Silicon Chip. You can view 38 of the 104 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Items relevant to "Salad Bowl Speakers":
Items relevant to "pH Meter Module":
Articles in this series:
Items relevant to "Coffee Grinder Timer":
Items relevant to "PIC Programming Adaptor":
Items relevant to "30V 2A Bench Supply, Mk2 – Pt1":
Items relevant to "Voltage Inverter / Doubler":
Purchase a printed copy of this issue for $11.50. |
Using Electronic Modules with Jim Rowe
Analog Liquid
pH Meter
This module is designed to form the basis of a liquid pH meter, for testing
the acidity or alkalinity of things like the water in fish tanks or swimming
pools, or the liquid in a vat when you’re making beer or wine. It comes
complete with two pH sensor probes, and can be easily hooked up to an
Arduino or other microcontroller to form a pH meter.
T
he ‘pH’ of a liquid indicates
how strong of an acid or alkali
it is; or perhaps it’s midway between
the two and thus ‘neutral’, like distilled water. In my school days (long
ago!), we used strips of ‘Litmus paper’
to test this – the paper changed colour
when it was dipped into a liquid,
with the colour providing a guide
to whether the liquid was an acid or
an alkali.
Nowadays, though, this kind of testing is done using a more precise device
called a pH Meter.
The concept of ‘pH’ was first proposed in 1909 by Soren Sorenson,
a Danish chemist working at the
Carlsberg Laboratory. It is generally
regarded as indicating the inverse concentration of hydrogen (H+) ions in an
aqueous liquid, or the ratio between
H+ ions and OH− (hydroxide) ions in
the liquid.
As shown in Fig.1, the pH scale
runs from 0 to 14, with 0 representing
an extremely strong acid, like battery
acid, and 14 representing an extremely
strong alkali (or base), like liquid drain
cleaner. In the middle of the scale (pH
= 7) is the neutral point.
The first electronic method for measuring pH was developed in 1934 by
Arnold Beckman, a professor at the
California Institute of Technology, to
help local citrus growers test the pH
of lemons they were picking.
He formed a company to manufacture and market pH meters, and since
then, pH meters have been used in a
wide range of industries. They include
testing water quality, swimming
pool maintenance and wine or beer
brewing. They are also widely used in
healthcare and food processing.
The pH probe
The key component of a pH meter is
the pH probe. This contains two electrodes, designed so that when they
are both in contact with the liquid to
be tested, a small voltage difference is
developed between them. The polarity and amplitude of this voltage difference is proportional to the pH of
the liquid.
Originally, pH meters used two separate electrode probes: a hydrogen ion
sensing probe and a reference probe.
But nowadays, most pH meters use
what is called a ‘combination’ probe,
which includes both electrodes in a
single probe body, shown in Fig.2.
The main H+ sensing electrode is
Fig.1: the table on the left shows the pH scale from zero
to 14 with hydrogen and hydroxide concentrations (pH
values normally lie in this range). The right-hand table
shows example liquids with their typical pH values.
36
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
inside a small central glass tube which
usually ends in a small spherical bulb
of very thin, porous glass. This sensing electrode is generally made of silver, with a very thin silver wire used
to make the electrical connection to
it. The interior of this H+ sensing electrode tube is filled with a solution of
silver chloride (AgCl), its electrolyte.
The reference electrode is similar
in construction, but housed in the
outer part of the probe body and surrounded by a different electrolyte; usually, a solution of potassium chloride
(KCl). This area of the probe ends in
a porous ‘reference junction’ around
the central glass tube, just above the
glass sphere housing the main H+ sensing electrode.
As a result, when the bottom of the
probe is submerged in a liquid, a voltage difference is generated between the
two electrodes.
The small hole shown in Fig.2 near
the top of the inner glass tube is provided because some of these probes are
designed to allow the H+ electrolyte
solution to be ‘topped up’ from time
to time, if it has seeped away through
the porous sensing membrane at the
bottom. Many pH probes do not offer
this feature, though.
The electrical output of an ‘ideal’
probe is shown in Fig.3, which plots
the voltage difference between the H+
electrode and the reference electrode
for liquids with a pH varying from 0
to 14. The voltage rises from 0mV at
pH = 7 to over +400mV for pH = 0 (red
line), while it falls to beyond -400mV
for pH = 14 (blue line).
Both the red (acid region) and the
blue (alkali region) lines have a slope
of -59.16mV per pH unit, assuming the
liquid being tested is at 25°C.
So an ideal composite pH probe has
a linear output voltage swing of from
+414.12mV to -414.12mV for the pH
range of 0-14, swinging positive for
acids and negative for bases from 0mV
at the pH = 7 neutral point.
The output from a pH probe has
a very high source impedance, typically between 10MW and 100MW. So
it needs to be connected to a very high
impedance load to avoid attenuation.
(analog-to-digital converter) inside a
microcontroller unit (MCU) like an
Arduino.
The module shown in the photos is
a low-cost unit we obtained from an
AliExpress vendor in China, “Mi Yu
Koung”. It comes complete with two
pH sensor probes (one ‘refillable’ and
the other not), each with a 1m-long
cable fitted with a BNC plug.
They also came with a small container of electrolyte for topping up the
refillable probe, four 10mm-long M3
screws and four matching nuts, for
mounting the module. There was also
a mounting nut and spring washer for
the module’s BNC socket, providing
the alternative option of mounting it
behind a panel.
This module ‘kit’ cost us $11.52 plus
$9.75 for shipping, for a total of $21.27.
We found an identical kit is available
from an eBay supplier called Garmenthouse No.1, for just under $20 with
free delivery.
We found that another module
called the DFRobot Gravity pH Meter
V2.0 is available in Australia, from
suppliers such as Core Electronics and
element14. This one comes with only
one pH probe, for about $82.00 plus
$10 for express delivery.
Module circuit details
Returning to the module shown in
the pictures, it is on a 42×32mm PCB
with the input BNC socket protruding
from one end, and a 6-pin SIL output
header at the other. The full circuit is
Fig.2: an example of a combination
probe, which has both electrodes in a
single probe body. The main electrode
is located inside a very thin, porous
glass membrane.
Fig.3: the electrical
output of an ‘ideal’
probe should be a
linear change in
voltage relative to
pH as shown in this
graph.
The sensor module
The job of the pH meter module is
essentially to amplify this low output voltage swing from the probe,
boosting it to a level where it can
be measured accurately by the ADC
siliconchip.com.au
Australia's electronics magazine
September 2023 37
Fig.4: the circuit
diagram for a
cheap pH module
which was
purchased from
AliExpress. The top half of the
circuitry involves processing
the signal from the pH probe,
while the lower half provides
an analog signal indicating the
module’s temperature.
shown in Fig.4, but don’t be fooled by
its apparent complexity.
The only section involved in processing the signal from the pH probe
connected to CON1 (the BNC socket)
is the top half, involving shunt regulator VREF1, op amps IC1a and IC1b
and, to a lesser extent, IC2a.
The lower half of the circuit, involving IC2b, TH1, IC3a and IC3b, is purely
to provide an analog signal indicating
the temperature of the module, via pin
6 (TO) of CON2. That could be useful
as a way to adjust for the temperature’s
effect on the pH readings, although the
module’s temperature won’t necessarily be the same as the temperature of
the liquid being tested.
The pH+ electrode signal from the
probe via CON1 goes directly to input
pin 3 of op amp IC1a. IC1 is a TLC4502,
a dual self-calibrating precision CMOS
op amp with an input bias current of
only 1pA (0.001nA). It therefore provides very little loading to the signal
from the pH+ electrode.
Since IC1a has negative feedback
applied via the 20kW and 10kW resistive divider, it amplifies the pH+ signal
by three times, sending the amplified
signal to pin 4 (PO) of output connector CON2.
The purpose of the circuitry at upper
left, involving VREF1 and IC1b, is
38
Silicon Chip
to generate a ‘bias offset’ voltage to
the pH− reference electrode of the
probe. Since the output voltage from
the probe can swing either positive
or negative with respect to zero, that
could be a problem for IC1a since its
output can only swing between +5V
and ground (0V).
By feeding a bias voltage to the
probe’s P− reference electrode, the
These two buffer solutions were
purchased from an Australian
supplier and came in 125mL
containers. Most buffer solutions will
have tolerance of ±0.01pH, which
explains the labelling of 7.01 for a
7pH buffer.
Australia's electronics magazine
pH=7 ‘zero’ voltage of the P+ electrode is shifted upwards so that the
output voltage of IC1a at pH=7 moves
up to +2.5V, allowing it to swing up
or down without problems. This also
means the ADC monitoring the output
signal doesn’t need to be able to deal
with negative voltages.
Trimpot VR1 and the 5.1kW resistor reduce the 2.5V output of VREF1
to around 0.83V, which when amplified by three times by IC1a, gives the
correct 2.5V offset. The offset voltage
is buffered by voltage follower IC1b
before being fed to the pH− probe connection of CON1.
If the pH=7 output of the probe is
exactly zero (as with an ideal probe),
and the gain of IC1a is exactly three
times, the bias voltage applied to pin 5
of IC1b would need to be exactly 2.5V
÷ 3 = 833mV.
However, with a real probe and real
resistors that differ from their nominal
values, that might vary. VR1 allows
the bias voltage to be adjusted until
the output of IC1a is close to +2.5V
when pH = 7.
The circuitry at centre right in
Fig.4, around VR2, IC2a and LED1
detects when the output voltage from
IC1a rises above a certain threshold.
IC2a is connected as a simple comparator, comparing the output of IC1a
siliconchip.com.au
Fig.5: a plot of the nominal output voltage over the full pH range for the module,
taken at pin 4 of CON2 (PO).
with a reference voltage set by trimpot VR2.
So when the output voltage of IC1a
rises just above that level, the output of
the comparator will drop to near-zero
and LED1 will light. The voltage level
at pin 5 (DO) of CON2 will also drop
to near zero, allowing the situation to
be detected by the MCU if required. At
the same time, LED2 simply acts as a
power-on indicator.
Fig.5 is a plot of the nominal output
voltage of the module at CON2 pin 4
(PO) for the full pH range from pH=0
to pH=14. It should provide an output
voltage of 2.50V for a pH of 7.0, rising
to 3.74236V for a pH of 0 and falling
to 1.25464V for a pH of 14.
DFRobot Meter differences
Before moving on, I should mention
that the DFRobot Gravity pH Meter
V2.0 module mentioned earlier only
provides an amplified analog version
of the pH probe’s output, with no
added ‘frills’.
It also allows the pH− output of
the probe to be connected directly to
ground. This is done by using a DC-DC
converter to provide the main op amp
with a -5V supply as well as the +5V
supply. It is also provided with a
mini polarised 3-pin output connector (instead of the 6-pin SIL header),
siliconchip.com.au
plus an output cable with a matching
3-pin plug.
In addition, it comes with four small
containers of pH standard buffer solution, two with pH = 7.0 and two with
pH = 4.0.
Connecting to an MCU
Since the module has an analog
voltage output within the 0-5V range
and is designed to operate from a DC
supply voltage of 5V, it is quite easy
to connect it to an MCU such as an
Arduino Uno or Nano. You just need
to connect its + and - power pins to
the +5V and GND pins on the MCU
board, and its PO output pin to one
of the MCU’s analog input pins, such
as A0, as shown in Fig.6.
Fig.6 also shows the Arduino connected to a 16×2 character alphanumeric LCD with an I2C serial interface,
so it can display the pH reading. More
about this shortly.
Now we just need firmware to sense
the module’s output voltage and convert it into the equivalent pH value.
After a bit of internet searching, I found
the website www.circuitdigest.com
that has an article by Debasis Parida
describing a pH Meter using the module we are focusing on here, together
with an Arduino Uno and a 16×2 LCD
display.
Australia's electronics magazine
A close-up of the tip of the probe that
came with the pH meter module. You
should just be able to see the two
electrodes, The main electrode is a
very thin winding wire in the centre.
September 2023 39
Fig.6: a wiring diagram showing how to connect the pH meter module to an Arduino Uno or similar. We have also
incorporated a 16x2 LCD module with I2C serial interface so that it can display the pH reading.
He also provided an Arduino
sketch, although there were a few
drawbacks: he had a parallel interfaced LCD, rather than one with an
I2C serial interface, and his code for
converting the module’s analog voltage readings into equivalent pH values was a bit convoluted and difficult
to follow.
So I decided to write a sketch of
my own. It is named “Arduino_pH_
meter_sketch.ino” and is available to
download from the Silicon Chip website. When you upload the sketch to
the Arduino and it begins running, it
gives you this opening display:
Silicon Chip
Liquid pH Meter
After pausing for two seconds, it
starts measuring the output voltage
from the pH amplifier module, converts it into the equivalent pH value
and then displays both the pH value
and the amplifier module’s output
voltage, like this:
pH = 7.0
Vaverage = 2.50V
It continues doing this every two
seconds. If you’re wondering why
the second line displays “Vaverage”,
that is because the sketch calculates
the average of 10 measurements to
compensate for minor fluctuations in
probe output.
The sketch also sends the pH value
and the average module output voltage back to your PC or laptop via the
Arduino’s serial port if you have it
connected. So if you start up the Arduino IDE’s Serial Monitor, you’ll see the
40
Silicon Chip
same information appearing every two
seconds.
Once you have the pH module and
probe connected to an Arduino as in
Fig.6 and have uploaded the sketch
to the Arduino and seen that it works,
there is still one further step before
your pH Meter is ‘ready to go’. This
the important step of calibration.
Probe and module calibration
This step is particularly important
because every pH probe is slightly
different in terms of its pH to voltage
conversion characteristic. Before you
can start using the probe seriously,
you have to test its response with
liquids at a minimum of two known
pH levels. This calibration needs to
be done not only before you start
using the pH Meter, but every time
you change probes or clean/refurbish
your probe.
Calibration is a two-step operation.
First, you place the probe into a ‘neutral’ liquid like distilled water, with a
known pH of 7.0. Then you can adjust
trimpot VR1 on the module (the one
nearer CON1, the BNC input connector) until the LCD readout gets as close
as possible to show pH = 7.0 and Vaverage = 2.50V.
The second calibration step is to
place the probe into a different liquid,
with a known pH that is well away
from 7.0; say, 4.0 or 10.0. This will
allow you to work out the effective
slope of the probe’s transfer characteristic. If you get a pH reading that
differs significantly from the correct
figure, you can make a change in the
Meter’s sketch to correct for this error.
Australia's electronics magazine
And while you can use distilled
water for the pH 7.0 reference buffer,
it is not so easy to find another liquid
with a known pH of 4.0 or 10.0. You
really need to get a reference solution
from a reputable supplier.
While you can find many suppliers
of reference buffer solutions on the
internet, many are overseas and can
only supply them in large containers
that cost a lot to ship. Luckily, I found
a local Australian supplier offering
two 125mL bottles, one of pH7 buffer and the other of pH4 buffer, for
the modest cost of $15.50 plus $8.95
for shipping.
This supplier is My Slice of Life
Pty Ltd, located at Shop 2, 159 Vincent Road, Wangaratta Victoria 3677.
Phone: (03) 5798 3489
Web: https://mysliceoflife.com.au
I ordered one of these packs of buffer
solution, and they can be seen in the
photo. When they arrived, I was therefore able to have a go at calibrating the
pH module and one of its probes.
Running into difficulties
Unfortunately, I soon struck a puzzling problem: when the hardware was
hooked up as in Fig.6 and either of
the probes connected to CON1 of the
module with its tip end submerged in
the pH = 7 buffer solution, no adjustment of trimpot VR1 would allow the
pH value to be displayed at anywhere
even close to 7.0.
The maximum pH displayed
remained no higher than 2.60, with
Vaverage no lower than 3.28V – much
higher than the correct figure of 2.50V.
At first, I suspected that trimpot
siliconchip.com.au
VR1 was faulty, but when I replaced
it, there was no change. Then I wondered if there might be a dry joint on
the module’s PCB, in the vicinity of
IC1. But resoldering any joints that
looked dubious still didn’t cure the
problem.
So it wasn’t possible to calibrate
the pH module with either of the two
probes supplied with it. I suspected
that either the probes themselves had
‘dried out’, or that IC1a has been damaged due to static charge on one of the
probe cables.
One further thing I should mention: I could not find any way to gain
access to the ‘refill’ opening near the
top of the refillable probe. The cover
ring seemed to be stuck in position, so
there was no way to top up its inner
electrolyte.
In the hope of providing some
answers to these problems, we ordered
another module and an accompanying non-refillable probe. When these
arrived we tried seeing if the new module and/or the new probe would give
more sensible results.
Cutting a long story short, the
replacement module and probe didn’t
perform any better than the first ones.
With the probe in a pH = 7.0 solution,
trimpot VR1 still would not allow the
value of Vaverage to be taken below
2.93V, giving a pH reading of 4.58.
Way off!
I tried various things to see if I could
track down the cause of this problem,
including re-checking my sketch to see
if I had made any programming errors,
measuring the actual gain of op amp
IC1a (it turned out to be 2.997 – very
close to 3.0) and trying to run the module from 3.3V instead of 5V. But none
of these provided any clues as to the
real cause of the problem.
Then I decided to see if I could
make trimpot VR1 able to bring the
Vaverage level down to 2.50V when the
probe was in a pH = 7 buffer solution.
After a bit of experimenting, I found
this could be done by connecting a
5.6kW resistor in parallel with the
5.1kW resistor connecting pin 5 of
IC1b to ground, bringing its effective
value down to 2.67kW.
This allowed the module and probe
to give correct readings of pH = 7 when
the probe was in either distilled water
or the pH7.00 buffer solution.
Astute readers may have spotted
the design flaw in the circuit earlier
– the reference attenuator, including
siliconchip.com.au
trimpt VR1, does not have enough
range to reduce the 2.5V reference to
the 833mV needed for calibration. By
shunting the 5.1kW resistor, we are
fixing that flaw and providing enough
range for correct calibration. Why it
was designed this way is a mystery.
However, when I tried swapping
the probe over to the pH4.00 buffer
solution, there was still a problem:
the module was now giving a pH
reading of around 5.14, rather than
the correct 4.00. So I had to change
the value of the variable “Senslope”
in my Arduino sketch, from the ‘ideal
probe’ figure of 0.05916 volts per pH
unit to 0.0234.
So finally, after fiddling with both
the hardware and software, I was able
to get the probe and module combination calibrated – at least, at the two pH
levels of 7.0 and 4.0. Mind you, there
was still no real explanation as to why
these hardware and software changes
were necessary.
Nor was there any way to be sure
that the output characteristic of the
module was still linear, so the twopoint calibration would ensure correct
pH measurements at levels well away
from pH = 4.0 or pH = 7.0.
After further testing and analysis, I
determined that the high impedance
of the probe and the module’s input
circuitry means they pick up a fair bit
of noise and 50Hz hum, causing the
readings to vary up and down. This
means that the module needs to be
housed in an Earthed metal case, to
provide shielding. That would at least
give you a chance of being able to calibrate them out-of-the-box.
Summarising
I can’t give these particular modules and their probes a glowing report,
given that I wasn’t able to achieve calibration using the normal procedure,
and it’s unclear whether the readings
could be relied upon over the full pH
range!
The circuit design may seem to
make sense at a theoretical level, and
the probes and modules seem to be
made correctly. The problem is that
they don’t provide sufficient instructions on how to assemble the device
to avoid RF and mains hum pick-up
from interfering with the results.
We think the DFRobot Gravity pH
Meter V2.0 is more likely to work
without modification, given its higher
price and availability from more repSC
utable sources.
The AliExpress module also includes two separate pH probes (one ‘refillable’
and the other not), a small bottle of electrolyte and some mounting hardware.
Australia's electronics magazine
September 2023 41
|