Hardware pH Monitoring

Hardware pH Monitoring

pH Monitoring

I would like to automate pH control of my swimming pool, but it has proven to be a much more complex task than I had imagined.

My pool has an electrolytic chlorine generator. The pool contains salt, and the chlorinator generates Chlorine by electrolysis. In many ways this is an ideal way to sanitise a pool, but the chlorinator causes the pH to rise, which requires the regular addition of acid to bring the pH back within acceptable limits. In theory it should be easy enough to automate this. But it’s not as easy as you might think.

I once bought and installed a commercial pH controller. On the first night it was installed, it pumped an entire 5 litre container of acid into the pool. There was no way to investigate what had happened, and the instructions did not explain the algorithm being used. I never gave it a second chance, it simply wasn’t up to the job at all.

With a system that can automatically pump acid into a swimming pool, there is no room for error. It must be easy to see what is happening and why, and ideally there should be a detailed log of everything that happens. There must be safeguards, such as a maximum amount of acid to add in any given time period, and the system should be able to summon human intervention if the pH goes outside some preset limits. I’m not even sure I can trust a peristaltic pump at all – what if the computer controlling it crashes while the pump is running? For me, automatic control is a long way off.

The first step is the pH sensing system. I’m using a standard pH probe mounted in the pool filtration plumbing. Previous experiments showed that fast moving water does not give accurate readings, so my pH sensor is mounted in a short dead-end branch teed off the main flow, like this:

In theory, building a pH interface should be easy, but I tried a couple of home-made interfaces and stability was a problem. Dealing with a high impedance device like a pH probe requires some very careful circuit construction and I finally gave up on building my own. Eventually, I found the perfect interface adaptor at Phidgets. It takes a standard pH sensor with a BNC connector, a 5v supply, and provides an analog output of 0 – 5v, which is the perfect input for a DS2450 one-wire analog to digital converter. No other components are required. Here’s the Phidgets pH adaptor with my DS2450 mounted on a piece of strip-board.

The interface itself works very well indeed. I calibrate it using two reference solutions and a simple linear calibration formula.

Calibration using two reference solutions of known pH provides two reference voltages:

V1 = pH1
V2 = pH2

Once these calibration values are known, the pH of any unknown liquid can be calculated using the following formula:

pH = ((Raw_value – V1) * (pH2 – pH1) / (V2 – V1)) + pH1

My Felix software does this rather effortlessly. You can see live data here, but only in the summer and only if everything is working. Here’s a typical day:

When the filtration pump runs, so does the chlorinator, and the charge it applies to the water obviously affects the pH sensor. The chlorinator reverses its polarity every time it starts, hence the sensor is affected the opposite way on each cycle.

Finally, I can now see why that commercial pH controller pumped an entire 5 litre container of acid into the pool on the first night it was installed.

One possible fix for this could be to plumb in a small-bore tee off the main flow, through earthed metal tube, to a chamber housing the pH sensor, returning to the main flow via another earthed metal tube.