PH Regulater/Meter - Arduino

About: Third year Electrical Engineering student at California Polytechnic State University

Intro: PH Regulater/Meter - Arduino

***If photos and links are not appearing, refresh the page

This is an instructable for an arduino pH regulator or meter:

--- The regulator is meant for reactions that start at a certain pH and naturally decrease/increase in pH due to the reaction. However, for many reactions, it is desired to stay at the starting pH. So, if the reaction deviates too far from the desired pH, this arduino project will pump in acid or base to bring the pH back to normal.

--- This project can also be used just simply as a pH sensor that reads pH of any solution.

Step 1: Necessary Materials

-Arduino Uno

-Computer and keyboard

-12V Peristaltic Liquid Pump

-Analog pH Sensor / Meter Pro Kit for Arduino

-I2C 20x4 Arduino LCD Display Module

-IN4001 Diode

-PN2222 Transistor

-12V DC Power Adapter

-Male to Female Jumper Wires

-Male to Male Jumper Wires

-Alligator Clips

-Arduino USB Cable


Step 2: Solder Diode Between Prongs of Pump

Solder the diode between the prongs of the peristaltic pump as pictured. Be sure to put the silver band of the diode pointing towards the (+) prong of the pump. This will protect the motor of the pump.

Step 3: Wiring Up the Hardware

A4 -------------------- to the SDA of LCD

A5 -------------------- to the SCL of LCD

GND ----------------- to GND of LCD

5V -------------------- to VCC of LCD

A0 -------------------- to middle prong (base) of transistor

GND ----------------- to **left prong (emitter) of transistor, **referred to flat side of transistor

(-) prong pump ---- to **right prong (collector) of transistor

(+) prong pump ---- to Vin (12V)

A3 -------------------- to signal wire (blue) of pH meter

5V -------------------- to (+) wire (red) of pH meter

GND ----------------- to (-) wire (black) of pH meter


***See photos for more detail

Step 4: The Code

There are 2 versions of the Arduino Code file attached... one is for regulating reactions that are increasing in pH, and the other is for reactions decreasing in pH



Download the needed libraries (zip attached in this instructable)

This code uses an LCD library that is not already included on the Arduino...

To implement this zip file into your project, download to your computer,

In arduino window, go to "Sketch" --> "Include Library" --> "Add .ZIP Library"

Step 5: Important Note -- Serial Monitor

This program uses a Serial input to drive the menu screens. This means that it will need to be connected to a computer or laptop during use. To operate the serial monitor, click the top right button (looks like a magnifying glass) on the arduino window.

***IMPORTANT - use "Autoscroll", "No line ending", and "9600 baud" options on the serial monitor screen... if you do not, the code will not perform as designed

To input values, type a value in using your keyboard and press the enter key, or click "Send"

Step 6: Adjusting the Code to Your Regulator Needs

There are very simple constants that just need to be changed to make sure that this program works for you! Below are the recommended constants to change and their descriptions:

-- fillTime : how long it takes your pump to completely fill with liquid, in seconds

-- delayTime: how long you want the regulator to wait before pumping in more solution

-- smallAdjust: number of seconds you want acid/base to be pumped in when pH deviates by 0.3 - 1 pH

-- largeAdjust: number of seconds you want acid/base to be pumped in when pH deviates by > 1pH


In addition, you will need to figure out what offset and slope your pH meter has...

If my slope and offset does not work well with your pH meter, you will need to take the following steps:

(1)-- set slope = 1 and offset = 0

(2)-- take and record pH readings in solutions of exactly pH 4, pH 7, and pH 10

(3)-- Create a system of equations like so:

(actual pH 4 reading)*slope + offset = 4

(actual pH 7 reading)*slope + offset = 7

(actual pH 10 reading)*slope + offset = 10


Use these three equations to find a best fit line to solve for slope and offset and change these constants to your new slope and offset values

Step 7: Video of the PH Regulator/Meter With Calibration Feature



    • Furniture Contest 2018

      Furniture Contest 2018
    • Audio Contest 2018

      Audio Contest 2018
    • Metalworking Contest

      Metalworking Contest

    3 Discussions


    18 days ago

    Many interesting applications for this project such as:
    Chemistry research
    Water treatment

    On the chemistry side we can also fine tune the controls using different types of acid and base at different concentrations.

    A process that needs two way pH control can use two of these controllers. one running acid and one with base. Remember the code needs a slight tweak depending on if u are trying to increase or decrease pH!

    Thanks a lot for the great work DJ!


    20 days ago

    Interesting project!


    21 days ago

    Very nice! Thanks for sharing your project!