The Planted Tank Forum banner

diy arduino ph controller

16K views 20 replies 8 participants last post by  Ultimbow 
#1 ·
#2 ·
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.
 
#5 ·
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.
 
#13 ·
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.
 
#17 · (Edited)






there you go!



This is the code at Arduino on pH PCB
Code:
#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
Code:
#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.
 

Attachments

#21 ·
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.


Audio equipment Electronic device Entertainment Circuit component Night


Circuit component Electronic device Electronic component Cable Wire



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
#define samplingInterval 20
#define printInterval 800
#define ArrayLenth 40 //times of collection
int pHArray[ArrayLenth]; //Store the average value of the sensor feedback
int pHArrayIndex=0;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int relay = 10;


void setup()
{
pinMode(relay,OUTPUT);
pinMode(LED,OUTPUT);
Serial.begin(9600);
Serial.println("pH meter experiment!"); //Test the serial monitor
}
void loop()
{
static unsigned long samplingTime = millis();
static unsigned long printTime = millis();
static float pHValue,voltage;
if(millis()-samplingTime > samplingInterval)
{
pHArray[pHArrayIndex++]=analogRead(SensorPin);
if(pHArrayIndex==ArrayLenth)pHArrayIndex=0;
voltage = avergearray(pHArray, ArrayLenth)*5.0/1024;
pHValue = 3.5*voltage+Offset;
samplingTime=millis();
}
if(millis() - printTime > printInterval) //Every 800 milliseconds, print a numerical, convert the state of the LED indicator
{
Serial.print("Voltage:");
Serial.print(voltage,2);
lcd.setCursor(0, 1);
lcd.print("PH:");
Serial.print(" pH value: ");
Serial.println(pHValue,2);
lcd.print(pHValue,2);
digitalWrite(LED,digitalRead(LED)^1);
printTime=millis();

}
if(pHValue >= 7.00)
{
digitalWrite(relay,HIGH);
}
else
{
digitalWrite(relay,LOW);
}

}
double avergearray(int* arr, int number){
int i;
int max,min;
double avg;
long amount=0;
if(number<=0){
Serial.println("Error number for the array to avraging!/n");
return 0;
}
if(number<5){ //less than 5, calculated directly statistics
for(i=0;i<number;i++){
amount+=arr;
}
avg = amount/number;
return avg;
}else{
if(arr[0]<arr[1]){
min = arr[0];max=arr[1];
}
else{
min=arr[1];max=arr[0];
}
for(i=2;i<number;i++){
if(arr<min){
amount+=min; //arr<min
min=arr;
}else {
if(arr>max){
amount+=max; //arr>max
max=arr;
}else{
amount+=arr; //min<=arr<=max
}
}//if
}//for
avg = (double)amount/(number-2);
}//if
return avg;
}


 
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top