Considering switching from PPM to EC, need advice.

The_Enthusiast

Active Member
Do you leave your probes in the solution 24/7 or do your remove them between checks? I'm guessing this uses industrial grade probes considering it cost so much.
Sorry for late reply - i was away for holidays.
The one i posted here isn't always in - its a "portable PH/EC/TEMP" tester.

But I saw one ORP and PH probes @ one pool and they were always in. And they died when they emptied the pool for 6 months and left them like that (to be precise the PH probe survived but ORP dies)
 

firsttimeARE

Well-Known Member
Which one and how much did it cost? I have one of their PH meters but I couldn't use it with an automated system or leave it running for prolonged periods of time since it runs off batteries and turns off.
$48.50 amazon prime bnc pH pen youd need a bnc shield.

I saw one on adafruit that had the,meter and shield for $50. Wasnt a bad deal at all.
 

firsttimeARE

Well-Known Member
Yes I am a programmer, although this is my first time writing this language, but they're all more or less the same.

I don't have a complete sketch for anything yet, but the sketch to run the pump I bought would just be something like.
Code:
const motorPin = 3 // this could be any available pin.

init () {
  pinMode(motorPin, OUTPUT);
}

loop() {
  if (runPump) { // this would be some indication that you want to turn the pump on, for me it's if the PH or EC is outside the acceptable tolerance I'm giving it. This could be simple or complicated depending on how you want to determine if the pump needs to run.
    digitalWrite(motorPin, HIGH);
    delay(1000); // this can be anything, in this case I'm choosing to run the pump for 1000 milliseconds [1 second] which equals 1ml
    digitalWrite(motorPin, LOW);
  }
}
That's very simplified as I'm not sure what exactly you're looking for when asking if I have a sketch. There are other concerns to consider also such as how do you determine if you should run the pump, how often should you run the pump and when was the last time the pump ran. For example my PH I want to check every hour, and the EC I want to check only once per day.

I'll be sharing my code, part list and build once it's complete but that could be a month or more. I think I'm going further than you're looking for though as I'm doing a touchscreen that allows me to monitor the PH and EC of the DWC system, set the EC levels, set the acceptable tolerance for the EC, purge the pumps to get air out of the lines, turn some motors on/off depending on if I'm using those nutes at that phase of growth, a flush mode that runs both EC and PH adjustments on a more aggressive schedule to get the soup back up to the correct EC/PH rapidly after a flush. Maybe a couple other features that I'm forgetting atm.

Aigh so much work to do! This EC meters code is causing issues atm so time to get back to that :/
Im looking for something that loops a pH check with an if condition to turn on a peristaltic pump for a couple seconds. That if condition is a pH value. This loop would run every 5 minutes.

If I understand this correctly the pH meter will register a certain voltage and this is what the arduino reads so you need to tell it the voltage to look for.
 

ttystikk

Well-Known Member
Which one and how much did it cost? I have one of their PH meters but I couldn't use it with an automated system or leave it running for prolonged periods of time since it runs off batteries and turns off.
Almost all of their pH probe tips are the same and interchangeable.
 

Eric Farley

Active Member
Im looking for something that loops a pH check with an if condition to turn on a peristaltic pump for a couple seconds. That if condition is a pH value. This loop would run every 5 minutes.

If I understand this correctly the pH meter will register a certain voltage and this is what the arduino reads so you need to tell it the voltage to look for.
If you just want to wait 5 minutes from the last time you checked the pH you can use a simple delay. delay(300000) would equal 5 minutes. As far as reading the pH you'll have to figure that out. I purchased a pH meter and shield from dfRobotics that just gives me the pH value as it would be on any meter. So with the pH meter I have I can do:

Code:
void loop() {
  float pH = getPh() // This method would use code provided in the adruino example code that came with the meter and would return a pH value i.e. 5.8
  if (pH > 5.9) { // If the pH is above 5.9 it's too high, so lets lower it.
    digitalWrite(phDownPin, HIGH); // Turn the pump that has pH down on.
    delay(500); // allow the pump to run to 1/2 second to dispense 1/2 ml. I use half the ph down as I do ph up because I find my ph down is stronger.
    digitalWrite(phDownPin, LOW); // Turn the pump that has pH down off.
  else if (pH < 5.7) { // If the pH is below 5.7 it's too low so let's increase it.
    digitalWrite(phUpPin, HIGH); // Turn the pump that has pH up on.
    delay(1000); // allow the pump to run for 1 second so it dispenses 1ml of pH up.
    digitalWrite(phUpPin, LOW); // Turn the pump that has pH up off.
  }
  delay(300000); // wait 5 minutes and run the loop again.
}
 
Last edited:

firsttimeARE

Well-Known Member
If you just want to wait 5 minutes from the last time you checked the pH you can use a simple delay. delay(300000) would equal 5 minutes. As far as reading the pH you'll have to figure that out. I purchased a pH meter and shield from dfRobotics that just gives me the pH value as it would be on any meter. So with the pH meter I have I can do:

Code:
void loop() {
  float pH = getPh() // This method would use code provided in the adruino example code that came with the meter and would return a pH value i.e. 5.8
  if (pH > 5.9) { // If the pH is above 5.9 it's too high, so lets lower it.
    digitalWrite(phDownPin, HIGH); // Turn the pump that has pH down on.
    delay(500); // allow the pump to run to 1/2 second to dispense 1/2 ml. I use half the ph down as I do ph up because I find my ph down is stronger.
    digitalWrite(phDownPin, LOW); // Turn the pump that has pH down off.
  else if (pH < 5.7) { // If the pH is below 5.7 it's too low so let's increase it.
    digitalWrite(phUpPin, HIGH); // Turn the pump that has pH up on.
    delay(1000); // allow the pump to run for 1 second so it dispenses 1ml of pH up.
    digitalWrite(phUpPin, LOW); // Turn the pump that has pH up off.
  }
  delay(300000); // wait 5 minutes and run the loop again.
}
Did that program come with your meter or did you write that?

Whats the setup look like? Didnt know getph or float ph was a command. Or is that part of the "example code" mentioned after the //?
 

Eric Farley

Active Member
Did that program come with your meter or did you write that?

Whats the setup look like? Didnt know getph or float ph was a command. Or is that part of the "example code" mentioned after the //?
I wrote that myself for the post. The setup would just be setting the pinMode for the motor pins.

getPh and float ph aren't commands built into Arduino.

getPh is a custom function (method) where I copied the code provided by the probe vendor. For me I purchased this probe: https://www.dfrobot.com/index.php?route=product/product&product_id=1110&search=sen0169&description=true#.Vl07WPmqqAx. If you scroll down you'll see a section called 'documents' which has a link to the arduino example. I went through that and copied the bits I needed and pasted them inside my custom getPh function. The code inside this function and how it gets the ph could vary widely from probe to probe but regardless this function would get a reading from the probe and return a ph value.

float is a data type for a number that can have decimal places. ph is the name of a variable I'm creating to store the value of the ph in. So float ph is just declaring a variable to store the value of the pH as a float data type.

Here is the Arduino reference guide, both custom functions and data types including float are documented. https://www.arduino.cc/en/Reference/HomePage
 
Last edited:

Eric Farley

Active Member
Code:
const int phUpPin = 3; // this is just whatever pin you have the pump connected to, it doesn't need to be pin 3;
const int phDownPin = 4; // again this can be any pin.

void setup() {
  pinMode(phUpPin, OUTPUT);
  pinMode(phDownPin, OUTPUT);
}

void loop() {
  float pH = getPh() // This method would use code provided in the adruino example code that came with the meter and would return a pH value i.e. 5.8
  if (pH > 5.9) { // If the pH is above 5.9 it's too high, so lets lower it.
    digitalWrite(phDownPin, HIGH); // Turn the pump that has pH down on.
    delay(500); // allow the pump to run to 1/2 second to dispense 1/2 ml. I use half the ph down as I do ph up because I find my ph down is stronger.
    digitalWrite(phDownPin, LOW); // Turn the pump that has pH down off.
  else if (pH < 5.7) { // If the pH is below 5.7 it's too low so let's increase it.
    digitalWrite(phUpPin, HIGH); // Turn the pump that has pH up on.
    delay(1000); // allow the pump to run for 1 second so it dispenses 1ml of pH up.
    digitalWrite(phUpPin, LOW); // Turn the pump that has pH up off.
  }
  delay(300000); // wait 5 minutes and run the loop again.
}

float getPh() {
  float ph; // declare a ph variable to store the value so we can return it.
  // copy and paste code from the probe vendor to get a useful reading from the probe. Set the reading to the ph variable we just declared.
  return ph; // return the ph to the previous function that called getPh so that we can do ph = getPh() there.
}
 

firsttimeARE

Well-Known Member
I wrote that myself for the post. The setup would just be setting the pinMode for the motor pins.

getPh and float ph aren't commands built into Arduino.

getPh is a custom function (method) where I copied the code provided by the probe vendor. For me I purchased this probe: https://www.dfrobot.com/index.php?route=product/product&product_id=1110&search=sen0169&description=true#.Vl07WPmqqAx. If you scroll down you'll see a section called 'documents' which has a link to the arduino example. I went through that and copied the bits I needed and pasted them inside my custom getPh function. The code inside this function and how it gets the ph could vary widely from probe to probe but regardless this function would get a reading from the probe and return a ph value.

float is a data type for a number that can have decimal places. ph is the name of a variable I'm creating to store the value of the ph in. So float ph is just declaring a variable to store the value of the pH as a float data type.

Here is the Arduino reference guide, both custom functions and data types including float are documented. https://www.arduino.cc/en/Reference/HomePage
So since,arduinos only recognize,integers and,round decimals up youre defining ph as a float variable so it recognizes decimals?

Is the custom getph,function a separate file?
 

Eric Farley

Active Member
So since,arduinos only recognize,integers and,round decimals up youre defining ph as a float variable so it recognizes decimals?

Is the custom getph,function a separate file?
Arduino understands more than integers, they are one of many different data types. Integers are a data type that only includes whole numbers and will remove decimals. float is similar data type that stores floating point numbers meaning they have a decimal point, even if that decimal is 0, i.e. 4.0. There are many other data types that don't deal with numbers, and more data types that do deal with numbers such as negatives. In the case of pH you always want a floating point number, i.e. float.

No the getPh function would just be inside the same file as the loop. In an ideal world for a production quality application I would want to include the vendor code in an external library and import that library into my sketch to use, but that isn't how it was provided to me from the vendor and I don't feel that it's worth the time to do that myself so I choose to have a large monolithic sketch.
 
Last edited:

firsttimeARE

Well-Known Member
So all thisbgetph function is is a library of conversions that convert a voltage registered by the probe into a pH value variable that the function uses to control pumps,based on where the pH lands?
 
Top