element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Vertical Farming
  • Challenges & Projects
  • Design Challenges
  • Vertical Farming
  • More
  • Cancel
Vertical Farming
Blog Automated Green House Blog:13.2 - PH Control: Measurement Portion
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: m.ratcliffe
  • Date Created: 19 Nov 2015 2:48 PM Date Created
  • Views 1235 views
  • Likes 2 likes
  • Comments 2 comments
  • adapted_greenhouse
  • ph
Related
Recommended

Automated Green House Blog:13.2 - PH Control: Measurement Portion

m.ratcliffe
m.ratcliffe
19 Nov 2015

This Blog will cover how to measure pH in your aquaponics/hydroponics system, later we will be using this reading to control the pH.

 

Take a look at the blog below to see why PH is an important factor and why we need to be controlling it.

 

Blog:20.2 - Toying with Chemical Analysis - pH

 

The pH Probe

DFRobot have been nice enough to send me one of their MCU pH sensors, it is the pro model with a longer life than the normal probes [hopefully I cant break this probe].

 

image

 

 

What else you will need:

>pH calibration fluid [4 and 7]

>Arduino mega/uno

 

Wiring diagram

image

 

Calibration

pH probes need to calibrated routinely [one a month is a good idea] so we better have a code that lets us easily calibrate the thing.

 

Wire the probe up like the diagram above, upload the code below and then:

 

1:Place Probe into pH7 calibration fluid, open serial

image

 

2:Take Recommended cell constant and change it in the top of code

image

 

 

 

3:Rinse Probe and place in pH4 calibration fluid

4:Adjust potentiometer on pH meter shield until ph reading in serial is 4

image

 

 

That's it, you are now calibrated and ready to use the pH reading from serial.

 

The Code

This reads the ph probes shield [its an analog value] averages ten readings to reduce any noise and converts the ADC reading into a ph value. outputting the reading to serial.

 

PH Measurement code

/*

   Script to print PH to serial

 

 

   28/8/2015  Michael Ratcliffe  Mike@MichaelRatcliffe.com

  

  

          This program is free software: you can redistribute it and/or modify

    it under the terms of the GNU General Public License as published by

    the Free Software Foundation, either version 3 of the License, or

    (at your option) any later version.

 

 

    This program is distributed in the hope that it will be useful,

    but WITHOUT ANY WARRANTY; without even the implied warranty of

    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

    GNU General Public License for more details.

 

 

    You should have received a copy of the GNU General Public License

    along with this program.  If not, see <http://www.gnu.org/licenses/>.

 

    Parts:

    -Arduino - Uno/Mega

   -df Robot Ph Probe Kit [SKU:SEN0169] This is a great PH sensor compared to the ones ive had in the past

 

 

 

    See www.MichaelRatcliffe.com/Projects for a Pinout and user guide or consult the Zip you got this code from

 

*/

 

 

//*********************** User defined variables ****************************//

//pH meter Analog output to Arduino Analog Input 0

int PHPin =A15; 

//The calibration constant for the PH probe

float K=3.64;         

//The Ph we will be calibrating in

int Cal_pH=7;

 

 

//********************** End Of Recomended User Variables ******************//

 

 

//************** Some values for working out the ph*****************//

float Kn=0;

float phValue=0;

int i=0;

long reading=0;

long sum=0;

float average=0;

 

 

 

 

//******************** Setup Loop Runs Once ******************************//

void setup()

{

  Serial.begin(9600);

  startupinfo();

}

 

 

//******************** Main Loops runs Forver **************************//

void loop()

{

ReadPH();

PrintSerial();

Calabrate();

delay(1000);

}

 

 

//*************************Print Some useful startup info **************************//

void startupinfo(){

Serial.println("pH Probe Script for arduino");

Serial.println("Released under GNU by Michael Ratcliffe");

Serial.println("www.MichaelRatcliffe.com");

Serial.println("Element14 'Adapted_Greenhouse'");

Serial.println("Using DFRobot PH Probe Pro ");

Serial.println("How to Use:");

Serial.println("1:Place Probe into pH7 calibration fluid, open serial ");

Serial.println("2:Take Recomened cell constand and change it in the top of code");

Serial.println("3:Rinse Probe and place in pH4 calibration fluid");

Serial.println("4:Adjust potentiometer on pH meter shield until ph reading in serial is 4");

Serial.println("    ");

Serial.println("Thats it your calibrated and your readings are accurate!");

 

}

 

 

 

 

//*************************Take Ten Readings And Average ****************************//

void ReadPH(){

  i=1;

  sum=0;

  while(i<=10){

  reading=analogRead(PHPin);

  sum=sum+reading;

    delay(20);

    i++;

  }

average=sum/10.0;

//converting the average to PH 3.5 part convers mv to ph

phValue=average*K*5/1024; 

 

}

 

 

//*************************** Print useful data to moniter ****************************//

void PrintSerial(){

 

 

Serial.print("    pH:");

Serial.print(phValue);

Serial.println(" ");

 

}

 

 

 

 

//****************** Calculate a K value *********************************************//

void Calabrate(){

 

 

Kn=((Cal_pH*1024)/(average*5));

Serial.print("If pH 7, Cell Konstant=  :");

Serial.println(Kn);

 

 

};

 

 

Temperature Compensation:

For the time being we will not be implementing temperature correcting, because it is not a major effect. We may correct for it later if it proves to be a bigger problem than we anticipated. Here is a example of how measured PH will change with temperature [pH 4 potassium biphthalate buffer standard ] [1]

Temperature [C]             pH
104.00
154.00
204.00
254.01
304.02
354.02
404.04
454.05
504.06
554.08
60

4.09

 

 

Reference:

[1 ]pH Temperature Compensation: PASCO

  • Sign in to reply
  • m.ratcliffe
    m.ratcliffe over 9 years ago in reply to DAB

    I got good readings over a hour, its a bit awkward to have the data over serial when working on the laptop. The next blog will be with a LCD and logs min/max PH, so I will leave it in some water overnight for a little longer of a test.


    It certainly feels a lot sturdier than the ones ive used in the past and the spec sheet says it is for "long term use" but I dont have enough data to confirm this at the moment. I hope it does live upto its claims, pH is what ive always struggled with the most. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • DAB
    DAB over 9 years ago

    I am curious, how stable is the probe over time?

     

    You get the data you need for the calibration test, but have you looked at the values over time?

     

    DAB

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube