DIY IoT Water pH Meter using pH Sensor & ESP32
DIY IoT Based Water pH Meter using pH Sensor & ESP32 WiFi Module to measure liquid pH Calibration from 0 to 14 & monitor on Thingspeak Server
- Suitable forB.Tech/Diploma ESP32/IoT students
- Build time1-2 weeks
- LevelBeginner
- Available atAjvika Labs, Kakinada
About this project
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 Name
Quantity
Purchase Links
ESP32 WiFi Module
Amazon
AliExpress
Ph Sensor Kit
graylogix.in
9V DC Supply
Amazon
AliExpress
Connecting Wires
Amazon
AliExpress
Breadboard
Amazon
AliExpress
PH Sensor KIT for Water
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
Module Power: DC 9.00V 1A
Measuring Range: 0-14PH
Accuracy: ± 0.1pH (24 )
Response Time: 1min
Industry pH Electrode with BNC Connector
Power Indicator LED
Output: Analog values in the range of (0.5V to 3V)
Alkali Error: 0.2PH
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.
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.
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.
const
int
potPin
=
A0
;
float
ph
;
float
Value
=
;
void
setup
(
)
{
// put your setup code here, to run once:
Serial
begin
(
115200
)
;
pinMode
(
potPin
INPUT
)
;
delay
(
1000
)
;
}
void
loop
(
)
{
Value
=
analogRead
(
potPin
)
;
Serial
(
Value
)
;
Serial
(
" | "
)
;
float
voltage
=
Value*
(
3.3
/
4095.0
)
;
ph
=
(
3.3
*
voltage
)
;
Serial
println
(
ph
)
;
delay
(
)
;
}
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.
We also tested Ph of Milk which was around 5.
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.
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.
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.
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.
#include <WiFi.h>
const
int
potPin
=
A0
;
float
ph
;
float
Value
=
;
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"
;
// d
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 Name
Quantity
Purchase Links
ESP32 WiFi Module
Amazon
AliExpress
Ph Sensor Kit
graylogix.in
9V DC Supply
Amazon
AliExpress
Connecting Wires
Amazon
AliExpress
Breadboard
Amazon
AliExpress
PH Sensor KIT for Water
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
Module Power: DC 9.00V 1A
Measuring Range: 0-14PH
Accuracy: ± 0.1pH (24 )
Response Time: 1min
Industry pH Electrode with BNC Connector
Power Indicator LED
Output: Analog values in the range of (0.5V to 3V)
Alkali Error: 0.2PH
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.
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.
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.
const
int
potPin
=
A0
;
float
ph
;
float
Value
=
;
void
setup
(
)
{
// put your setup code here, to run once:
Serial
begin
(
115200
)
;
pinMode
(
potPin
INPUT
)
;
delay
(
1000
)
;
}
void
loop
(
)
{
Value
=
analogRead
(
potPin
)
;
Serial
(
Value
)
;
Serial
(
" | "
)
;
float
voltage
=
Value*
(
3.3
/
4095.0
)
;
ph
=
(
3.3
*
voltage
)
;
Serial
println
(
ph
)
;
delay
(
)
;
}
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.
We also tested Ph of Milk which was around 5.
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.
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.
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.
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.
#include <WiFi.h>
const
int
potPin
=
A0
;
float
ph
;
float
Value
=
;
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"
;
// d
Technologies used
Hardware components
- ESP32
- ESP8266
- Arduino
- OLED
Software & tools
- Arduino IDE
- ThingSpeak
What you get
- Working project / hardware kit, tested before delivery
- Complete source code with explanation
- Project demo and guidance for your viva
- Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed.
Payment is in two parts:
• 50% advance to start the project
• Remaining 50% before delivery
Note:
• Documentation and PPT are not included by default
• If you need documentation/PPT, it can be arranged for extra time and cost
We'll confirm the exact timeline and cost with you after reviewing your requirements.