====== PH - METER ======
2 scripts disponibles.
===== Script 1 =====
int ph_pin = A0; //This is the pin number connected to Po
void setup() {
Serial.begin(9600);
void loop() {
int measure = analogRead(ph_pin);
Serial.print("Measure: ");
Serial.print(measure);
double voltage = 5 / 1024.0 * measure; //classic digital to voltage conversion
Serial.print("\tVoltage: ");
Serial.print(voltage, 3);
// PH_step = (voltage@PH7 - voltage@PH4) / (PH7 - PH4)
// PH_probe = PH7 - ((voltage@PH7 - voltage@probe) / PH_step)
float Po = 7 + ((2.5 - voltage) / 0.18);
Serial.print("\tPH: ");
Serial.print(Po, 3);
Serial.println("");
delay(2000);
}
===== Script 2 =====
const int phPin = A0;
int sensorValue = 0;
unsigned long int avgValue;
float b;
int buf[10],temp;
void setup () {
Serial.begin(9600);
}
void loop () {
for (int i=0;i<10;i++) {
buf[i]=analogRead(phPin);
delay(10);
}
for (int i=0;i<9;i++) {
for (int j=i+1;j<10;j++) {
if (buf[i]>buf[j]) {
temp=buf[i];
buf[i]=buf[j];
buf[j]=temp;
}
}
}
avgValue=0;
for(int i=2;i<8;i++)
avgValue+=buf[i];
float phVol = (float)avgValue*5.0/1024/6;
float phValue = -5.70 * phVol + 21.34 ;
Serial.print("Sensor = ");
Serial.println(phValue);
delay(20);
}
===== Réglage généraux =====
Board description
BNC plug: Where you put the probe. It seems to work with any probe with a calibration difference. I tested 3 models (cheap blue, cheap black and a short black from a EC+pH kit).
Pin To: Should be the temperature but I can't make it works.
Pin Do: High/Low 3.3v adjustable limit.
Pin G/GND: Probe ground. It is useful when the ground is not the same as your Arduino. In some circumstances the ground voltage of the liquid to measure can be different.
Pin G/GND: Power ground (direct from Arduino).
Pin V+/VCC: Input power 5V DC (direct from Arduino).
Blue potentiometer close to BNC: pH offset.
Blue potentiometer close to pins: limit adjustment.
Black component with 103 printed (not the one between potentiometers): thermistor for temperature compensation.
"Calibration"
A single word for many things because in our case there are 2 different calibrations. The "offset" value and the "step" value.
The offset.
The offset is the shifting of all pH values to a specific voltage range. If a pH 7 output a voltage of 2.2v and pH 8 a voltage of 2.1v, then a shift of +0.3v move the pH 7 to 2.5v and the pH 8 to 2.4v. This can be done on the board or via software but it's probably easyer on the board because it's probe independant and there are less programming to do.
Connect GND (both) and Vcc to Arduino GND and 5v. Remove the probe and do a short circuit between the the small BNC hole and the external part of BNC. Put a voltmeter (or Arduino) to measure the voltage between GND and Po. Adjust the pot (close BNC) until the output is 2.5v. Now the pH 7 have an exact value of 2.5v (511 with analogRead function) because the probe will output 0 millivolt.
The steps.
Now you need one or more buffer solutions depending the range and precision you want. Ideally you should know the range of the measure you want to do with your system. I use water between pH 5 and pH 7, then I choose the buffer 4.01 (and 6.86 to verify my stuff). If you usually measure pH between 8 and 10 choose buffer 9.18 (eventually 6.86 also).
Connect the (clean) probe and put it in the buffer then let it stabilize for a minute. You know it's stable when it goes up and down (3.04 then 3.05 then 3.03 then 3.04) .Take note of the voltmeter (or Arduino) value, in my example it's 3.05v.
That's all, now you can use it with the code below.
===== Divers =====
{{:arduiro:1212.jpg?direct&400|}}
{{:arduiro:photo.jpg?direct&400|}}