# diy arduino ph controller



## Darkblade48 (Jan 4, 2008)

Seems a bit expensive for what you get. I know there are other sources where you can get the exact same functionality (pH measurements), but has an integrated Arduino chip already for a few dollars more.

Of course, if you already have a spare Arduino, however, then this might be an option. Alternatively, if you have the individual components, it is not too difficult to construct a basic controller on a breadboard.


----------



## Ultimbow (Mar 19, 2009)

I was going with this to put it in my current built on a mega and touch screen light control and many other option i am self teaching in the prosses too so i try to keep simple for now ;-)


----------



## mistergreen (Dec 9, 2006)

there are other sensor https://www.sparkfun.com/search/results?term=ph 
but they're more expensive so you found a good deal. Make sure to to code it so you can recalibrate easily every week or month. They do drift and every point matters when you use it to measure CO2. You can be off by 2ppm to 20+ppm. That's the problem with pH controllers.


----------



## mattinmd (Aug 16, 2014)

Darkblade48 said:


> Seems a bit expensive for what you get. I know there are other sources where you can get the exact same functionality (pH measurements), but has an integrated Arduino chip already for a few dollars more.


An Arduino (or ATMega chip) and pH probe together for only a bit over $30?

Where? That sounds like an amazing deal and I'm very intrigued by it.


----------



## gus6464 (Dec 19, 2011)

That is quite cheap compared to an Atlas probe and chip which is considerably more.
http://atlas-scientific.com/product_pages/kits/ph-kit.html?


----------



## Darkblade48 (Jan 4, 2008)

mattinmd said:


> An Arduino (or ATMega chip) and pH probe together for only a bit over $30?
> 
> Where? That sounds like an amazing deal and I'm very intrigued by it.


I will PM you.


----------



## Ultimbow (Mar 19, 2009)

Darkblade i would be interested to see it too i would maby upgrade my smaller tank ;-)


----------



## PlantedRich (Jul 21, 2010)

When looking at buying PH probes, don't pass up looking at ag suppliers. They can be had much cheaper than the stock aquarium supply.


----------



## kman (Dec 11, 2013)

Darkblade, I'm interested in this cheap setup, as well, if you don't mind shooting me the same PM.


----------



## Darkblade48 (Jan 4, 2008)

kman said:


> Darkblade, I'm interested in this cheap setup, as well, if you don't mind shooting me the same PM.


Done.


----------



## kman (Dec 11, 2013)

mattinmd said:


> An Arduino (or ATMega chip) and pH probe together for only a bit over $30?
> 
> Where? That sounds like an amazing deal and I'm very intrigued by it.


Looks like the pH probe is separate, unfortunately... only the circuitry part of the LeoPhi is $35, although it does look pretty nifty.

Add all the parts together and I have a hard time seeing how someone can assemble a fully operational Arduino-based (or similar) reader, display and probe for less than the fully-assembled commercial solutions, like this one:

https://www.amazon.com/American-Marine-PINPOINT-Monitor-Calibration/dp/B000255MH4/

Although I'd love to be wrong, because if I can get the same functionality (or more) for less, that would be great!

The SparkysWidgets site does have a nice tutorial on building your own, so perhaps if you have lots of parts laying around, you could reduce the cost some.


----------



## Ultimbow (Mar 19, 2009)

Just order mine from df robot today it was back order for a while they had 125 when a started this post and 2 day after they where out  today they had 6 available come to 41$ with shipping (Canada). Want to incorporate it in my build witch is going really slow with a 6 month old boy and i am learning (starting at zero) at same time. Will put picture when i receive it and do the "basic connection" to test it.


----------



## Ultimbow (Mar 19, 2009)

Received my ph "shield" today [emoji2] dint think was going to get her so fast. Will check and test the basic code tonight and then will try to build a controller with a uno and relay.


----------



## saiko (Mar 30, 2007)

sorry but bit late on this thread. You can check the below too if you like to build one on your own. Suppose to work for other probes too.
http://www.reefcentral.com/forums/showthread.php?p=16463909

You can check my model at end. I put an Atmega-8(arduino bootload) so that I can send data serially over.


----------



## Ultimbow (Mar 19, 2009)

saiko said:


> sorry but bit late on this thread. You can check the below too if you like to build one on your own. Suppose to work for other probes too.
> http://www.reefcentral.com/forums/showthread.php?p=16463909
> 
> You can check my model at end. I put an Atmega-8(arduino bootload) so that I can send data serially over.


No problem always fun to look at other people project. The last picture of the post are broken or unavailavle any more could see them. At least not with my cell phone. [emoji20]


----------



## saiko (Mar 30, 2007)

there you go!



This is the code at Arduino on pH PCB

```
#include <EasyTransfer.h>


//The pins 2=Rx,3=Tx


//create object
EasyTransfer ET; 
struct SEND_DATA_STRUCTURE{
  //put your variable definitions here for the data you want to send
  //THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO
  int val_ph_a;
  int val_ph_b;
};

//give a name to the group 
SEND_DATA_STRUCTURE mydata;

int analogPin = 5;     // potentiometer wiper (middle terminal) connected to analog pin 3
                       // outside leads to ground and +5V
int val = 0;           // variable to store the analog value read

float val_ph=0;        //store the float multipled value
int i=0,j;

float val_ph_array[5]={0,0,0,0,0};
void setup()
{
  Serial.begin(9600);          //  setup serial
  //start the library, pass in the data details and the name of the serial port. Can be Serial, Serial1, Serial2, etc.
  ET.begin(details(mydata), &Serial);
  
 
  
  for(j=0; j<20;j++)//run a few times before sending over serial, so that array is not blank
  {
  val = analogRead(analogPin);    // read the input pin
  if (i>4)
  i=0;
  val_ph_array[i]=val * 0.02;// calculate WRT voltage
  val_ph=float (val_ph_array[0] + val_ph_array[1] + val_ph_array[2] + val_ph_array[3] + val_ph_array[4])/5;//normalizing any of the error data
  i++;
  }
  

}
void loop()
{  

  val = analogRead(analogPin);    // read the input pin
  
  if (i>4)
  i=0;
  val_ph_array[i]=val * 0.02;// calculate WRT voltage
  val_ph=float (val_ph_array[0] + val_ph_array[1] + val_ph_array[2] + val_ph_array[3] + val_ph_array[4])/5;//normalizing any of the error data
  i++;
  
  mydata.val_ph_a=val_ph;
  mydata.val_ph_b=(val_ph- mydata.val_ph_a)*100;  
  Serial.println(val);     // debug value 
  ET.sendData(); 
  delay(1000); //send pH every 1sec to mother Arduino
}
```
This is the code at the mother Arduino

```
#include <SoftEasyTransfer.h>

/*   For Arduino 1.0 and newer, do this:   */
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); //RX TX hard coded, not the main UARTs

/*   For Arduino 22 and older, do this:   */
//#include <NewSoftSerial.h>
//NewSoftSerial mySerial(2, 3);


//create object
SoftEasyTransfer ET; 

struct RECEIVE_DATA_STRUCTURE{
  //put your variable definitions here for the data you want to receive
  //THIS MUST BE EXACTLY THE SAME ON THE OTHER ARDUINO
  int tens_part;
  int deci_part;
};

//give a name to the group of data
RECEIVE_DATA_STRUCTURE mydata;

void setup(){
  mySerial.begin(9600);
  Serial.begin(9600);
  //start the library, pass in the data details and the name of the serial port.
  ET.begin(details(mydata), &mySerial);
  
  pinMode(13, OUTPUT);
  Serial.println("sjklads ghewre");
}

void loop(){
  //check and see if a data packet has come in. 
  if(ET.receiveData())
    {
      //this is how you access the variables. [name of the group].[variable name]
    //since we have data, we will blink it out. 
    /*for(int i = mydata.blinks; i>0; i--){
      digitalWrite(13, HIGH);
      delay(mydata.pause * 100);
      digitalWrite(13, LOW);
      delay(mydata.pause * 100);
    }*/
    
    Serial.print(mydata.tens_part);
    Serial.print(".");
    Serial.print(mydata.deci_part);
    Serial.println("");
  }
  //you should make this delay shorter then your transmit delay or else messages could be lost
  delay(250);
}
```










On left is the completed board, on right is the mother Arduino, and in center is the lab grade pH probe.


----------



## Ultimbow (Mar 19, 2009)

Wow that is realy neet project thanks!!!


----------



## mistergreen (Dec 9, 2006)

how do you calibrate?


----------



## saiko (Mar 30, 2007)

hi, the pic dint have all components put in it. But it has provision for 2 trimmers(bottom of pic). So, they are used to calibrate one above and one below 7


BTW the readings are with the probe still in storage sol.


----------



## Ultimbow (Mar 19, 2009)

So her is what i have put together it seem to work ok but dint test on aquarium yet i am out of co2 will get my bottle fill tomorrow and i am waiting for my calibration fluid that i should get tomorrow too. I will run/test the setup without the co2 plug on controller to monitor it.



















her is the code 



> #include <LiquidCrystal.h>
> #define SensorPin A0 //pH meter Analog output to Arduino Analog Input 0
> #define Offset 0.91 //deviation compensate
> #define LED 13
> ...


----------

