pH controller design

Have anyone done pH controller using NodeRED ?

Hi Aloka,
Can you share what you’ve tried so far or found already? For example, what pH sensor do you use, is it analog or digital, how did you connect it, and so on.
For example, I know that Atlas Scientific’s pH probes can be read in a couple different ways including over a serial connection. They can also be connected to arduino or raspberry pi directly through a device/hat called the Tentacle (T3). I’m seriously thinking about using them for a project of mine.

Hey @afelix, We are just planning to set things up for our hydroponics business in near future. So this is what we are up to as per your question. Till now we are doing all things manually. and BTW that is great to know about "Atlas Scientific’s pH probes". We will look into it. What else we should look into ?

That’s nice, I’m looking into it for hydroponics too. Atlas Scientific also creates good quality temperature probes and electric conductivity probes. All of them can be submerged, and depending on how you try to connect them they can be hooked to a single Tentacle T3 hat on top of a raspberry pi. It also exposes 2 inputs for I2C, one (or both) could be used to connect a peristaltic pump to mix your nutrient solution.

1 Like

The sure fire way to control pH is to build a lookup table (aka: function generator).

PID controllers won’t control it reliably due to the logarithmic nature of pH.

First things third, you need to know how you will add your base/acid and in what volume. Dosing pumps are typically used and can be set to dispense a predefined amount per dose.

Once you have that figured out, google pH titrations and pH lookup table controllers.
The titrations will be used to populate your lookup table.

Basically you want to find out the ratio between the volume of liquid to treat and how much volume of acid/base is needed to correct it to your needs.

A titration will need to be done for the acid and the base separately because both have different reaction times.

Once you have your samples, you can build your function generator that will output or infer the amount of acid/base to add to correct your pH based on your current pH and it’s concentration.

1 Like

I have never tried but in principle that should be solved by controlling the log of pH (or the antilog dependent on which way round it is). Does that not work?

Take a look at Tentacle T3 for Raspberry Pi (retired) – Whitebox Labs
t’s stackable and hosts up to 5 EZO devices from Atlas Scientific to measure PH, Dissolved Oxygen, Electric Conductivity (E.C.), Oxidation-Reduction Potential (ORP) temperature (RTD), peristaltic pump (EZO-PMP).

2 Likes

I particularly like how stackable they are:

I've been looking at Atlas Scientific probes as well as the T3 for a little under a year now. I've been looking into hydroponics for a couple years and I'm still trying to figure out if it would be worthwhile to set it up for personal usage rather than going commercial. So far I've figured out I can likely get the costs for starting up and operating out if I were to scale up and sell leftover produce, but working out if it would be worth it for the smaller scale is harder. Hence why I've read all these pages several times, but haven't bought any of them yet.

If you’re super clever with math, maybe you can do something with the log.

Not everyone, including me, is super clever with math. A lookup table is the one thing that does work very well and doesn’t require a deeper understanding of the math going on in a PID.

A PID will control the pH, but you will exacerbate the difficulty getting it to finely control it. It will more less always hover above and below your setpoint. For some applications that don’t require accuracy, this is fine.

Using a lookup table is horrible, as you say that will never give you accurate results. The right way is using a linearisation function to approximately linearise the relationship between the control input and the pH. If anybody wants to do that then post where I can find the data and I will have a look. Not unless someone is actually going to try it out though, I don't want to spend the time unless it is worthwhile.

1 Like

I worked in various dyehouses for over 40 years so pH control is almost second nature to me.

Automatic pH control is extremely complex and has to take into account a number of variables:

  1. Total system capacity.

  2. Native water hardness.

  3. Strength of acid/alkali donors for adjustments.

  4. Accurate dosing of donors and time to reach pH equilibrium.

  5. A meticulous electrode calibration scheme (For hydroponics a 1 point calibration daily at pH 4.01 should suffice)

  6. Electrode contamination, electrodes need to be kept clean, and some are not suitable for continuous immersion.

There are automatic systems available but as always at a price.

https://www.hg-hydroponics.co.uk/ph-ec-dosers--monitors-483-c.asp

I would love to see a node-red solution, small peristaltic pumps are quite cheap too.

2 Likes

Having got all that setup what control algorithm was used to do the real time control?

I only ever saw automatic pH control on 2 dyeing machines in all those years, they were commercial - hard coded, I have no idea of the algorithm used, they were also very maintenance intensive.
I think for hydroponics, where the pH range is from 5.5-5.8 to 6.5 it might be easier to just drive a peristaltic pump for a given time, wait until the pH stabilises and see how the pH has changed, repeat until an acceptable tolerance is reached. A job for Fuzzy Logic maybe?

2 Likes

A function generator will make it linear by using the titration data gathered from samples. It will characterize the the amount of acid/base added to the change in pH.

You would ultimately know if pH is X away from setpoint, you need to add approximately Y of acid/base to correct it.
Sure, it will not correct it exactly to the setpoint, but it would be extremely close. From there, you can wait for the pH to stabilize and then add acid/base in smaller amounts until neutralization is reached.

I built an entire water monitoring system using node-red and multiple Atlas Scientific probes (pH, EC, DO). I have a bunch of nod-red code that handles the challenge of determining which sensor is reporting measurements, calibration, etc. Let me know if you want to chat.

1 Like

Yeah @dennishvo, Come online.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.