Hi guys,
this is my first message in here :]
I'm working on aquarium project and there for i need to measure the PH level of the solution and i would like your helps with the code debugging.
(I didn't tried this yet cause I didn't got the products yet)
I decided to use the phidget 1130 - pH/ORP Adapter
Product Link:
Product Manual
and regular PH prob - Analytical grade chemicals, lab materials PH Probe, USA
Product Link:
http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=290513215434
and regular LM35 Temperature Sensor (Because the PH level is relative to the solution temperature)
const int LM35 = A0
const int PHprobe = A1;
void setup()
{
Serial.begin(9600);
}
void loop()
{
int WaterTemp = 0;
int WaterPH = 0;
WaterTemp = TankTemperature();
WaterPH = TankPHLevel(WaterTemp);
Serial.println(WaterPH, DEC);
}[ch8195]
int TankTempetraure()
{
float TankTemp = 0;
float tempc = 0; // temperature variables
float samples[8]; // variables to make a better precision
float maxi = -100,mini = 100; // to start max/min temperature
int i;
for(i = 0;i< =7;i++) // gets 8 samples of temperature
{
samples[i] = ( 5.0 * analogRead(LM35) * 100.0) / 1024.0;
tempc = tempc + samples[i];
delay(300);
}
CurrentTankTemp = tempc/8.0; // better precision
if(CurrentTankTemp > maxi) {maxi = CurrentTankTemp;}
if(CurrentTankTemp < mini) {mini = CurrentTankTemp;}
return CurrentTankTemp;
}
[ch8195]
int TankPHLevel(float temp)
{
float CurrentTankPH = 0;
float PH = 0; // PH variables
float samples[8]; // variables to make a better precision
float maxi = -100,mini = 100; // to start max/min PH
int i;
for(i = 0;i< =7;i++) // gets 8 samples of PH
{
samples[i] = 7 - (2.5 - analogRead(PHprobe)/200) / (0.257179 + 0.000941468 * temp);
PH = PH + samples[i];
delay(1000);
}
CurrentPH = PH/8.0; // better precision
if(CurrentPH > maxi) {maxi = CurrentPH;}
if(CurrentPH < mini) {mini = CurrentPH;}
return CurrentkPH;
}
I want to highlight this line from the code:
samples = 7 - (2.5 - analogRead(PHprobe)/200) / (0.257179 + 0.000941468 * temp);
PH = PH + samples*;*
CurrentPH = PH = PH/8.0;
[/glow]
This is the function that consulate the PH level in the solution is it correct? or should i add somewhere the "/1024" ?
Thanks a lot for the helpers