Python code for ORP readings conversion to Chlorine (in ppm)

seanny

0
Aug 3, 2015
1
Singapore
Hi I am Sean from singapore. Just would like to let everyone know some significant differences in how we manage chemical levels in pools here as compared to other countries, especially Western nations.

1) We don't measure CYA levels (or perhaps use CYA in our pools)

2) We measure Chlorine in ppm, rather than using ORP readings.

Hence I am building a prototype auto dosing system powered by Raspberry Pi for a client. My sensors are purchased from Atlas Scientific, which means having an ORP Probe. This is my first time coding in 4 years, hence I would like to know whether anyone has coded conversions from ORP readings to free chlorine (in ppm).

Otherwise, I am stuck with using the ORP conversion charts and developing an algorithm to understand the trend of chemical levels in pools over time.

Looking forward to your constructive feedback.
 
Without CYA how do you manage the FC level? It has to be very low, like .1 or.2 ppm without CYA. TFP will even recommen some CYA, around 20 ppm, for indoor pools, just to help buffer the effects of chlorine. It also makes management much easier.

This is for residential pools. Commercial pools are treated a little differently and are outside of my comfort zone.

- - - Updated - - -

If you do some searches around this forum you will find lots of info about ORP sensors. Look for posts by Chem Geek, JoyFullNoise and others.

- - - Updated - - -

In general, automated systems have a poor track record due to things you are starting to find out. One of the big issues, is the need to calibrate sensors on a regular basis. If you are going through that effort, you might as well, just test with a good kit, and manual dose the chlorine and pH adjustment yourself.
 
Welcome to TFP! :wave:

If you use slow-dissolving chlorine tablets, then they are Trichlor and for every 10 ppm FC they also increase CYA by 6 ppm. See this thread that seems to indicate that CYA is measured in some test kits available in Singapore and that both granular chlorine and tablets of Trichlor are available.

As for ORP the precise relationship to FC varies by sensor model and manufacturer and the readings can be impacted by hydrogen gas bubbles in saltwater chlorine generator systems, by sunlight, and by the presence of organic material in the pool that has nothing at all to do with the rate of disinfection that is determined primarily by the FC/CYA ratio. It is also inversely affected by temperature in a way that is the opposite of chlorine's effectiveness and is affected by pH beyond actual hypochlorous acid levels. Such ORP sensors typically get fouled by higher CYA levels and being a logarithmic scale they go wild with noise at lower ORP levels associated with lower FC/CYA ratios (so typically higher CYA levels).

This post gives a couple of HOCl and pH to ORP formulas while this post gives even more (though I wouldn't trust the Aquarius or Sensorex sensors) and this post shows how wildly scattered real ORP readings are in pools where 23% of pools with more than one sensor varied by 100 mV or more which is roughly a factor of 16 difference in FC all else equal!

As for approximating HOCl levels in pools, you can roughly use half the FC/CYA ratio for that. If there is no CYA in the water at all, then you can use roughly half the FC level if the pH is near 7.5.

Basically, you shouldn't try and use a fixed formula and instead should just report ORP and allow the user to MANUALLY create a setpoint to maintain that ORP. You should then separately and independently maintain the pH at a constant level using a separate pH sensor and pH chemical dosing system. That way, if the pool water temperature is maintained, the ORP can be used for process control though it will still need to be checked (compared against actual measured FC) regularly. In the U.S., states require such cross-correlation checking several times per day if ORP systems are used. ORP is not generally allowed to be relied upon by itself.

As for approximating a delta FC vs. ORP with all else equal, the rough relationship can be expressed as a certain number of millivolts of ORP per doubling of FC. For the Chemtrol sensor, this is roughly 22 mV/(2xFC) while for Oakton it is roughly 28 mV/(2xFC). So once you have a setpoint for a given FC you can approximate the delta in FC. For example, let's say that you set 3 ppm FC with 30 ppm CYA that reads as 683 mV on the Chemtrol. If the ORP drops by 22 mV to 661 mV then this means that the FC has dropped by half to around 1.5 ppm FC. Likewise if the ORP rises by 22 mV to 705 mV, then the FC has roughly doubled to 6.0 ppm FC. In reality the FC numbers are 1.65 and 5.2 because it's HOCl and not FC that affects ORP and the FC/CYA ratio is not a perfect proxy for HOCl at different ratios (though it's close enough for rough work). So the following formula could be used generically and you just need to find the actual factor that is involved at a given temperature, pH, and CYA level:

ORP = k1 + k2*ln(FC)
FC = e(ORP - k1)/k2

where you can find k2 by seeing how ORP varies with changes in FC as follows:
d(ORP)/d(FC) = k2/FC0
or
k2 = FC0 * d(ORP)/d(FC)
or better yet if you can't measure small incremental differences:
ORP2 - ORP1 = k2*(ln(FC2) - ln(FC1))
so
k2 = d(ORP) / d(ln(FC))

and then find k1 at a given setpoint. After that, you can use the FC formula as a function of ORP with your k1 and k2 constants to try and adjust dosing. Here's an example of some readings one might get from a Chemtrol sensor at two points at 85ºF, pH 7.5, CYA 30 ppm:

FC ... ORP
3.0 ... 683
4.0 ... 694

k2 = (694-683)/(ln(4.0)-ln(3.0)) = 38.2
k1 = 683 - 38.2*ln(3.0) = 641
k1 = 694 - 38.2*ln(4.0) = 641

so the following are rough formulas relating ORP and FC for the Chemtrol under the conditions I stated:
ORP = 641 + 38.5*ln(FC)
FC = e(ORP - 641)/38.5

the mV per doubling of FC (ignoring some non-linearity of FC/CYA vs. HOCl) is 38.5*ln(2) = 26.7 mV. My earlier 22 mV/doubling statement was at higher active chlorine levels when no CYA is present. When CYA is present, higher FC raises HOCl a little more than just proportionally.

Does that help?
 
Thread Status
Hello , This thread has been inactive for over 60 days. New postings here are unlikely to be seen or responded to by other members. For better visibility, consider Starting A New Thread.