pH meter Arduino, pH Meter Calibration, DIYMORE pH Sensor Arduino Code

(Last Updated On: December 8, 2020)

pH meter Arduino

pH Meter Arduino, Description:

pH Meter Arduino– This is the analog pH sensor kit from the DIY MORE which is a bit different from the one developed by the DFrobot which I have already used in some of my previous projects explaining what is a pH sensor, it’s working, Calibration, and how to use a pH sensor to find the pH value of different liquids. I also used the DFrobot pH sensor kit for measuring the water quality using the Arduino board and I also used the pH sensor kit from the DFrobot in an IoT based water quality monitoring system using the NodeMCU ESP8266 WiFi module. So, if you want to learn how to use the pH sensor kit from the DFrobot then I highly recommend read my previous articles.

Before I am going to explain how to calibrate and use this pH Senor kit from the DIY MORE, first a few words about the sponsor of this article for sending me high quality PCBs.

About the Sponsor, ALLPCB:

pH meter Arduino

24-Hours Lead Time

ALLPCB is the World’s Fastest PCB Manufacturing Company. Feel free to visit their website to not only find out what awesome PCB and assembly services they offer but also to easily upload your Gerber files and thus order affordable and High-quality PCBs quickly. Besides this, you will also get a 30 Dollars Coupon balance, which you can use to get your first prototype order for free.

Xmas Surprise‘s Back

Random Secret Coupon for Any Order Over $500 Before 24th December 2020. $10, $20, $50 or $500 Coupon Immediate Use, for more information visit:

pH meter Arduino

In this tutorial, you will learn how to calibrate and use this low-cost pH sensor kit from DIY MORE. I started off by calibrating the pH sensor using the Arduino board, once the pH sensor perfectly calibrated, then I started by measuring the pH value of the distilled water and displayed the values on the serial monitor.

pH meter Arduino

I performed a series of tests using different liquids and once satisfied I further modified the code to display the pH value on the Oled display module. Again I started with the Distilled water and waited for around 30 minutes to check if there can be any fluctuations in the pH value. The pH value remained almost the same.

Next I added some lemon juice to the water and I was amazed with the result.

pH meter Arduino

As you know the pH value of the lemon juice is 2, and the value on the display as you can see is almost 2. Next, I cleaned the pH sensor probe to measure the pH value of the Malik. For the milk too I got the correct pH value.

pH meter Arduino

I also added lemon juice to the Milk to check if the value will drop. After adding the Lemon juice to the milk the value dropped. As this is a getting started tutorial; I will try to explain the maximum basic things.

In this tutorial we will cover,

  1. DIY MORE pH Sensor Kit Pinout and technical specifications
  2. pH Sensor Calibration
  3. Complete circuit diagram explanation
  4. pH Sensor Arduino Programming and finally
  5. Testing

Without any further delay let’s get started!!!

Amazon Purchase links:

Arduino Nano

Arduino Uno:

pH Sensor Kit DIYMORE

pH Sensor Kit DFrobot

128×64 SSD1306 Oled display Module

LM7805 Voltage Regulator:

DC Female Power Jack

Other Tools and Components:

Super Starter kit for Beginners

Two Channel / 200 MHz Digital Oscilloscope

Variable Supply:

Digital Multimeter:

Soldering iron kit: “best”

PCB small portable drill machine:

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

Analog pH sensor Pinout:

pH meter Arduino

This is the analog pH sensor kit from the DIY MORE which is a bit different from the one developed by the DFrobot. This pH Sensor Kit can measure pH values of different liquids with a good precision. The board contains a pair of trimmers through which you can adjust the Analog reading offset which I will explain while calibrating the pH Sensor. I will show you the easiest way to calibrate the pH sensor without using any liquid or substance and then later we will measure the pH value of some known liquids.  It has two LEDs which work as the Power Indicator, a pH sensor, a BNC connector. This board is also known as the sensor interface circuit.

This pH Sensor Kit has an on-board voltage regulator chip due to which it can be easily powered up using 3.3 to 5.5Vdc. Due to this wide range of input voltages it can be used with 5V and 3.3V compatible controller boards like Arduino, ESP32, and ESP8266 etc.

pH meter Arduino

The pH Sensor interface circuit is also provided with 6 male headers which are clearly labeled as V+, this is where we connect the 3.3V or 5V from the Arduino, in my case I will connect 5 volts, but if you are planning to use this pH sensor Kit with ESP8266 or ESP32 then you will need to connect this pin with 3.3Volts.

The next two pins are the ground pins, you can connect any of these two pins with the Ground pin of the Arduino.

Po is the Analog output pin, which should be connected with the analog pin of the Arduino.

Do is the 3.3V DC output pin.

The last pin is the To which is the temperature output.

Out of these 6 pins we will only use 3 pins; V+, G, and Po.

pH Sensor Calibration:

pH meter Arduino

To calibrate this sensor you will need a wire to short the external part and the center of the probe connector. This causes a 2.5 volts tension on the Po analog output pin. I started off by connecting the external part of the BNC connector with the center of the BNC probe connector.

pH meter Arduino

Now connect the V+ pin with the Arduino’s 5v. Connect the ground pin of the interface circuit with the ground pin of the Arduino, and finally connect the analog output pin Po with the A0 pin of the Arduino.

Connect Arduino with the laptop to calibrate the pH sensor using the following Arduino code.

pH Sensor Calibration Arduino Code:

This is a very basic program that we are going to use for calibrating the pH sensor interface circuit. The purpose of this program is to the read the analog output pin Po and display the voltage on the serial monitor. Make sure the Arduino board is selected and also check if the right communication port is selected. Click on the Upload button and wait for a while. After the program has been uploaded. Now the next step is to open the serial monitor.

pH meter Arduino

If you will see a value other than 2.50 then use the trimmer to adjust this value.You know the pH value is from 0 to 14. A pH of 7 means 2.5 Volts. So we are going to set it to 2.5 volts using the trimmer. Now, you can see the value is set to 2.5Volts. The pH Sensor is now calibrated.

Disconnect the Arduino board and also remove the wire. Now, it’s time to connect the pH sensor with the interface board.

pH meter Arduino

The small container already has the distilled water, this is how it look after connecting the pH sensor with the Interface board, the wiring remains the same. Now, let’s check its pH value.

Arduino pH meter testing after calibration:

pH meter Arduino

As you can see the Arduino is connected with the laptop, now we will need to upload the following code to find the pH value of the distilled water.

Download Libraries:

pH Meter Arduino Code:

After you upload the program, then you can open the Serial monitor to check the pH value of some known liquid. I used the distilled water. Although I did the calibration, but still the value was little off which I then adjusted. The above code is already adjusted. I have explained this in the video tutorial given at the end of this article.

pH meter Arduino

Very pure distilled water that has had little contact with air will have a pH value between 6.9 and 7. After adjusting the value, I was able to get the exact pH value for the distilled water. The pH value is between 6.9 and 7. The pH value can be further adjusted by changing the calibration value. We are done with the calibration and now it’s time to display the pH value on the Oled display module as it seems quite impractical to use the laptop or computer.

pH Sensor and Oled display with Arduino, Circuit Diagram:

pH meter Arduino

The 5V regulated power supply based on the LM7805 linear voltage regulator is used to power up the Arduino Nano. J1 is the female DC power jack and this is where we connect the input power supply. You can connect any voltage source between 7 and 25 Volts. Two 470uF capacitors are connected at the input and output sides of the voltage regulator. These are the decoupling capacitors. The output voltage should be connected with the VIN pin of the Arduino Nano.

The 128×64 SSD1306 i2c supported Oled display module is connected with the Arduino Nano which is used to display the pH value. The SCL and SDA pins are connected with the A5 and A4 pins, while the VCC and GND pins of the Oled display module are connected with the Arduino’s 5V and ground.

The V+ pin of the pH Sensor is connected with the 5V. The ground of the pH sensor is connected with the ground of the Arduino Nano. The analog output pin Po is connected with the Arduino’s analog pin A0.

Arduino Nano development board PCB designing:

pH meter Arduino

Next, I designed a PCB for the Arduino Nano, which I will use as the Development board. I added female headers for the 3.3V, 12V, 5V, and ground. The area on the right side can be used as the Vero Board for soldering other electronic components. I also added female headers on the left and right sides of the Arduino Nano for connecting the jumper wires.

pH meter Arduino

These are the PCBs I received from the ALLPCB Company. As you can see the quality is really great, the silkscreen is quite clear, and the Blue color solder mask looks amazing. Finally, I started off by placing the components and completed the soldering Job.

pH meter Arduino

This is how everything looks after soldering and interfacing. Again I started with the testing. If you remember I did all the testing with Arduino Uno, but this time I am using the Arduino Nano. This is why the value is little off, now you can again calibrate the sensor. I practically tested this if you do the calibration on the Arduino Nano and then use the pH sensor with the Arduino Uno the pH value can be little off. So make sure to calibrate the pH sensor whenever you switch between the different Arduino boards. Anyhow I calibrated the pH sensor one more time for the Arduino Nano and again I was able to get the exact pH values for different liquids. If you compare the pH sensor from the DIY MORE with the pH Sensor from the DFrobot you will find the pH sensor from the DIY MORE is cheap, but when it comes to the use and accuracy the pH sensor from the DFrobot is simply amazing. My recommendation is go for the DFrobot pH sensor.

pH meter Arduino code Explanation:

You will need the following libraries in order to print the pH values on the Oled display module.

#include <Wire.h>

#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>

#include <SimpleTimer.h>

SimpleTimer timer;

The following line of code is used to calibrate the value. My value was a little off that’s why I subtracted 0.7. If your value is different then you can adjust this value.

float calibration_value = 21.34 – 0.7; //21.34 – 0.7

Following are some variables.

int phval = 0;

unsigned long int avgval;

int buffer_arr[10],temp;

float ph_act;

// for the OLED display

#define SCREEN_WIDTH 128 // OLED display width, in pixels

#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)

#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)


void setup()




display.begin(SSD1306_SWITCHCAPVCC, 0x3C);



timer.setInterval(500L, display_pHValue);


void loop() {; // Initiates SimpleTimer

using the for loop we take samples, then arrange the values, and then finally take the average.

for(int i=0;i<10;i++)





for(int i=0;i<9;i++)


for(int j=i+1;j<10;j++)











for(int i=2;i<8;i++)


float volt=(float)avgval*5.0/1024/6;

ph_act = -5.70 * volt + calibration_value;

Serial.println(“pH Val: “);




display_pHValue() this is a user-defined function, it has no return type and doesn’t take any argument as the input. This function is controlled using the timer. The purpose of this function is to display the pH value on the Oled display module.

void display_pHValue()


// display on Oled display

// Oled display



display.setCursor(0,0); // column row



display.setCursor(55, 0);








display.setCursor(60, 30);


display.setCursor(95, 50);




For the step by step explanation watch video tutorial given below.

Watch Video Tutorial:


Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply