ESP32 pH Sensor, IoT pH Sensor Code and Circuit diagram

(Last Updated On: September 8, 2021)

ESP32 pH Sensor, Description:

ESP32 pH Sensor

ESP32 pH Sensor– I have been using pH Sensor with Arduino and Nodemcu ESP8266 for measuring the pH value of different liquids. I also used it with the EC Sensor or TDS sensor for measuring the Water Quality and I also used it in the making of a low-cost Hydroponics system which was an Arduino based project. As explained in my previous tutorial which is based on the IoT Water level monitoring system using ToF10120 Laser Rangefinder or Distance senor, I am writing this series of articles to explain how to use each sensor individually before I make the complete IoT based Hydroponics system.

So, in this series of articles, my first article was based on the IoT Water level monitoring system using ESP32, ToF10120, and Blynk application. In this article, I explained each and every detail including interfacing, programming, and how to get rid of the fluctuations.

In today’s tutorial, which is the 2nd article in this series, I am going to explain how to make IoT pH Sensor using the pH sensor kit from the DiyMore, ESP32 WiFi + Bluetooth module, I2C supported Oled display module, and Blynk application. The pH sensor kit from the Diymore is a bit different from the one designed by DFrobot which I have also used in some of my previous tutorials 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 it in an IoT based water quality monitoring system using the NodeMCU ESP8266 WiFi module.

The Diymore pH sensor kit is cheap as compared to the DFrobot pH sensor kit. I have already explained how to calibrate and use this low-cost pH sensor kit with the Arduino to measure the pH value of different liquids, so I highly recommend first read my previous articles and then you can resume from here, because I will use the same code, but I will do some modifications to make it compatible with the ESP32 WiFi + Bluetooth Module. Anyways, after modifying the code and interfacing the pH Sensor and Oled Display module with the ESP32 Development board, finally I was ready to test the pH Value of different liquids including Water, Acidic solution, and washing powder. Before, I am going to share with you the test results, first, a few words about the sponsor of this project.



Altium Designer:

ESP32 pH Sensor

Altium Designer is the world’s most trusted PCB design system. Altium Designer enables engineers to effortlessly connect with every facet of the electronics design process. Over 35 years of innovation and development focused on a truly unified design environment makes it the most widely used PCB design solution. With Altium Designer you can create PCB designs with an intuitive and powerful interface that connects you to every aspect of the electronics design process. Route it your way through any angle, tune for delay, Push, Slide, and Walkaround faster than ever. Interact and collaborate with mechanical designers like never before in a photo-realistic, 3D design environment. If you want to get started with the Altium designer, you can click on the get started.

I have already calibrated my pH sensor kit the same way as I explained in my previous article. Initially I started with the water, I waited for a few minutes to let the pH Sensor stabilize.

ESP32 pH Sensor

The Water pH value which you can see on the Oled display module is simply amazing, you know The pH of most drinking-water lies within the range 6.5 and 8.5. Natural waters can be of lower pH. The water under test is from Well and the value fluctuates around 7, which means this water is drinkable. I am pretty satisfied with the result. The same value you can also see on the Blynk application. So, no matter where you are, if you have access to the internet, then you can monitor the pH value of any liquid from anywhere in the world. How easy it is to make an IoT pH sensor using just a few low-cost electronics components. Anyways next I am going to check the pH value of this Acidic solution.

ESP32 pH Sensor

This is amazing, the pH sensor is working just fine, a lower pH value means the solution is very acidic. Next, I am going to test the pH value of washing powder.

ESP32 pH Sensor

You know mostly the powder detergents pH value is close to 10, you may get a slightly lower value or a high value depending on the chemicals used. I shared the test results with you guys and now you have got the idea of what you are going to learn after reading this article. Without any further delay let’s get started!!!




 Amazon Links:

Arduino Nano

Arduino Uno:

ESP32 Wifi + Bluetooth Module:

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:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*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!



IoT pH Sensor Circuit Diagram:

ESP32 pH Sensor

On the top left side you can see a regulated 5v power supply which is used to supply 5 volts to the ESP32 Module. If you want to use an external power source then you will need this power supply and you will need to connect a wire from the output of 7805 regulator with the 5v pin of the ESP32 WiFi + Bluetooth Module. The main advantage of using this regulated 5v power supply is that, you can power up your ESP32 module using a 12v adaptor or a solar panel. But if you are performing basic experiments then you can use your Laptop or computer to power up the ESP32 Module.

The Oled display module power supply pins are connected with the 3.3V and GND pins while the SDA and SCL pins are connected with the GPIO pins 21 and 22.

The pH sensor kit V+ and GND pins are connected with the 3.3V and GND while the Po pin which is the analog output pin is connected with the GPIO pin 35.

ESP32 pH Sensor

This is the same ESP32 development board which I used with the TOF10120 Sensor, so I am going to use the same board with the pH sensor kit and Oled display module. You can see this board also has the relays, but for now I am not using these relays. If you want to make the same ESP32 Development board then you can read my article on the IoT Home Automation project.

ESP32 pH Sensor

Anyway, I connected the I2C supported Oled display module and the pH sensor kit with the ESP32 as per the circuit diagram which I just explained. So, my interfacing is completed and now let’s take a look at how to make the Blynk application.



Blynk Application making:

Blynk application isn’t difficult at all, just a few steps and you are done. For the step by step explanation watch video tutorial given at the end of this article. Before, you start the programming first of all, make sure you download all the necessary libraries.




IoT ESP32 pH Sensor Programming:



pH Meter Code Explanation:

This is the same exact code which I used in the getting started tutorial which was based on the Arduino board. But as this time I am using the ESP32 Board with the pH sensor Kit; So, I made a few changes, you can see in the code, I added libraries for the Blynk application, I also added the authentication token which was generated while making the Blynk application and I also added the WiFi credentials.

Another most important change is the voltage and the adc resolution and finally to send the value to the Blynk application I added this “ Blynk.virtualWrite(V2,ph_act);” line of code and you can see I am using the same V2 virtual pin and the final pH value. Everything else remains exactly the same. So, that’s all for now.

Don’t forget to like and subscribe to my YouTube channel, Electronic Clinic.



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

%d bloggers like this: