ph sensor arduino with lcd display free sample

pH scale is used to measure the acidity and basicity of a liquid. It can have readings ranging from 1-14 where 1 shows the most acidic liquid and 14 shows the most basic liquid. 7 pH is for neutral substances that are neither acidic nor basic. Now, pH plays a very important role in our lives and it is used in various applications. For example, it can be used in a swimming pool to check the quality of water. Similarly, pH measurement is used in a wide variety of applications like agriculture, wastewater treatment, industries, environmental monitoring, etc.

In this project, we are going to make an Arduino pH Meter and learn how to measure the pH of a liquid solution using a gravity pH sensor and Arduino. A 16x2 LCD is used to show the pH value on the screen. We will also learn how to calibrate the pH sensor to determine the accuracy of the sensor. So let’s get started!

The unit that we use to measure the acidity of a substance is called pH. The term “H” is defined as the negative log of the hydrogen ion concentration. The range of pH can have values from 0 to 14. A pH value of 7 is neutral, as pure water has a pH value of exactly 7. Values lower than 7 are acidic and values greater than 7 are basic or alkaline.

Analog pH sensor is designed to measure the pH value of a solution and show the acidity or alkalinity of the substance. It is commonly used in various applications such as agriculture, wastewater treatment, industries, environmental monitoring, etc. The module has an on-board voltage regulator chip which supports the wide voltage supply of 3.3-5.5V DC, which is compatible with 5V and 3.3V of any control board like Arduino. The output signal is being filtered by hardware low jitter.

The construction of a pH sensor is shown above. The pH Sensor looks like a rod usually made of a glass material having a tip called “Glass membrane”. This membrane is filled with a buffer solution of known pH (typically pH = 7). This electrode design ensures an environment with the constant binding of H+ ions on the inside of the glass membrane. When the probe is dipped into the solution to be tested, hydrogen ions in the test solution start exchanging with other positively charged ions on the glass membrane, which creates an electrochemical potential across the membrane which is fed to the electronic amplifier module which measures the potential between both electrodes and converts it to pH units. The difference between these potentials determines the pH value based on the Nernst equation.

The Nernst equation gives a relation between the cell potential of an electrochemical cell, temperature, reaction quotient and the standard cell potential. In non-standard conditions, the Nernst equation is used to calculate cell potentials in an electrochemical cell. The Nernst equation can also be used to calculate the total electromotive force (EMF) for a full electrochemical cell. This equation is used to calculate the PH value of a solution as well. The glass electrode response is governed by the Nernst Equation can be given as:

After successful hardware connections, now it’s time for programming the Arduino. The complete code for this pH meter with Arduino is given at the bottom part of this tutorial. The stepwise explanation of the project is given below.

The first thing to do in the program is to include all the required libraries. Here in my case, I have included “LiquidCrystal_I2C.h” library for using the I2C interface of an LCD display and “Wire.h” for using I2C functionality on Arduino.

Next, the calibration value is defined, which can be modified as required to get an accurate pH value of solutions. (This is explained later in the article)

Finally, calculate the average of a 6 centre sample Analog values. Then this average value is converted into actual pH value and printed on an LCD display.

Calibration of the PH electrode is very important in this project. For this, we need to have a solution whose value is known to us. This can be taken as the reference solution for the calibration of the sensor.

Suppose, we have a solution whose PH value is 7 (distilled water). Now when the electrode is dipped in the reference solution and the PH value displayed on LCD is 6.5. Then to calibrate it, just add 7-6.5=0.5 in the calibration variable “calibration_value” in the code. i.e. make the value 21.34 + 0.5=21.84. After making these changes, again upload the code to Arduino and recheck the pH by dipping electrode in the reference solution. Now LCD should show the correct pH value i.e. 7(Little variations are considerable).Similarly, adjust this variable to calibrate the sensor. Then check for all other solutions to get the exact output.

ph sensor arduino with lcd display free sample

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. I have also used the same Diymore pH Sensor with the ESP32 and built an IoT pH Meter.  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 Sensor kit from the DIY MORE, first a few words about the sponsor of this article for sending me high-quality PCBs.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

ph sensor arduino with lcd display free sample

In chemistry, pH is a scale used to specify how acidic or basic a water-based solution is. Acidic solutions have a lower pH, while basic solutions have a higher pH. Thus Ph sensor has the ability to determine the Ph of any solution, i.e it tells whether the substance is acidic, basic or neutral in nature. By knowing the Ph, we can monitor the water quality in Agricultural Farm and also in Fish Farming. Similarly, Ph Sensor has a wide range of applications like wastewater treatment, pharmaceuticals, chemicals & petrochemicals.

In this basic tutorial, we will learn how to interface Gravity Ph Sensor with Arduino. We will design a simple Ph Meter and display the Ph value on OLED/LCD Display. We will also learn about the construction & working of the Ph Sensor. Finally, we will learn the calibration method which will determine the correctness and accuracy of the sensor. The Ph Sensor can also be interfaced with other higher-level microcontrollers like NodeMCU ESP8266 & STM32 which I will discuss in future.

The term PH is a quantitative measure of the acidity or basicity of aqueous or other liquid solutions. The term, widely used in chemistry, biology, and agronomy, translates the values of the concentration of the hydrogen ion which ordinarily ranges between about 1 and 10−14 gram-equivalents per liter—into numbers between 0 and 14.

In pure water, which is neutral (neither acidic nor alkaline), the concentration of the hydrogen ion is 10−7 gram-equivalents per liter, which corresponds to a pH of 7. A solution with a pH less than 7 is considered acidic; a solution with a pH greater than 7 is considered basic, or alkaline.

A pH meter is a scientific instrument that measures the hydrogen-ion activity in water-based solutions, indicating its acidity or alkalinity expressed as pH. The pH meter measures the difference in electrical potential between a pH electrode and a reference electrode, and so the pH meter is sometimes referred to as a “potentiometric pH meter“. The difference in electrical potential relates to the acidity or pH of the solution.

The Ph Sensor has a rod-like structure usually made of glass, with a bulb containing the sensor at the bottom. The glass electrode for measuring the pH has a glass bulb specifically designed to be selective to hydrogen-ion concentration. On immersion in the solution to be tested, hydrogen ions in the test solution exchange for other positively charged ions on the glass bulb, creating an electrochemical potential across the bulb. The electronic amplifier detects the difference in electrical potential between the two electrodes generated in the measurement and converts the potential difference to pH units. The magnitude of the electrochemical potential across the glass bulb is linearly related to the pH according to the Nernst equation.

The reference electrode is insensitive to the pH of the solution, being composed of a metallic conductor, which connects to the display. This conductor is immersed in an electrolyte solution, typically potassium chloride, which comes into contact with the test solution through a porous ceramic membrane. The display consists of a voltmeter, which displays voltage in units of pH.

DFRobot Gravity: Analog pH meter V2 is specifically designed to measure the pH of the solution and reflect the acidity or alkalinity. As an upgraded version of pH meter V1, the sensor greatly improves the precision and user experience. The onboard voltage regulator chip supports the wide voltage supply of 3.3~5.5V. The output signal filtered by hardware has low jitter. With this Ph Sensor, you can quickly build the pH meter to measure the Ph value of the different aqueous solutions.

The Ph Sensor Kit has Signal Conversion Board (Transmitter) V2 and also pH Probe. Both of them are connected with each other. The features of both of these parts are as follows.

Ph Sensor has 3 pins that need to be connected to Arduino. So, connect the VCC pin to 5V of Arduino and GND to GND. Connect its analog pin to A0 of Arduino as shown in image above.

Once the code is uploaded to Arduino Board, you can open serial monitor and start testing the Ph Sensor. I tested the Ph Sensor with All 4 solutions given above and found the following results

Now Let us display the Ph Value on OLED Display instead of Serial Monitor. To do that we need to add a 0.96″ I2C OLED Display to Arduino Uno. Hence the connection diagram is shown below.

The connection is fairly simple again. Connect the Analog pin of Ph Sensor to Arduino A0 pin and supply 5V to it. Also, connect the SDA SCL pin of OLED Display to Arduino A4 & A5 Pin respectively.

The source code for Interfacing DFRobot Gravity Ph Sensor with Arduino and OLED Display is given below. Simply copy the code and upload it to the Arduino Board.

Once the code is uploaded the OLED display will start showing the value of Ph. Dipping the Ph electrode on different solutions will give different value as shown in the images below.

If you worked with PH metering before you will know that PH values range from 0-14. Where PH 0 is very acidic, PH 7 will be neutral and PH 14 very alkaline. The biggest problem while using the Ph Sensor is about the calibration. Since the Ph sensor is an analog sensor so there is a need for calibration as the output is dependent upon the voltage. So we need a solution whose Ph Strength is known to us. There are various buffer solutions available in the market whose PH is fixed.

The simplest method to calibrate the Ph sensor is to dip the ph electrode on the solution of known strength and observe the reading. For example, when the electrode is dipped in a solution whose Ph Value is 7, the reading should show 7. In case it doesn’t show the correct reading, you need to rotate the potentiometer placed on Signal Conversion Board (Transmitter) V2. Once the reading matches, you can stop rotating and hence the sensor is calibrated.

Note: In my case I used Milkfor calibrating the sensor as I didn’t have any buffer solutions. The ph of milk is between 6.5 to 6.7. So you can also use Milk for calibration.

The sensitive glass bubble in the head of the pH probe should avoid touching with the hard material. Any damage or scratches will cause the electrode to fail.

After completing the measurement, disconnect the pH probe from the signal conversion board. The pH probe should not be connected to the signal conversion board without the power supply for a long time.

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.

ph sensor arduino with lcd display free sample

• Arduino Uno houses ATmega328 microcontroller from ATMEL. This microcontroller contains flash memory (32 KB), RAM (2 KB), 8 bit wide CPU and 1 KB EEPROM.

ph sensor arduino with lcd display free sample

Note: If you plan on using an external power supply for the Arduino, connect it to the Arduino before doing the calibration. This will ensure that the reference levels are appropriately set, which will aid in the correct calibration.

The sensor used in this project has an accuracy of +/- 0.2%. The pH meter will operate within this accuracy in the temperature range of 7 - 46°C. Outside of this range, the meter will have to be modified for temp compensation. Note: The pH probe can be subjected to a range of 1 − 60 °C.

ph sensor arduino with lcd display free sample

This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.

ph sensor arduino with lcd display free sample

This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.

ph sensor arduino with lcd display free sample

Welcome to ProteShea – in this project, we’re going to show you how to interface a pH sensor with the Arduino Uno (rev 3). The purpose of the pH sensor is to determine if a solution is neutral, acidic, or alkaline. This sensor can be used to gauge water quality with a whole suite of sensors including ORP (oxidation/reduction potential), DO (dissolved oxygen), etc. The basics of how the pH sensor works (minus the details involved for describing the chemistry taking place) and how to create a circuit model of the sensor will be discussed.

pH (ranges from 0 to 14) is a logarithmic measure of hydrogen ion (H+) concentration (range is from 1 and 10^-14 moles per liter) in a solution1. For example, a solution of 10^-9 H+ would equate to a pH of 9. Furthermore, a pH of 7 is considered neutral, a pH of < 7 is acidic, and a pH of > 7 is alkaline, as shown in Fig. 2.

The pH sensor contains two electrodes to generate a voltage, which is shown in Fig. 3, with the positive and negative terminals being the signal and reference electrodes, respectively. Since we need the reference electrode to be at 0 volts, we use the power/ground isolation feature of Captis so our ground doesn’t pick up noise from other sensors or canisters that are included in a canister stack.

When the sensor is immersed in a liquid you’re trying to measure, a voltage potential is built up around the glass bulb shown in Fig. 4. The material of the glass bulb allows an ion exchange to occur with the hydrogen ions in the measured solution. To have a complete circuit, a high-impedance path is created between the two electrodes, denoted as “Rs” in the image below. Knowing that the two electrodes generate an output voltage and we have a series resistance Rs, we can now create a circuit model of the pH sensor. This is shown in Fig. 3.

Since we’ve shown that the pH sensor has a very high-impedance and produces a very small output voltage, we’ll need a circuit with a high input impedance so that we don’t distort the significantly small voltage output of the sensor. We can use the high-impedance properties of a non-inverting operational amplifier (op-amp) so we don’t load down the sensor. The non-inverting op-amp configuration is shown in Fig. 5.

The backside of Captis conveniently contains a graphic of a non-inverting op-amp for quick reference! Essentially, the potential difference is being measured between the glass membrane and the reference electrode. We can further develop our circuit, as shown in Fig. 6.

Next, we’ll need to communicate with Captis via SPI (serial peripheral interface) to read the voltage measurements from the pH sensor. The 8-bit ADC does not require any specific registers to be read from like we saw in Project 19. We simply initiate a SPI transfer by generating clock pulses on SCLK, and data is received on MISO. According to page 18 of the ADC datasheet found here, we’ll need to initiate two SPI transfers to receive all 16 bits of data.

Most analog signals are centered around 0V meaning that they have positive and negative voltages. These analog signals can be very small in amplitude, and measurement can be a challenge with a low-resolution ADC. However, lower resolution usually means lower component cost.

In order for the ADC to sample the voltage from the pH sensor, the voltage range of the sensor needs to be within the operating range of the ADC (i.e. 0V to 5V). By characterizing the pH sensor to obtain its maximum (corresponds to pH of 14) and minimum (corresponds to pH of 0) voltage measurements, a circuit can then be designed to fit those data points within the ADC range.

[Stage 1] The front-end analog circuitry on Captis contains a non-inverting, high-precision operational amplifier (op-amp) with low noise to capture the small signal generated by the pH sensor. [Stage 2] This is followed by an inverting, high-bandwidth op-amp to drive the analog-to-digital converter (ADC). An inverting op-amp works perfectly for offsetting the analog signal so that the entire waveform is shifted above 0V. Why didn’t we choose two high-precision op-amps for Stage 1 and 2? One of the reasons is that high-bandwidth op-amps are usually cheaper than high-precision op-amps.

Twin Insight: whenusing an 8-bit ADC with a 5V supply, we can achieve a resolution of (2^8)/(5V) = 51.2 mV. The signal in the figure below could be sampled as a DC signal instead of an AC signal. If we’re able to amplify the 20mV signal to around 3.5V peak-to-peak, we may be able to recover the waveform depending on the sampling frequency. Lower-level details will be covered in a future topic.

One of the benefits of Captis is that it can be used to seamlessly interface to a Raspberry Pi since it does not have an on-board ADC. However, this section only describes connecting to an Arduino.

Wire wrapping from J16 to J3 header can be configured differently depending on if the I/O is utilized by other canisters in your stack. Be sure to reference the Captis User Manual if you need help with the pinouts. Since we’re only using Captis with Modulus, we wire wrapped Captis with the configuration shown in Fig. 10. The pin numbering can also be seen in Table 1.

Now that we’ve simulated the circuit, we can go ahead and configure our hardware. Usually, it’s best practice to design, simulate, and then build the circuit. This helps to avoid some of those debugging headaches. For “STAGE 1” located on the left side of Captis, jumper J7 is configured as non-inverting, jumper J15 is connected to GND, and jumper J10 is left unconnected. For “STAGE 2” located on the right side of Captis, jumper J9 is configured as inverting, jumper J8 is connected to -5V0, and jumper J11 is fused to GND. The configuration is shown in Fig. 11 with the jumper locations highlighted in blue.

We’re using 12” M/M jumper wires to connect Captis’ 4×26 pin header to the Arduino. The wiring schematic is shown in Fig. 12, and Table 2 lists the pin numbering. Arduino doesn’t support the SPI interface on all of its GPIO pins so be conscious of this if you need to change your wiring.

If you are using Modulus and Captis, carefully mate the two Canisters together. Ensure that the male pins of Captis align with the female header of Modulus. Then, insert your Canister stack into the FuelCan’s 4×26-pin connector, as shown in Fig. 13.

In this section, we’re going to describe how to calibrate the pH sensor. The sensor and electronics need slight adjustments to get accurate readings and we do this by measuring against a known source such as the calibration solution with a known pH of 10 on the LCD. You should notice that if you submerge the sensor in this calibration solution, you won’t measure a pH of 10. Since it’s a linear sensor and the voltage conversion to pH is provided by DFRobot, we don’t need to create our own calibration plot.

Using the potentiometers in Fig. 14, you’re able to adjust the pH measurement until you read a value of 10. Once you read the correct pH, you’ve calibrated your sensor! You can use the “Stage 2 Gain Adj.” for a course tuning and “Stage 1 Gain Adj.” for more fine tuning.

If you haven’t mounted the Uno onto the prototyping area of the FuelCan, go ahead and do that. If you are using a breadboard instead of Modulus, place the breadboard in the bottom storage compartment to limit the length of the jumper wires. You’ll need to supply +5V and GND to the power and ground rails on the breadboard by using the provided banana jack to test-lead clip cables. You will need two male header pins to mount the test-lead clips on the breadboard side. Plug the Type A side of the USB cable into USB1 receptacle and the Type B side into the Uno’s receptacle to power and program the board. Power up the FuelCan with the AC-DC power adapter.

We are leveraging code written by DFRobot (found here) to store the received data samples and convert the voltage to a meaningful value (in this case pH!). We will be displaying the data on a 16×2 character LCD, so we must include the LiquidCrystal.h library. The SPI.h library is needed to communicate with the ADC and the math.h library is needed for a few number-rounding functions.

In the void loop() function, we’ll check to see if the system time is greater than the sampling interval of 20 milliseconds. If greater, the readADC() function is called so that a data sample can be acquired. Additionally, the code checks if the system time is greater than the print interval. If this is true, the average pH is written to the LCD and the Arduino LED is toggled. Further explanation of writing to the LCD can be found in Project 9.

We communicate with Captis via SPI (serial peripheral interface) to read the voltage measurements from the pH sensor. The 8-bit ADC does not require any specific registers to be read from like we saw in Project 19. We simply initiate a SPI transfer which will generate clock pulses on SCLK, and data is received on MISO. According to page 18 of the ADC datasheet found here, we’ll need to initiate two SPI transfers to receive all 16 bits of data, shift, and then concatenate the two bytes received.

A 40-element array is used to store the ADC samples which helps with the accuracy of the pH measurement and minimizes the effect of data outliers. A sample is stored every 20 milliseconds and the average is computed every 800 milliseconds. A larger data buffer can increase accuracy further, but this will increase computation time, so it becomes a trade-off.

ph sensor arduino with lcd display free sample

pH meters are scientific instruments used for measuring the activity and concentration of hydrogen-ions in water-based solutions, with the aim of indicating its acidity or alkalinity expressed as pH values. They find application in water & wastewater treatment, pharmaceuticals, chemicals & petrochemicals, food & beverages, mining, and agricultural processes to mention a few. For today’s tutorial, we will attempt to build an accurate, DIY version of this very useful tool.

pH meters comprises of majorly a probe and a processing unit which interprets the data from the probe and displays in a human readable format. pHmeter essentially measures the difference in electrical potential between a pH electrode and a reference electrode. As a result of this, pH meters are sometimes referred to as a “potentiometric pH meters”.

While there are several DIY pHmeter examples on the internet, today’s project will be based on the examples provided by Atlas Scientific. We will use the Atlas Scientific pH probe and their Gravity analog pH meter breakout board. The Gravity analog pH meter breakout board is a fairly accurate low-cost pH metering solution specifically designed for Students / education, Proof of concept developments and pH metering applications requiring moderate accuracy levels. It comes with a BNC port through which it can be connected to the Atlas Scientific pH probe.

Asides the pH breakout and the probe, we will use an Arduino Uno and a 20×4 LCD display. The Arduino will serve as the brain for the project obtaining the pH level from the probe while the LCD will serve the purpose of providing visual feedback to the users as the value obtained by the Arduino will be displayed on the LCD.

To reduce the workload associated with searching for the exact components used for this tutorial, I have included links through which each of the components can be bought.

The schematics for today’s project is quite straightforward. We will connect the LCD using the 4-pin mode, while we willconnect the signal pin from the PH sensor to an analog pin on the Arduino since it’s output is analog.

With the connections ready, to make the project neat and presentable an enclosure was created. The enclosure is based on the popular abs plastic enclosures and it was modified with drills and other tools so it accommodates the screen and fits perfectly for other projects. A picture of the completed enclosure is displayed in the image below.

Use this pilot hole as the start point for the 3.2mm (1/8″) drywall cutting bit. Since this a small job, we will use the bit on the hand drill rather than a drywall cutting machine. Work on the inside of the rectangle instead of the lines as it may be a bit difficult to cut in a straight manner with this bit on the drill.

Put the piece in the vice and cut the openings. The circular opening is made using drill bits. The rectangular ones are made by following a similar process used to make the opening for the LCD.

The code for today’s project is quite straightforward. Our tasks as mentioned during the introduction is to collect the pH level using the pH meter and display on the attached LCD.

We will use the Arduino IDE for the development of the code and will use 2 major libraries; the Liquid Crystal Display library and the Atlas gravity sensor library. The liquid crystal display library is used to reduce the amount of work/code that is required to get the Arduino to interact with the LCD, while the Atlas Gravity Sensor Library makes it easy to interface with the PH meter and obtain data. The Liquid Crystal Library usually comes with the Arduino IDE but just in case it didn’t, you can always install it via the Arduino Library manager. The Atlas Gravity Sensor library, on the other hand, needs to be installed manually, as such, you will need to download it from the attached link, unzip it and copy it’s content into the Arduino Library folder. The library folder is usually in the same folder as your Arduino Sketches.

Next, we declare some of the variables that will be used during the code, declare the analog pin of the Arduino to which the PH sensor analog output pin is connected, and create instances of both the Atlas Gravity Sensor Library and the Liquid Crystal Library.

LiquidCrystal pH_lcd(2, 3, 4, 5, 6, 7); //make a variable pH_lcd and assign arduino digital pins to lcd pins (2 -> RS, 3 -> E, 4 to 7 -> D4 to D7)

With those done, we proceed to to the void setup() function. We start the function by initializing serial communication which will is used for debug purposes, and the LCD display on which a splash/initialization screen is displayed.

Next, the PH level is obtained from the PHmeter using the ph.read_ph() function. The values obtained is then displayed on the serial monitor and on the LCD.

Other parts of the code are the serialEvent() function which is used to obtain user input from the Serial Monitor, and the parse_cmd() function which takes in the data from the serial port and uses it to set the calibration level of the PHmeter.

LiquidCrystal pH_lcd(2, 3, 4, 5, 6, 7); //make a variable pH_lcd and assign arduino digital pins to lcd pins (2 -> RS, 3 -> E, 4 to 7 -> D4 to D7)

To ensure the accuracy of the results from the pH meter, there is a need to accurately calibrate the device. pH meters are calibrated across 3 levels; 4, 7, and 10 using standard buffer solutions that already exists at that PH level. These standard solutions are sometimes provided by the sellers of the PH sensor but when not provided, you can always get them from your local chemical stores.

To calibrate the meter, upload the sketch we developed above to your Arduino. Take some time to ensure the components are properly connected before doing this. When sketch upload is complete, open the serial monitor, based on our code the serial monitor will prompt you to enter the calibration values, with samples showing how to enter them correctly. When at this stage, follow the steps below to calibrate the meter with the three buffer solutions.

With these done, the pH meter is now calibrated and should be able to give the correct pH level for any solution the probe is tested with. The calibration values are saved on the Arduino’s EEPROM so they are not lost when the meter is disconnected from power. This makes calibration not necessary before every use but you should re-caliberate the system again after some time, so you can always enter the cal,clearcommand on the serial monitor to clear the previous stored calibration values and repeat the steps explained above.

With the code uploaded and calibration done, you can now go ahead and dip the probe into any solution you desire and you should see the pH value displayed on the LCD like shown in the image below.

The accuracy of the pHmeter varies with temperature, as such, it is important to note that the sensor used in this project has an accuracy of +/- 0.2% and that the pH meter will operate at this accuracy level when the temperature range is between 7 – 46°C. Outside of this range, the meter will have to be modified to compensate.

Going forward, while the scope of this project is limited to pH value, you can choose to add several other sensors to make the project more useful. A good example of sensors that could be added for more value include temperature and humidity sensors.

ph sensor arduino with lcd display free sample

This website is using a security service to protect itself from online attacks. The action you just performed triggered the security solution. There are several actions that could trigger this block including submitting a certain word or phrase, a SQL command or malformed data.

ph sensor arduino with lcd display free sample

using the datasheet and some tracing with a multimeter I determined that there are 2 full digits used and a half a digit which is the 1, and of course the dot, because I don"t care about the dot.

ph sensor arduino with lcd display free sample

Need to measure water quality and other parameters but haven"t got any low cost pH meter? Find it difficult to use with Arduino? Here comes an analog pH meter, specially designed for Arduino controllers and has built-in simple, convenient and practical connection and features. It has an LED which works as the Power Indicator, a BNC connector and PH2.0 sensor interface. To use it, just connect the pH sensor with BNC connector, and plug the PH2.0 interface into the analog input port of any Arduino controller. If pre-programmed, you will get the pH value easily. Comes in compact plastic box with foams for better mobile storage.

Attention:In order to ensure the accuracy of the pH probe, you need to use the standard solution to calibrate it regularly.Generally, the period is about half a year. If you meaure the dirty aqueous solution, you need to increase the frequency of calibration.

Before the electrode in continuous use every time,you need to calibrate it by the standard solution,in order to obtain more accurate results.The best environment temperature is about 25 ℃,and the pH value is known and reliable,close to the measured value. If you measure the acidic sample, the pH value of the standard solution should be 4.00.If you measure the alkaline sample, the pH value of the standard solution should be 9.18.Subsection calibration, just in order to get a better accuracy.

(1)Connect equipments according to the graphic,that is,the pH electrode is connected to the BNC connector on the pH meter board,and then use the connection lines,the pH meter board is connected to the ananlong port 0 of the Arduino controller. When the Arduino controller gets power,you will see the blue LED on board is on.

(3)Put the pH electrode into the standard solution whose pH value is 7.00,or directly shorted the input of the BNC connector.Open the serial monitor of the Arduino IDE,you can see the pH value printed on it,and the error does not exceed 0.3. Record the pH value printed,then compared with 7.00, and the difference should be changed into the "Offset" in the sample code. For example,the pH value printed is 6.88,so the difference is 0.12.You should change the "# define Offset 0.00" into "# define Offset 0.12" in your program.

(4)Put the pH electrode into the pH standard solution whose value is 4.00.Then wait about one minute,adjust the gain potential device, let the value stabilise at around 4.00.At this time,the acidic calibration has been completed and you can measure the pH value of an acidic solution.

(5) According to the linear characteristics of pH electrode itself, after the above calibration,you can directly measure the pH value of the alkaline solution, but if you want to get better accuracy, you can recalibrate it. Alkaline calibration use the standard solution whose pH value is 9.18.Also adjust the gain potential device, let the value stabilise at around 9.18. After this calibration, you can measure the pH value of the alkaline solution.

The electrode used for the first or long set without re-use, the electrode bulb and the sand core, immersed in the 3NKCL solution activated eight hours.

ph sensor arduino with lcd display free sample

We all know PH is an essential thing for drinking water. If you don’t take care of this crucial ingredient, you might ruin your entire meal in a matter of seconds. This article will teach you how to build an Arduino Ph sensor as a beginner project for someone who doesn’t know what they’re doing.

We can regard an Arduino as a ‘microcontroller.’ This means that it is a tiny computer that you can use for electronic projects (and for much more). It can act as the main component in a huge amount of projects. By combining multiple projects, you can make something even greater.

Before you get started, make sure you set up the Arduino kit by following the instructions that came with it. This takes approximately 1 hour and 30 minutes to do. However, if you’re in a hurry, it’s possible to do this in 20 minutes by following this tutorial.

Every solution has a pH that a simple electrode can measure. For example, lemon juice has a pH of 2-3, and vinegar has a pH range from 4-6. Clean water may have a pH between 6.5 and 8, depending on the area you live.

A probe is an electronic device that allows you to measure the amount of voltage or current flowing through a circuit. For example, we will be using a Ph probe when measuring PH. This sensor lets us know if the water contains acids or bases.

The PH probe has two wires: one red and one black. The blue wire connects to 5V, and the black wire connects to the Ground(GND). The Red wire is what you use to measure the PH. It’s a very sensitive probe that can measure the pH value. You connect it to the Arduino, and in a concise period, it will tell you if the solution has an acidic or basic value.

There are many different models of Ph Sensor for Arduino. Unfortunately, many of them appear similar. But, if you want to do a good job and make sure your sensor will last for a long time, you should go with one from Rayming PCB & Assembly and get this one.

You can connect the sensor to the Arduino board using two wires. Once the connection is complete, you can start testing the sensor. You should do this by using a small piece of bread. The amount of sugar in bread is close to human skin, so it is easy to see how the sensor will react.

One can adjust the Ph probe to any other values as well. You need to tell it which value you want, and it will give it back to you (the value). You can do this by using a simple piece of bread.

Testing the sensor after connecting it to the Arduino is essential before using other solutions. You should always let the sensor rest for around 24 hours to stabilize and work properly. You will have to do this again when you connect it to a new circuit later.

The Ph probe requires between 3.5V and 5V to read the solution’s pH value properly. Therefore, to monitor the pH level of your Arduino project, you will need to use a voltage regulator or a voltage divider.

This project will use two transistors and two resistors to get the proper readings from different circuits or sensors. For example, if you want to measure the temperature on your Arduino board, you can get that information with a thermistor. However, the readings for both temperatures and pH depend on the circuit’s current level and, therefore, on the value used in your soil ph sensor Arduino.

Before you start building your sensor, make sure to read these instructions carefully. Your project will not be waterproof. Ensure that you place the device on a flat, safe surface.

Other than that, almost everything is as simple as a ‘Plug and Play’ installation. If anything fails to work correctly, try restarting the Arduino IDE. If it still doesn’t work, check all the connections again to ensure there aren’t any loose wires touching other components or parts of the circuit.

You can choose to make the Arduino board a stand-alone device so that you don’t need an enclosure. But, we think it’s better to use an enclosure because it gives you a safer way to store your sensor or Arduino board in the future. But, of course, you could also use the box that comes with your Arduino kit.

Place your finished product on top of another piece of acrylic sheet or plexiglass that is slightly larger than your enclosure. Then, cut it to the same size as a saw. Once you finish both pieces, drill two holes for the mobile phone camera and one for the micro SD card slot.

Don’t worry if you mess up while making these holes. You can always take your enclosure apart and fix all these problems. Do this by using a drill bit that is slightly smaller than your cord and then cut all of these holes with a rotary tool, or you can use a saw if you want to make smoother cuts.

1) First, we will install the 220-ohm resistor from the LCD module side so that you can use an external power source. You also want to connect this to your Arduino board’s positive (red) side.

4) You will also have to add an extra ground wire between the transistors and the breadboard since they don’t share a common ground with the Arduino board. Finally, connect the transistor and resistor to GND on the Arduino board.

The Ph probe should be installed like the picture above to connect the wires to your Arduino board. The GND wire should be connected to one of the Arduino’s pins and should go in between both transistors to be grounded.

Finally, you can install the LCD module using two wires. You need to connect one pin to the Arduino board and the other to the transistor that shares a ground with the Arduino. You can use a breadboard for this if you want, but it is much easier just by connecting both circuits directly.

Just connect the parts that are highlighted in green using jumper wires. You can bend the wires to make them fit in between the housing and your Arduino board without causing any harm to them or their circuit.

Once you have your Arduino pH circuit assembled, you can now place your sensor in a safe environment to see how well it works. However, you don’t want to put it in the water yet because you haven’t installed the software to let your sensor know its pH level.

You will have to install and run the Arduino IDE on your computer. You will also have it on your mobile phone for setting up, uploading, and testing sensors in the future.

Once you have finished installing everything, open up your Arduino IDE on your computer, select ‘File/Open and select the code you downloaded from our page.

Now connect your Arduino UNO to your computer with a USB cord and then click on ‘File/Upload’ this will send the code to your sensor so that you can start testing it out.

Click ‘Tools/serial monitor’ This will open up a terminal in which you can test your sensor! Type “M50” in the terminal to heat the water at 50 degrees Celsius.

If you type “M10” in your terminal, you will notice that the temperature is now 10 degrees Celsius hotter, and the LCD screen will now say “Temp 2.0”.

You can calibrate this sensor so that it will be able to tell the exact pH level that is in your environment. For this part, you will need two common solutions in a range of 1-14 pH. In this case, we used a solution at five and another at 10.

Our solution at five pH was pink, and our solution at ten pH was purple. So we mixed these two solutions, and our sensor read “7”. Which means you calibrated the sensor at 7.

This code will turn on (red LED on) the LED connected to your LED strip (VCC) and display “Temp” on the LCD screen. You can change these values in the sketch to suit your needs!

Then connect your pH source (a five pH) to your Arduino board. Then download a sketch from here. This will let your Arduino board be able to read your pH sensor!

Notice that when you download and upload the program, the LED light will turn blue and red when it recognizes that the sensor and Arduino need a connection.

It is essential to test the pH sensor in different environments to ensure that it will perform well. In this part, I will show you how we tested out the pH sensor in a few different environments. This would allow you to know that the sensor is doing what it is supposed to do.

We tested the pH sensor in an open environment. First, we used a clear jar and filled it up with distilled water so that there was no conductivity of the water, and we stirred for about 30 seconds. Next, we put a piece of pH paper on top of the solution and connected an Arduino board using a USB cable.

Then, we took the sensor apart and connected it to our lab equipment. We tested the voltage output from the sensor, compared it to a known value, and found that there was about 0.1 volts difference between both of them. We then compared the results to the pH table online and found that the readings were correct!

We used distilled water again to have no water conductivity in the jar. Next, we used a hard water solution and poured it into the jar. We then put some pH paper on top of the water and connected the other end to our Arduino board. Then we took our pH sensor apart, stripped off its casing, and put it into the hard water solution. From there, we tested both outputs from the Arduino and lab equipment.

To our surprise, both of them were about 0.02-volt difference which is acceptable for our sensor since it is an analog voltage output device. Unfortunately, we tested one previous version of the pH sensor in hard water, and it didn’t give us a reliable result, so we needed to replace it with this one since it is more precise.

We used the same setup again, but we used a saltwater solution, about 0.4 volts difference from our analog output device. Both outputs were still within an acceptable range, and we tested both of them using a previous version of the pH sensor in saltwater, and it also gave us similar results.

If your sketch is too large for the flash memory, you might get this error message, which means your sketch is too big to fit in the flash memory. To fix this problem, comment out unnecessary codes and compile and upload again. If it still doesn’t work, you can use another Arduino IDE instead of using the default one that comes with Arduino boards.

When you compile your code and upload it on your Arduino board, you might get the “Unsatisfied Link Error” message box. This means that there is a library that you need to add to the Arduino IDE before trying to compile and upload again. But, of course, you can always go to this page and download this library into your Arduino IDE to use it in your project.

This error happens when you try to upload a sketch, but nothing happens on your board. This might be because there is something wrong with the code you are trying to upload. First, try removing all the comments from your file and then re-compile it again. If that doesn’t work, you could use this other Arduino board instead.

When you upload sketches onto your Arduino board, you might get a message box telling you that “Serial port is already in use.” This might be because your IDE tried to upload on a serial port and failed because it was not connected. To fix this, try to restart your Arduino IDE by closing it and re-open the IDE.

Sometimes, when you compile your code, a Java error comes up and tells you that the Launch4j cannot run. This is because your Arduino board is not detected by your computer since there might be a problem with the serial connection between your computer and the Arduino board. Connect your Arduino board with a new USB cable to fix this problem.

This error happens when you try to connect an Arduino board to your computer, but your Arduino board doesn’t appear in the list of recognized devices. To fix this, remove the IDE, and after you reboot your computer and then re-plug it into the USB port, this should help.

Sometimes, the code you put into your Arduino IDE doesn’t work when you compile it. This might be because you need to put in the PIN before starting. To fix this problem, comment out the “Serial. begin()” line by putting a “#” at the beginning of that line and then upload the program onto your board again.

Your board may be out of sync with the Arduino IDE. If you can’t upload any sketch onto your board, try resetting and restarting it by disconnecting the power and reconnecting it to a new USB cable. This should sync it up to Arduino IDE to upload sketches onto your board.

This might be because your Arduino board is not compatible with this type of hardware. If you have an Arduino Uno that you cannot use, you might consider finding a different one.

Finally, we have finished our first pH sensor Arduino project. We started by looking at the basic parts that we will need for this project: an Arduino Uno and a pH sensor. After reading about how these sensors work, we decided to use the DS18B20, easy to find and cheap. Fortunately, most of the parts we used were available on Amazon, so there was no need to look everywhere to get what we needed.

After building our pH sensor, we tested both possible scenarios using hard and saltwater. We found that both outputs were still within an acceptable range from the common range of pH values. Both values were around seven and below eight, which means our sensor gave us a correct output.

ph sensor arduino with lcd display free sample

DFRobot Gravity: Analog pH Sensor/Meter Kit V2IntroductionThe new Arduino Analog pH sensor/Meter is compatible with Raspberry Pi and Arduino microcontroller.Attention:1. The BNC connector and the signal conversion board must be kept dry and clean, otherwise, it will affect the input impedance, resulting in an inaccurate measurement. If it is damp, it needs to be dried.

ph sensor arduino with lcd display free sample

PH is a scale with which we can determine whether the water-based solution is acidic or basic. PH is represented as the power of hydrogen or the potential of hydrogen (Source: Wikipedia). With the help of electrodes, we can measure PH of solution electronically which could be more beneficial to measure and automate PH of the aquarium, or hydroponic or aquaponic. So, in this article, we will learn How to make Arduino PH Meter.

Most plants require acidic PH to break down the mineral for proper growth with the help of this meter one can measure the PH of water and can select appropriate water.

PH electrode is a device containing two different sensors (electrode), where the main sensor is made from PH glass which detects the presence of hydrogen ion and reference sensor usually made from silver or silver chloride.

When the PH electrode is merged into liquid or solution, it generates a voltage according to the value of PH. The relation of output voltage and PH value is inverse i.e. at low PH value (acidic solution) it generates high voltage and as PH increases the output voltage starts to fall.

The output voltage of the electrode is not enough that any microcontroller or Arduino can read. This voltage either needs amplification or we have to use high-bit ADC. This module amplifies this electrode voltage that Arduino can easily read without much error. The module is ideal for general-purpose lab professionals and field use. Now, let’s see the features of this module.

The circuit of the Arduino PH meter is shown in figure 1. +5V from Arduino is connected to Vcc of the module where GND pin to GND. The output of Electrode and temperature sensor T1 (LM35) is analog, the P0 pin represents the output of the electrode and the T1 represents the output pin of LM35. Check out the article on interfacing LM35 with Arduino. These two pins are connected to the analog pin of Arduino.

You can use any analog pin except A4 and A5 because here we are using the I2C protocol for LCD. For instance, P0 is connected to A0, and T1 is connected to A1. Pin T2 of the module is DQ (output of DS18B20) is digital. Thus, pin T2 is connected digital D5 pin as shown in the circuit diagram. An electrode is connected to BNC connected to where DS18B20 is connected to the connector. VCC and GND of DS18B20 are connected to + and – pin marked near connector where DQ pin is connected to the middle pin of the connector. Check out the tutorial on how to interface DS18B20 with Arduino.

LCD is connected to Arduino in I2C protocol i.e. SDA and SCL pin of LCD is connected to SDA (A4) and SCL (A5) of Arduino respectively. For better power regulation a capacitor of 100uF is connected across Arduino 5V pin and GND pin as shown in the circuit diagram.

According to the manufacture datasheet at PH 7, it produces zero potential. For acidic solution, it produces positive potential and for a basic solution, it produces negative potential. As Arduino cannot read negative potential directly so we need proper calibration. We have to change negative potential to positive potential. So, we make PH 7.0 solution as middle point let say 2.5V i.e. when we immerse the electrode in pure water it will display 2.5V.

Step 2: Upload the program given below to your Arduino board. (This program is only for voltage reading, if you wish to measure potential at pin P0 using a multimeter then this step is not compulsory).

Step 3: Remove the electrode from the BNC connector and short the inside connector with an outside connector of BNC. i.e. positive and negative pin of the BNC connector is short-circuited.

Step 3: Similarly, immerse the electrode in PH 6.86 (under the temperature of 250C) standard buffer solution of phosphate, and gently shake it, and note down the corresponding voltage.

The voltage read by Arduino is now converted to PH by using the equation of straight link i.e. Y = mX + C. For converting we need slope (m) and constant (C). For calculating m and C we had taken the voltage reading at two different pH solutions.

Software is written in Arduino programming language and compiled using Arduino IDE. This software takes reading from the electrode, LM35, and DS18B20 and converts it into the PH of the solution, surrounding temperature, and solution temperature. For working on this software code, we need four libraries. LiquidCrystal_I2C for I2C 20×4 LCD, one wire, and DallasTemperature for DS18B20 waterproof temperature sensor and math.h is used to calculate the absolute value of float type quantity for calibration. In software code, we had also generated a special character for