PH-4502C Sensor DIYMORE: How To Use and Calibrate using Arduino UNO R3
Description
Water is a necessity for every living thing. The importance of knowing the quality of water so that our lives are healthier is something that should be done. One way to find out whether drinking water is fit for drinking is to measure its physical parameters, namely ph. pH itself is the level of acidity of a solution or water, where a good pH value for drinking water according to WHO is 6.5–8.5.
Lately, I made a college project, which is to make a pH sensor that used to measure the amount of pH in a solution. This project aims to produce finished goods in the form of sensors that can be applied in real life. Enjoy!
Board Description and Specification
First and foremost, if we want to build something, we must know how it will works. I used pH sensor 4502C from DIYMORE. This pH Sensor had specification as followed:
· Heating voltage: 5±0.2V (AC -• DC)
· Working current: 5–10mA
· The detection concentration range: PH 0–14
· The detection range of temperature: 0–60 centigrade
· The response time: ≤ 5S
· Stability time: ≤ 60S
· Power consumption: ≤ 0.5W
· The working temperature: -10~50 centigrade (the nominal temperature 20 centigrade)
· Working humidity: 95%RH (nominal humidity 65%RH)
· Service life: 3 years
· Size: 42mm x 32mm x 20mm
· Weight: 25g
· The output: Analog voltage signal output
What you must underline is detection concentration range (it will used, soon!). This PH sensor has an Analog value output. This value will later be converted to digital during the calibration process. The PH Sensor board has several pins as shown in the picture.
Here’s board description:
- BNC Connector: Pin to place where we put the probe. I used standard probe contain when I buy this Sensor.
- To: Temperature pin, we actually don’t use this, but if you want to actually measure the temperature of water, I think you should do further calibration process, but now we just skip this part.
- Do: High/Low 3.3 pin, this pin for adjustable limit from the board.
- Po: PH pin, this pin is for pH value input.
- GND: Ground pin
- GND: Ground pin, actually this two GND have similar function as ground. But, this pin is connected directly to Arduino.
- VCC: Power Input pin, use 5V DC in Arduino.
- Blue Potentiometer close to BNC: PH offset value Pin.
- Blue Potentiometer close to pins: Limit adjustment pin.
Flowchart and Wiring Diagram
To know how the sensor works, we must know what logical thinking behind it. Here’s flowchart to demonstrate how actually sensor works by logical thinking process:
Description of what inside the flowchart is as followed:
First we start the sensor then after that the probe inside the water will measure difference potential between +VCC and Ground when the probe inside the water we try to measure. After that, we know the value of voltage that the water we try to measure have. However, the voltage value we measure still analogue value, so we need to convert the value to the digital by using ADC equation (see on calibration).
Thereafter, we convert the value of voltage to the pH value, by using equation above. If you want to know what’s the point of equation above, you should check calibration part. From now on just understand that after we get the voltage, we convert it so we have pH value then display it in Serial Monitor or LCD (if you have one).
For the diagram above, we just need three jumper cable. One for the +VCC, GND, and Analog Input Pin A0. The GND we use is actually the same for both GND (either analog GND or supply GND), so it comes to just one GND at a time in Wiring Diagram.
Calibration
This part is divided by two parts, first is hard calibration by adjusting potentiometer in the BNC connector. Second is soft calibration with analytical pH for knowing pH step.
Hard Calibration
First, connect all wiring needed to the Arduino Board (use both GND). Remove sensing probe from the connector, and do short circuit between the small BNC hole and the external part of BNC (some part like bolt) using wire. Put voltmeter (or read using Serial Monitor in Arduino IDE) to measure the voltage between GND and Po. In my case, I use Arduino IDE to measure voltage by connecting input on Pin A0 and using code below:
void setup() {
Serial.begin(9600); //Begin the Serial Monitor
}
void loop() {
float measure = analogRead(A0); //Read pin A0
double voltage = measure*5/1024; //Analog-to-Digital Conversion
Serial.println(voltage); //Print voltage value to Serial Monitor
}
Afterwards, make sure to have 2.5V value on the Serial Monitor by adjusting potentiometer (close to BNC).
If you ask, “why must 2.5V?” , the answer is because the detection concentration range is 0–14 and the Arduino Voltage (or range of measured voltage) is around 0–5V. Which means, median value for concentration range is 7 and voltage is 2.5. So, 2.5V means the exact value of pH7 and if you had exact value of PH 7 mean the probe will outputs 0 millivolt.
Soft Calibration
After Hard Calibration, we moved into Soft Calibration. The purpose of this part of calibration is to knowing what is the value of pH step. pH step is some kind of value which explains the relationship between pH and voltage.
Now, we need one or more buffer solutions depending the range and precision we want. For my case, water (between PH 5 — PH7), buffer (PH 6.81), and buffer (PH 4.01). Connect the probe and put in the buffer then let it stabilize for a minute. If the value in Arduino IDE have same value, indicating that the sensor is stable, then take a note for the voltage value. Here’s example of my data while calibrating:
After we get the data, we do a linearity test to find out the limits of the range that our pH sensor can measure. We used Regression Linear to know what is the value of R². Here’s the result:
Based on the graph above, it can be concluded that the R² value obtained is quite good (close to 1), but this value can only be used in the pH range < 7. To determine the pH step value for pH values above 7, a buffer solution with an amount higher. For now, the sensor I’m calibrating has an effective measurement range of 0–7 pH.
Implementation
After the calibration process is over, now is the time of implementation. Before starting, we need the value of the pH step, the value of the pH step can be calculated using simple mathematical calculations, with the following equation:
We take the difference between two known voltage, in my example 2.3 for pH 6.8 and 3.05 for pH 4.00 which is -0.74V. This voltage is equivalent of the pH range from 4–6.8, which is 2.8 pH units. The division of voltage by pH units gives volt/pH. This volt/pH value is known as pH step. My pH step is 0.1841.
Afterwards, we can enter the pH step value that we get into the probe value, so that the value read in the Serial Monitor is the adjustment value between the voltage read in the solution and its comparison with the pH step.
After that, we just enter into the code as follows:
void setup() {
Serial.begin(9600); //Begin Serial Monitor
}
void loop() {
float measure = analogRead(A0); //Read pin A0
double voltage = measure*5/1024; //Analog-to-Digital Conversion
// PH_step (Voltage/pH Unit) = (Voltage@PH7-Voltage@PH4)/(PH7 - PH4)
float pH = 7+((2.5 - voltage)/0.1841); // PH_probe = PH7-((Voltage@PH7-Voltage@probe)/PH_step)
Serial.print("PH: "); //Print word pH in Serial Monitor
Serial.println(pH); //Print pH value in Serial Monitor
delay(1000); //Gives delay 1 second
}
Thus, an article on how to calibrate the pH-4502C sensor. There are still many deficiencies in calibration that can be improved, such as increasing the measurement range of the sensor by using a buffer solution with a pH value greater than 7.
For source code and wiring diagrams in the form of Fritzing, you can access them via my GitHub link here. Thank you!