Skip to content

Calibrating a pH Sensor

In this article, we will discuss the ph sensor and how to calibrate one of them. These ph sensors are available in many variants in the market. What we sell is a very interesting Analog ph sensor. Our analog pH sensors are specially designed for Arduino micro-controllers, that are easy to use ie. plug-and-play solution to measure the pH value of a solution without any additional circuit required.

What is a pH Scale??

The pH scale is used to measure the acidity and basicity of a liquid. It can have readings ranging from 1-14 where 1 shows the most acidic liquid and 14 shows the most basic liquid. 7 pH is for neutral substances that are neither acidic nor basic.  Now, pH plays a very important role in our lives and it is used in various applications. For example, it can be used in a swimming pool to check the quality of water.

What is pH Value ??

The unit that we use to measure the acidity of a substance is called pH. The term “H” is defined as the negative log of the hydrogen ion concentration. The range of pH can have values from 0 to 14. A pH value of 7 is neutral, as pure water has a pH value of exactly 7. Values lower than 7 are acidic and values greater than 7 are basic or alkaline.

How Does Analog pH Sensor Work??

An Analog pH sensor is designed to measure the pH value of a solution and show the acidity or alkalinity of the substance. It is commonly used in various applications such as agriculture, wastewater treatment, industries, environmental monitoring, etc. The module has an on-board voltage regulator chip that supports the wide voltage supply of 3.3 – 5.5V DC, which is compatible with 5V and 3.3V of any control board like Arduino. The output signal is being filtered by a hardware filter.


The construction of a pH sensor is shown below. The pH Sensor looks like a rod usually made of a glass material having a tip called “Glass membrane”. This membrane is filled with a buffer solution of known pH (typically pH = 7). This electrode design ensures an environment with the constant binding of H+ ions on the inside of the glass membrane.

When the probe is dipped into the solution to be tested, hydrogen ions in the test solution start exchanging with other positively charged ions on the glass membrane, which creates an electrochemical potential across the membrane which is fed to the electronic amplifier module which measures the potential between both electrodes and converts it to pH units. The difference between these potentials determines the pH value based on the Nernst equation.

Calibrating the pH Sensor

As we can see that there are two potentiometers in the above pic. Which is closer to the BNC connector of the probe is the offset regulation, the other is the pH limit.

Offset: The average range of the probe oscillates between negative and positive values. The 0 represents a pH of 7.0. In order to be able to use it with Arduino, this circuit adds an offset value to the value measured by the probe, so the ADC will only have to take samples of positive voltage values.

PH Limit: This potentiometer is to sets a limit value of the pH sensor circuit that causes the red LED to light up and the Do pin signal to turn ON.

Connect Po to Analog input A0 on Arduino, and G to Arduino GND. Run the given Arduino sketch below, and open the Serial Monitor of Arduino IDE to observe the reading, slowly adjust the potentiometer RV1 (the one near the BNC connector on the board) until the Po reading is equal to 2.50v.

#include <Arduino.h>
const int adcPin = A0;
 
void setup() 
{
    Serial.begin(115200);
}
 
void loop() 
{
   int adcValue = analogRead(adcPin);
   float phVoltage = (float)adcValue * 5.0 / 1024;
   Serial.print("ADC = "); 
   Serial.print(adcValue);
   Serial.print("  Po  = "); 
   Serial.println(phVoltage, 3);
   delay(1000);
}

This is assuming that all the pH probes are equal and will produce exactly 0v at a pH reading of 7.0, but in reality, all probes are slightly different from each other, especially for consumer-grade pH probes.

Temperature also affects the reading of the pH sensor slightly, so the better way is to use a pH buffer solution of pH=7.0 to calibrate the probe. All the buffer solutions will have the temperature compensation information on their package that you could factor in for your calibration.

Note

1.“pH buffer packages for calibration purpose available in liquid form or in powders form, the liquid pack is easy to use but powders pack is good for storage. These solutions are sold in different values but the most common are pH 4.01, pH 6.86, and pH 9.18.”

2. To avoid cross-contamination, dip the probe in distilled water for a couple of minutes before dipping it in different buffer solutions. To increase the accuracy, let the probe stay in the buffer solution for a couple of minutes before taking the reading as the result.

Use the same Arduino sketch to get the voltage reading for pH=4.01, and write down the voltage value, in my case, the voltage is 3.06 @ pH=4.01. The voltage readings at a ph of 4.01 Vph4 and at pH of 7.0 Vph7 allows us to draw a straight line, and we can get the Voltage change per pH value m as:

m = (ph7 – ph4) / (Vph7 – Vph4) /

m = (7 – 4.01) / (2.5 – 3.05)

m = -5.436

So the pH value at any voltage reading at Po can be derived with this formula:

pH = pH7 – (Vph7 – Po) * m

i.e. pH = 7 – (2.5 – Po) * m

Measuring pH value:

#include <Arduino.h>
const int adcPin = A0;
  
// calculate your own m using ph_calibrate.ino
// When using the buffer solution of pH4 for calibration, m can be derived as:
 // m = (pH7 - pH4) / (Vph7 - Vph4)
const float m = -5.436; 

void setup()
{
   Serial.begin(115200);
}

void loop() 
{
   float Po = analogRead(adcPin) * 5.0 / 1024;
   float phValue = 7 - (2.5 - Po) * m;
   Serial.print("p h value = "); 
   Serial.println(phValue);
   delay(5000);
}

Leave a Reply

Your email address will not be published. Required fields are marked *

Exit mobile version