ph sensor Arduino, how do ph sensors work, application of ph meter, ph sensor calibration

(Last Updated On: October 19, 2019)

pH Sensor

Description:

In this Tutorial, you will learn how to use the pH sensor with Arduino and find the pH value of different liquids “Water, Milk and Cold rink”, and display the pH value on the serial monitor. As this is a getting started tutorial, so in this tutorial, we will only cover the extreme basics like for example

  1. How a pH sensor work
  2. Application of pH meter
  3. pH sensor Calibration
  4. pH sensor interfacing with Arduino
  5. Basic programming to find the pH value of different liquids and finally
  6. Testing


The components and tools used in this project can be purchased from DFrobot and Amazon, the components Purchase links are given below:

Gravity: Analog pH Sensor / Meter Kit For Arduino by DFrobot:https:
https://www.dfrobot.com/product-1025.html?tracking=5cfb9465c247d

Amazon links:

Arduino Uno: https://amzn.to/2tVz1vu
Gravity: Analog pH Sensor / Meter Kit For Arduino by DFrobot: https://amzn.to/2MEtRzy
Mega 2560: https://amzn.to/2ze1kdu
Voltage sensor 0-25v: best offer https://amzn.to/2PcMGXY
Nodemcu esp8266 wifi module: Best price https://amzn.to/2NAvmiB
lm7805 Voltage Regulator: https://amzn.to/2IZEl5x
330 ohm resistors pack: https://amzn.to/2NtlAeh
5v 2A adaptor: https://amzn.to/2GsNfcw
2n2222 npn transistors: https://amzn.to/2EmXsIb
10k Resistor: https://amzn.to/2KTd6OW
lm7805 Voltage Regulator: https://amzn.to/2IZEl5x
330-ohm resistors pack: https://amzn.to/2NtlAeh
female DC power jack socket: https://amzn.to/2KEo1gt
470 uf capacitors: https://amzn.to/2xDCOzf
5×7 cm vero board: https://amzn.to/2OHGbvn
female headers: https://amzn.to/2zqmtiJ
connection wires: https://amzn.to/2DpBuW7
Super Starter kit for Beginners: https://amzn.to/2KJvmKG
Jumper Wires: https://amzn.to/2KMoVXs
Bread Board: https://amzn.to/2MS4q8X
12v Adaptor: https://amzn.to/2Ntr6h1
PCB plate: https://amzn.to/2IUwpCt
Variable Supply: https://amzn.to/2MT4Qfj
Digital Multimeter: https://amzn.to/2Nvft9i
Vero Board / strip board: https://amzn.to/2MTf9jD
Soldering iron kit: “best” You guys should definitely purchase this: https://amzn.to/2zfoNuJ
Solder wire: https://amzn.to/2ufUMWf
Wire Stripper: https://amzn.to/2KOqxfU
wire cutter: https://amzn.to/2ucIq14
PCB small portable drill machine: https://amzn.to/2Nu62XF

DISCLAIMER:

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!


Let’s first start with the very basic questions

What is pH? And how a pH sensor actually works?

“pH stands for power of hydrogen, which is a measurement of the hydrogen ion concentration in the body. The total pH scale ranges from 1 to 14, with 7 considered to be neutral. A pH less than 7 is said to be acidic and solutions with a pH greater than 7 are basic or alkaline.”

pH Sensor

If you’re using litmus paper, and you are not interested in any automatic system, or any notification system then none of this matters. You can check manually the pH values of different liquids. The basic idea is that the paper turns a slightly different color in solutions between pH 1 and 14 and, by comparing your paper to a color chart, you can simply read off the acidity or alkalinity without worrying how many hydrogen ions there are.

pH Sensor

pH Sensor

But a pH meter somehow has to measure the concentration of hydrogen ions. How does it do it?

An acidic solution has far more positively charged hydrogen ions in it than an alkaline one, so it has greater potential to produce an electric current in a certain situation.

pH Sensor

in other words, it’s a bit like a battery that can produce a greater voltage. A pH meter takes advantage of this and works like a voltmeter: it measures the voltage (electrical potential) produced by the solution whose acidity we’re interested in, compares it with the voltage of a known solution, and uses the difference in voltage (the “potential difference”) between them to deduce the difference in pH….


About the DFrobot pH Sensor kit:

pH Sensor

This is the analog pH sensor kit from the DFrobot, DFrobot is a leading robotics and open source hardware provider. They create innovative, user-friendly hardware & software products that become the building blocks in all kinds of electronic projects. I personally recommend you should definitely visit www.dfrobot.com .

This pH Sensor kit can be used in Water quality monitoring equipment, it can be used in the water tanks, Fish aquarium, this pH Sensor kit can be used with GSM, nodemcu esp8266 wifi module for remote notifications.

pH Sensor

This pH sensor kit is best for measuring the water quality and other parameters. It has an LED which works as the Power Indicator, a pH sensor, a BNC connector, a variable resistor which is used for the calibration which I will explain during the testing and PH2.0 sensor interface circuit.

pH Sensor Kit Interfacing with Arduino:

For the step by step interface connections watch video Tutorial Click Here

Connect the red wire with the Arduino’s 5v…

Connect the black wire with the Arduino’s Ground…

Connect the blue wire with the Arduino’s Analog pin A0..

so that’s all about the interfacing, now let’s have a look at the pH sensor Arduino programming/code.


Programming:

Arduino pH sensor code / Programming:

This is a very simple and basic program to find the pH value of different liquids, I will be using some known liquids, whose pH values are already known. For the demonstration purposes, I will be using Water, Milk, and a cold drink. In upcoming tutorials, I will modify this program and display the pH Values on the LCD. I will also make an IOT version of the same project.

We use a for loop to get 10 sample values from the pH sensor and store these values in an array. Then we use these two for loops to sort the values from small to larger in the ascending order…

This for loop is used to take the average value of 6 center samples and the value is stored in avgValue. Then we convert this value into millivolts and into the pH value. Then finally we display the ph value on the serial monitor.

Practical Testing:

For the Practical Demonstration watch video given at the end or click Here”.
First of all, let’s find the pH value of the Water, the water under test is not pure water, so in this case, the ph value can be slightly greater than 7. After you are done with the program uploading,
connect Arduino with the laptop and open the Serial monitor.
The pH of pure water is 7. In general, water with a pH lower than 7 is considered acidic, and with a pH greater than 7 is considered basic. The normal range for pH in surface water systems is 6.5 to 8.5, and the pH range for groundwater systems is between 6 to 8.5. So the water under test is safe as you can see in the video and can be used for drinking without any problem….
Now let’s test the pH value of the Milk.
Fresh cows milk has a pH of between 6.7 and 6.5. Values higher than 6.7 denote mastitic milk and values below pH 6.5 denote the presence of bacterial deterioration. For more information click on the link below.
Link: https://www.quora.com/Is-milk-an-acid-or-a-base
Now, let’s check the pH value of Cold drink. Remove milk and clean this with water… If you search on Google you will find that the pH value for the cola drinks can be from 2 to 5. As you can see on the screen the pH value is between 2 and 5.
This pH sensor kit from the DFrobot is the most accurate pH sensor kit. We checked the pH values of three different liquids and got accurate values.

Arduino pH Sensor Calibration:

The calibration is really easy, all you need is select a liquid with the known pH values like for example the cow milk and check it’s value, if the value is greater or lower than the exact pH value which you can, of course, find in the chart, then all you need is to rotate this variable resistor which you can find near to the BNC connector clearly labeled in the picture above, and adjust the value.

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...

1 Comment

  1. Hi Engr,

    This is awesome stuff! Thank you so much for sharing. I’m currently looking at making a monitoring system from an Arduino that measures things like temperature and pH, but am interested in running two temperature and two pH meters, all simultaneously. I’m curious to know how the code would change if I’m wanting to add another pH meter? What kinds of changes would you make? I’d love to hear your thoughts!

Leave a Reply

Close