Our prices are exclusive of taxes and shipping. 18% GST shall be added during check out. Happy Shopping! :)  

Robocraze Welcome to Robocraze

pH Sensor Kit

"All of us learnt using old-school acid-base indicators but accuracy is always better, and pH sensor comes to our rescue. It helps us measure pH."

pH Sensor Kit

“If it turns pink, it’s acid I think.” This, probably, has been the most common confusion during our Chemistry labs. Measuring acids and alkalis (bases) with litmus paper is something pretty much everyone learns how to do in school. It might be relatively easy to compare that little strip of wet paper with the colors on the pH scale and figure out how acidic or alkaline something is but sometimes that's too crude a measurement. If you keep tropical fish, for example, who lives in water of a certain acidity or alkalinity, getting things wrong with the litmus risks killing off your fragile pets. That's why many people invest in a pH sensor that can measure pH directly. Let's take a closer look!

Now, what does pH mean?

The pH of a substance is an indication of how many hydrogen ions it forms in a certain volume of water. There's no absolute agreement on what "pH" stands for, but most people define it as something like "power of hydrogen" or "potential of hydrogen." Mathematically, it is defined as


pH = -log(H+

pH Sensor Module

A typical pH sensor has two electrodes. The electrode that does the most important job, which is called the glass electrode, has a silver-based electrical wire suspended in a solution of potassium chloride, contained inside a thin bulb (or membrane) made from a special glass containing metal salts (typical compounds of sodium and calcium). The other electrode is called the reference electrode and has a potassium chloride wire suspended in a solution of potassium chloride.

For pH meters to be accurate, they must be properly calibrated (the meter is accurately translating pH measurements into voltage measurements), so they usually need testing and adjusting before you start to use them. You calibrate a pH meter by dipping it into standard buffer solutions (test solutions of known pH) and adjust the meter accordingly. It should always be dipped in a de-ionized water after each use, this keeps the measurements precise.

Pin connections of pH sensor:

Now, we are using a pH sensor circuit board with this. It needs 9 V DC supply. The probe gets connected to the circuit board and output pins are connected to an Analog pin of Arduino. As mentioned, we are using Arduino and programming the same. The code for the same is following:

#define SensorPin A0 //pH meter Analog output to Arduino Analog Input 0

#define Offset 0.00 //deviation compensate

#define LED 13

#define samplingInterval 20

#define printInterval 800

#define ArrayLenth 40 //times of collection


int pHArray[ArrayLenth]; //Store the average value of the sensor feedback

int pHArrayIndex=0;

void setup(void) {



Serial.println("pH meter experiment!"); //Test the serial monitor



void loop(void){

static unsigned long samplingTime = millis();

static unsigned long printTime = millis();

static float pHValue,voltage;

if(millis()-samplingTime > samplingInterval){



voltage = avergearray(pHArray, ArrayLenth)*5.0/1024;

pHValue = 3.5*voltage+Offset;



if(millis() - printTime > printInterval){ //Every 800 milliseconds, print a numerical, convert the state of the LED indicator



Serial.print(" pH value: ");






double avergearray(int* arr, int number){

int i;

int max,min;

double avg;

long amount=0;


Serial.println("Error number for the array to avraging!/n");

return 0;


if(number<5){ //less than 5, calculated directly statistics




avg = amount/number;

return avg;




min = arr[0];max=arr[1];







amount+=min; //arr<min



else {


amount+=max; //arr>max




amount+=arr[i]; //min<=arr<=max




avg = (double)amount/(number-2);


return avg;



The code, in the beginning, has a variable defined as ‘offset’. This is for us to set an offset as some pH sensors might give a value with some fixed deviation from the true value. This offset will be equal to that difference in value. This offset can also be rectified using the potentiometer.

Make sure the sensor is not left dry and kept horizontal while measuring. The pH sensor is fragile and sensitive to the external factors, be gentle with it and give it some time as it may take a few seconds before giving the correct value.

Write Your Comment

Only registered users can write comments. Please, log in or register