Oak pH Measuring Circuit with Dosing Pumps

So the hydroponics tomatoes and cucumbers are coming to an end and the plan is to convert the other side of the greenhouse to also be hydroponics since its doing so well and requires near zero upkeep.

That bring  up my new project; the only upkeep that is required with the current setup is adjusting the pH on a weekly basis and adding nutrients from time to time.  The Oak pH Measuring Circuit with Dosing Pumps will now take care of the weekly pH adjustments for me.

The whole circuit is very simple and only required the following parts...
2 12v DC DIY Dosing Pumps from https://amzn.com/B00KJ5X1NY for $11.49
1 Analog pH Meter Kit from https://amzn.com/B01BNG41KO  for $34.40
2 PN2222a transistors
2 10k resistors
1 LM7805 Voltage Regulator
2 Push button tack switches
1 Digistump Oak or another Arduino that fits your needs.

Here is the code:

double pH = 0;
int acidMotor = 9;
bool acidMotorStatus = false; //particle.io monitor pump use
int baseMotor = 10;
bool baseMotorStatus = false; //particle.io monitor pump use
int led = 1;
double perfectpH = 5.5; //pH which would be best for our vegies
double pHBuffer = 0.3; //buffer so pumps arent running all of the time
int waitForDrips = 60; //Default 60 to count down from to run puumps (if needed)
int waitForDripsSet = 60; //Countdown from this number to run pumps (if needed)
int acidRunPin = 6;
int baseRunPin = 7;
int motorRunTime = 1000; //How long to run the motors

void setup() {
  Serial.begin(9600);
 
  pinMode(acidMotor, OUTPUT);
  pinMode(baseMotor, OUTPUT);

  pinMode(acidRunPin, INPUT);
  pinMode(baseRunPin, INPUT);
 
  pinMode(led, OUTPUT);
 
  Particle.variable("pH", pH);
  Particle.variable("AcidMotor", acidMotorStatus);
  Particle.variable("BaseMotor", baseMotorStatus);
}

void loop() {
  double reading = analogRead(A0); //Read the pH probe
  pH = reading / 59.16; //divide pH probe reading by 59.16

  waitForDrips--; //wait to run pumps (if needed) until zero is reached.
  if (waitForDrips <= 0)
  {
    waitForDrips = waitForDripsSet;
    if (pH < perfectpH - pHBuffer)//too much acid.  Put in a couple drops of base
    {
      baseMotorStatus = true;
      digitalWrite(baseMotor,HIGH);
      digitalWrite(led, HIGH);
      delay(motorRunTime); //this might be too much or too little depending on the amount of water you are trying to change
      digitalWrite(baseMotor,LOW);
      digitalWrite(led,LOW);
      baseMotorStatus = false;
    }
    else if (pH > perfectpH + pHBuffer)//too much base.  Put in a couple drops of acid
    {
      acidMotorStatus = true;
      digitalWrite(acidMotor,HIGH);
      digitalWrite(led, HIGH);
      delay(motorRunTime); //this might be too much or too little depending on the amount of water you are trying to change
      digitalWrite(acidMotor,LOW);
      digitalWrite(led,LOW);
      acidMotorStatus = false;
    }
  }

  int acidState = digitalRead(acidRunPin); //Priming Button for acid
  int baseState = digitalRead(baseRunPin); //Priming Button for base
 
  if (acidState == HIGH || baseState == HIGH)
  {
    if (acidState == HIGH)
    {
      digitalWrite(acidMotor,HIGH);
      digitalWrite(led, HIGH);
    }
    if (baseState == HIGH)
    {
      digitalWrite(baseMotor,HIGH);
      digitalWrite(led, HIGH);
    }
  }
  else
  {
    digitalWrite(acidMotor,LOW);
    digitalWrite(baseMotor,LOW);
    digitalWrite(led,LOW);
  }
   delay(1000); //Delay a se
 cond before testing again
}