Close Menu
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
Facebook X (Twitter) Instagram
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us
Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
How To Electronics
  • Articles
    • Learn Electronics
    • Product Review
    • Tech Articles
  • Electronics Circuits
    • 555 Timer Projects
    • Op-Amp Circuits
    • Power Electronics
  • Microcontrollers
    • Arduino Projects
    • STM32 Projects
    • AMB82-Mini IoT AI Camera
    • BLE Projects
  • IoT Projects
    • ESP8266 Projects
    • ESP32 Projects
    • ESP32 MicroPython
    • ESP32-CAM Projects
    • LoRa/LoRaWAN Projects
  • Raspberry Pi
    • Raspberry Pi Projects
    • Raspberry Pi Pico Projects
    • Raspberry Pi Pico W Projects
  • Electronics Calculator
How To Electronics
Home » DIY IoT Water pH Meter using pH Sensor & ESP32
ESP32 Projects IoT Projects

DIY IoT Water pH Meter using pH Sensor & ESP32

Mamtaz AlamBy Mamtaz AlamUpdated:August 20, 20221 Comment7 Mins Read
Share Facebook Twitter LinkedIn Telegram Reddit WhatsApp
IoT pH Sensor ESP32
Share
Facebook Twitter LinkedIn Pinterest Email Reddit Telegram WhatsApp

Overview

In this tutorial, we will design our own DIY IoT Based Water pH Meter using pH Sensor & ESP32 WiFi Module. In some earlier tutorial, we interfaced pH Sensor with Arduino to make a portable ph Meter. The pH reading data was displayed on OLED Screen.

This is a completely different tutorial as we will be using a better and advanced pH Sensor. The pH Sensor used here is an analog type pH Sensor that gives a linear pH reading in 0pH to 14pH range. Instead of displaying the data on an OLED screen, we will send the data to ThingSpeak Server. The ThingSpeak provides instant visualizations of data posted by our device, i.e. ESP32. Since ESP32 is a 12-bit controller with built-in ADC, so it can measure data more precisely compared to Arduino which has a 10-bit ADC.

It incorporates a high-resolution pH probe that samples liquid pH at user-defined intervals and transmits the result to remote servers. The pH probe comes with a 5 long cable and can be dipped in any solution. The response time is lesser than a minute. We can incorporate this IoT Based pH Meter in Aquariums, Hydroponics, laboratories, etc. So let us learn how we can interface pH Sensor with ESP32 & make our own pH meter. The tutorial also covers the pH Sensor Calibration method.


Bill of Materials

Following are the materials required for making the IoT Based pH Meter. You can purchase all the components online using the following links.

S.N.Components NameQuantityPurchase Links
1ESP32 WiFi Module1Amazon | AliExpress
2Ph Sensor Kit1graylogix.in
49V DC Supply1Amazon | AliExpress
5Connecting Wires10Amazon | AliExpress
6Breadboard1Amazon | AliExpress




PH Sensor KIT for Water

pH Sensor Kit

This Analog pH Meter Kit with the industrial real-time electrode is specially designed for Arduino, ESP8266, ESP32 & other Microcontrollers. It uses an industry electrode and has a built-in simple, convenient & practical connection. It has a long life (up to 1 year), which makes it very suitable for long-term online monitoring.

The signal connector board has an LED that works as the Power Indicator. The board also has a BNC-type connector and a PH sensor interface. To use it, just connect the pH sensor with a BNC connector, then plug the PH interface into the analog input port of any microcontroller. If programmed, you will get the pH value easily. You can also use a multimeter to measure the output voltage.

This industrial pH electrode is made of a sensitive glass membrane with low impedance. It can be used in a variety of PH measurements with fast response and excellent thermal stability. It has good reproducibility, is difficult to hydrolysis, and can eliminate basic alkali error.

In 0pH to 14pH range, the output voltage is linear. The reference system which consists of the Ag/AgCl gel electrolyte salt bridge has a stable half-cell potential and excellent anti-pollution performance. The ring PTFE membrane is not easy to be clogged, so the electrode is suitable for long-term online detection.


PH Sensor Specifications

  1. Module Power: DC 9.00V 1A
  2. Measuring Range: 0-14PH
  3. Accuracy: ± 0.1pH (24 )
  4. Response Time: 1min
  5. Industry pH Electrode with BNC Connector
  6. Power Indicator LED
  7. Output: Analog values in the range of (0.5V to 3V)
  8. Alkali Error: 0.2PH
  9. Internal Resistance: 250MO



Calibration Instruction

This instrument is calibrated for the PH sensor provided along with this Kit. And may not give accurate results if the PH sensor probe is changed. Hence calibration is required if the PH sensor Probe is changed. The results are directly proportional to the temperature of the solution.

The sensor can be calibrated at values: PH4 = 1.5V, PH7 = 2.0V & PH9 = 2.5V. To use this sensor, lace the PH Sensor probe vertically and keep it for a long time before using it. It will give excellent results if the sensor probe is used multiple times in the period of 2 to 3 days.

Rinse the sensor prove tube in deionized water and dab it with the tissue paper before immersing it in the test solution. Will take approximately 30 to 40 seconds to stabilize the results. Once the reading is noted down and before placing the probe in the storage solution, again rinse the probe tip in the deionized water, dab it with the dry tissue paper and then place the storage cap.


Precautions

PH sensor probe Tube tip is very sensitive and should not be touched with hands and should not be placed on the ground. The bulb type tip is very fragile and should be kept in the storage solution if not used.


Interfacing & Testing PH Sensor with ESP32

Before proceeding for IoT pH Meter, let us do a basic interfacing and testing of pH sensor with ESP32 WiFi Module. This is a simple connection diagram.

Interfacing & Testing PH Sensor with ESP32

To power the pH Sensor use an external 9V battery or a 9V DC Supply. Connect the output pin of the pH Sensor signal board to VP of ESP32 which can be used as an A0 pin. The output of the sensor ranges between 0.5V to 3V so the sensor can be used with analog pins of ESP32.

IoT Based pH Meter


Basic Test Code

The pH sensor is an analog sensor. So we will be converting the analog output voltage into a pH value. Here is a simple ESP32 & pH Sensor Code.

Copy the code and paste it on the editor of Arduino IDE. Select the ESP32 from Board Manager and also select the COM port. Now you can upload the code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const int potPin=A0;
float ph;
float Value=0;
 
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  pinMode(potPin,INPUT);
  delay(1000);
}
void loop(){
 
    Value= analogRead(potPin);
    Serial.print(Value);
    Serial.print(" | ");
    float voltage=Value*(3.3/4095.0);
    ph=(3.3*voltage);
    Serial.println(ph);
    delay(500);
}

After uploading the code, open the Serial Monitor, the sensor values must be visible.

We have tested the lemon juice whose Ph came around 2.8 ~ 3.0

We also tested a basic detergent solution the Ph for this was greater than 8.

IoT Based pH Meter

We also tested Ph of Milk which was around 5.

pH Meter ESP32

There is no need for calibration of the sensor if you haven’t changed the probe which was already provided with the Ph sensor Kit.
Otherwise, you can do that by tuning the 5k resistor on the Ph module as highlighted in the image below.

Ph Sensor Calibration



IoT Based Water pH Meter using pH Sensor & ESP32

Now let us write another code to build an IoT Based pH Meter. Using this code we can monitor the pH value from any part of the world. We will be using the Thingspeak server for online monitoring of the pH data.

ThingSpeak provides very good tool for IoT based projects. By using the ThingSpeak site, we can monitor our data and control our system over the Internet, using the Channels and web pages provided by ThingSpeak. So first you need to sign up for ThingSpeak. So visit https://thingspeak.com and create an account.

Thingspeak Setup

Then create a new channel and set up a widget for pH Value.

Then create the API keys. This key is required for programming modifications and setting your data.


Source Code/Program

The following is the code for IoT Based pH Meter using pH Sensor & ESP32.

1
2
3
String apiKey = "*************";
const char *ssid = "*************";
const char *password = "*************";

You need to update the API key by pasting the API Key copied previously from Thingspeak Dashboard. Also update the Wi-Fi credentials, Wi-Fi name in SSID, and its password in password variable.

Now copy the following code and upload it to the ESP32 Board.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <WiFi.h>
const int potPin=A0;
float ph;
float Value=0;
 
String apiKey = "*************"; // Enter your Write API key from ThingSpeak
const char *ssid = "*************"; // replace with your wifi ssid and wpa2 key
const char *password = "*************";
const char* server = "api.thingspeak.com";// don't change this
 
WiFiClient client;
 
void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  pinMode(potPin,INPUT);
  delay(1000);
 
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(2000);
    Serial.print(".");
  }
  // Print local IP address and start web server
  Serial.println("");
  Serial.println("WiFi connected.");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
  
}
 
void loop() {
  // put your main code here, to run repeatedly:
Value= analogRead(potPin);
Serial.print(Value);
Serial.print(" | ");
float voltage=Value*(3.3/4095.0);
ph=(3.3*voltage);
Serial.println(ph);
delay(500);
 
if (client.connect(server, 80)) // "184.106.153.149" or api.thingspeak.com
   {
      String postStr = apiKey;
      postStr += "&field1=";
      postStr += String(ph);
      postStr += "\r\n";
    
      client.print("POST /update HTTP/1.1\n");
      client.print("Host: api.thingspeak.com\n");
      client.print("Connection: close\n");
      client.print("X-THINGSPEAKAPIKEY: " + apiKey + "\n");
      client.print("Content-Type: application/x-www-form-urlencoded\n");
      client.print("Content-Length: ");
      client.print(postStr.length());
      client.print("\n\n");
      client.print(postStr);
    }    
}



Once the code is uploaded, the ESP32 will try connecting to the WiFi Network. Every 15 seconds the data will be uploaded to the Thinkspeak server.

We can view the uploaded values in the private view section on the Thinkspeak dashboard as in the image.

IoT Based pH Meter Thingspeak


Video Tutorial & Guide

DIY IoT Water pH Meter using pH Sensor & ESP32
Watch this video on YouTube.

Incase if you are not satisfied with the Analog Ph Sensor, then you can use Atlas Scientific Ph Sensor which has better accuracy & result due to I2C & UART interface.

Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Reddit Telegram WhatsApp
Previous ArticleCreate Bluetooth Low Energy Project using Arduino & BleuIO
Next Article Aquarium Water Quality Monitor with TDS Sensor & ESP32

Related Posts

ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

Updated:June 16, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

Updated:June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

Updated:May 10, 20262K
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

Updated:May 2, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

Updated:April 27, 20261K
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

Updated:April 27, 20262K
View 1 Comment

1 Comment

  1. Murali Krishnah on November 11, 2022 4:20 AM

    How to reduced that 15 seconds count at the end? Where should I change the code to obtain the sensed values much sooner?

    Reply

CommentsCancel reply

Latest Posts
ESP32 Fingerprint Attendance System with Live Web Dashboard

ESP32 Fingerprint Attendance System with Live Web Dashboard

June 16, 2026
IoT Based PM & Air Quality Monitoring System using ESP32

IoT Based PM & Air Quality Monitoring System using ESP32

June 14, 2026
DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

DIY ESP32 MLX90640 IR Thermal Camera with Live Web Display

May 10, 2026
IoT Activity Tracker with ESP32 & Accelerometer Gyroscope

IoT Activity Tracker with ESP32 & Accelerometer/Gyroscope

May 2, 2026
A Guide to Sourcing Obsolete ICs for Vintage Projects

Beyond AliExpress: A Guide to Sourcing Obsolete ICs for Vintage Projects

April 21, 2026

ESP32 IoT Vehicle Motion Analyzer with MPU6050 & LIS3MDL

April 27, 2026
Building a Smart Sensor Node with a BLE Microcontroller

Building a Smart Sensor Node with a BLE Microcontroller

February 26, 2026
High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

High-Accuracy Pitch, Roll, Yaw with ESP32 & BNO08x IMU

April 27, 2026
Top Posts & Pages
  • ESP32 Fingerprint Attendance System with Live Web Dashboard
    ESP32 Fingerprint Attendance System with Live Web Dashboard
  • IoT Based PM & Air Quality Monitoring System using ESP32
    IoT Based PM & Air Quality Monitoring System using ESP32
  • Buck Converter: Basics, Working, Design & Application
    Buck Converter: Basics, Working, Design & Application
  • 12V DC to 220V AC Inverter Circuit & PCB
    12V DC to 220V AC Inverter Circuit & PCB
  • ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
    ESP32 CAN Bus Tutorial | Interfacing MCP2515 CAN Module with ESP32
  • IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
    IoT AC Energy Meter with PZEM-004T & ESP32 WebServer
  • Designing of MPPT Solar Charge Controller using Arduino
    Designing of MPPT Solar Charge Controller using Arduino
  • How to use Modbus RTU with ESP32 to read Sensor Data
    How to use Modbus RTU with ESP32 to read Sensor Data
Categories
  • Arduino Projects (197)
  • Articles (60)
    • Learn Electronics (19)
    • Product Review (15)
    • Tech Articles (28)
  • Electronics Circuits (46)
    • 555 Timer Projects (21)
    • Op-Amp Circuits (7)
    • Power Electronics (13)
  • IoT Projects (205)
    • ESP32 MicroPython (7)
    • ESP32 Projects (82)
    • ESP32-CAM Projects (15)
    • ESP8266 Projects (76)
    • LoRa/LoRaWAN Projects (22)
  • Microcontrollers (38)
    • AMB82-Mini IoT AI Camera (4)
    • BLE Projects (18)
    • STM32 Projects (19)
  • Raspberry Pi (93)
    • Raspberry Pi Pico Projects (57)
    • Raspberry Pi Pico W Projects (12)
    • Raspberry Pi Projects (24)
Follow Us
  • Facebook
  • Twitter
  • Pinterest
  • Instagram
  • YouTube
About Us

“‘How to Electronics’ is a vibrant community for electronics enthusiasts and professionals. We deliver latest insights in areas such as Embedded Systems, Power Electronics, AI, IoT, and Robotics. Our goal is to stimulate innovation and provide practical solutions for students, organizations, and industries. Join us to transform learning into a joyful journey of discovery and innovation.

Copyright © How To Electronics. All rights reserved.
  • About Us
  • Disclaimer
  • Privacy Policy
  • Contact Us
  • Advertise With Us

Type above and press Enter to search. Press Esc to cancel.

Ad Blocker Enabled!
Ad Blocker Enabled!
Looks like you're using an ad blocker. Please allow ads on our site. We rely on advertising to help fund our site.