I managed to cobble this sketch together with some much appreciated help with 'if'. I soon realized that getting Arduino to recognize a pH probe and display the value on an LCD was way over my head, not to mention calibrating the probe with Arduino.
So, I wondered if it might be doable to feed the Arduino from my Pinpoint pH monitor.
I pulled the circuit out of the Pinpoint pH monitor and checked all the LCD connections with my DMM, hoping to find one that displayed the same thing as what's on the LCD. But I thought that maybe I'm missing something...
Anyway, I wondered if I could get an opinion as to whether something like this might be feasible.
[int pHpin = A7;
float pHvalue = 0;
unsigned long hoursInMs(int h)
{
return h*3600000UL; //values will be expressed in hours
}
long minutesInMs(int m){
return m*60000L; //values will be expressed in minutes
}
long secondsInMs(int s){
return s*1000L; //values will be expressed in seconds
}
void setup()
{
pinMode(A7, INPUT); // pin A7 connected to pH probe
pinMode(7, OUTPUT); // pin 7 controls mixing pump
pinMode(8, OUTPUT); // pin 8 controls kalk slurry
pinMode(9, OUTPUT); // pin 9 controls washing soda
pinMode(10, OUTPUT); // pin 10 controls calcium chloride
}
void loop()
{
int reading = analogRead(pHpin); // read pH sensor
pHvalue = 8.3; // convert to pH value
if( pHvalue < 8.3 ) // if pH is 8.3 or higher, kalk slurry will not be added and mixing pump will not turn on
{
digitalWrite(8, LOW); // turn kalk slurry dosing pump off
digitalWrite(9, LOW); // turn washing soda dosing pump off
digitalWrite(10, LOW); // turn calcium chloride dosing pump off
digitalWrite(7, HIGH); // turn mixing pump on using a NO relay
delay(secondsInMs(3)); // let mixing pump run for 20 seconds, or long enough to create kalk slurry
digitalWrite(7, LOW); // turn mixing pump off
delay(secondsInMs(3)); // leave mixing pump off for 30 seconds to allow any solid chunks to fall to the bottom of container
digitalWrite(8, HIGH); // turn kalk slurry dosing pump on using a second NO relay
delay(secondsInMs(3)); // let kalk slurry dosing pump run only briefly to prevent a precipitation event
digitalWrite(8, LOW); // turn kalk slurry dosing pump off
delay(secondsInMs(3)); // leave kalk slurry dosing pump off briefly to allow slurry to dissipate
digitalWrite(8, HIGH); // same as above, this just spreads out the kalk slurry.
delay(secondsInMs(3));
digitalWrite(8, LOW);
delay(secondsInMs(3));
digitalWrite(8, HIGH); // same as above.
delay(secondsInMs(3));
digitalWrite(8, LOW);
delay(secondsInMs(3));
digitalWrite(8, HIGH); // almost same as above.
delay(secondsInMs(3));
digitalWrite(8, LOW);
delay(secondsInMs(3)); // in 5 minutes, the dosing series continues
}
digitalWrite(7, LOW); // turn mixing pump off
digitalWrite(8, LOW); // turn kalk slurry dosing pump off
digitalWrite(10, LOW); // turn calcium chloride dosing pump off
digitalWrite(9, HIGH); // turn washing soda dosing pump on using a third NO relay
delay(secondsInMs(3)); // dose washing soda for 5 seconds
digitalWrite(9, LOW); // turn washing soda dosing pump off
delay(secondsInMs(3)); // wait 5 minutes before next dose
digitalWrite(7, LOW); // turn mixing pump off
digitalWrite(8, LOW); // turn kalk slurry dosing pump off
digitalWrite(9, LOW); // turn washing soda dosing pump off
digitalWrite(10, HIGH); // turn calcium chloride dosing pump on using a fourth NO relay
delay(secondsInMs(3)); // dose calcium chloride for 5 seconds
digitalWrite(10, LOW); // turn calcium chloride dosing pump off
delay(hoursInMs(6)); // wait 6 hours before starting at the top with a new dosing series.
}
/code]