How to place EC and pH probe in the same circuit?

Hi, I’m building a water quality test using a EC and pH probe. I bought this EC meter:

and this pH meter:

I place them side by side about 3 cm gap. I realized that the reading goes way off especially for the pH probe when I placed them side by side in the same water. Once I isolated both the probe, the reading returns back to normal.

How do I fix this issue to connect both the probes together without having these error?

What is your entire experiment?

You make it sound like it is not a code problem, but sensor interaction. Obvsly you cannot program around that.

So, code please and a schematic will help, as will any dets on your procedure.


Nice looking code, but not complete. I don’t see the readec() or readph() functions, nor any code that looks like it is making an initial interaction with the sensors, like turning them on, configuring &c.

So… it still feels like an interaction between the sensors.

Is it possible to turn off one whilst you read the other, then vice-versa? This would might eliminate such interaction.

Also it might be easier here if you were working with a very smaller program that simply takes readings you seek and prints them.


Here’s the remaining code:

void readec(){
     // subtract the last reading:
    AnalogValueTotal = AnalogValueTotal - readings[index];
    // read from the sensor:
    readings[index] = analogRead(ECsensorPin);
    // add the reading to the total:
    AnalogValueTotal = AnalogValueTotal + readings[index];
    // advance to the next position in the array:
    index = index + 1;
    // if we're at the end of the array...
    if (index >= numReadings)
    // ...wrap around to the beginning:
    index = 0;
    // calculate the average:
    AnalogAverage = AnalogValueTotal / numReadings;
   Every once in a while,MCU read the temperature from the DS18B20 and then let the DS18B20 start the convert.
   Attention:The interval between start the convert and read the temperature should be greater than 750 millisecond,or the temperature is not accurate!
    temperature = sensors.getTempCByIndex(0);  // read the current temperature from the  DS18B20
    TempProcess(StartConvert);                   //after the reading,start the convert for next reading
   Every once in a while,print the information on the serial monitor.
    Serial.print("Analog value:");
    Serial.print(AnalogAverage);   //analog average,from 0 to 1023
    Serial.print("    Voltage:");
    Serial.print(averageVoltage);  //millivolt average,from 0mv to 4995mV
    Serial.print("mV    ");
    Serial.print(temperature);    //current temperature
    Serial.print("^C     EC:");
   // tb.sendTelemetryFloat("maintemp", temperature);
    float TempCoefficient=1.0+0.0185*(25-25.0);    //temperature compensation formula: fFinalResult(25^C) = fFinalResult(current)/(1.0+0.0185*(fTP-25.0));
    float CoefficientVolatge=(float)averageVoltage/TempCoefficient;   
    if(CoefficientVolatge<150)Serial.println("No solution!");   //25^C 1413us/cm<-->about 216mv  if the voltage(compensate)<150,that is <1ms/cm,out of the range
    else if(CoefficientVolatge>3300)Serial.println("Out of the range!");  //>20ms/cm,out of the range
      if(CoefficientVolatge<=448)ECcurrent=6.84*CoefficientVolatge-64.32;   //1ms/cm<EC<=3ms/cm
      else if(CoefficientVolatge<=1457)ECcurrent=6.98*CoefficientVolatge-127;  //3ms/cm<EC<=10ms/cm
      else ECcurrent=5.3*CoefficientVolatge+2278;                           //10ms/cm<EC<20ms/cm
      ECcurrent/=1000;    //convert us/cm to ms/cm
      Serial.print(ECcurrent,2);  //two decimal
      //tb.sendTelemetryFloat("EC", ECcurrent );
void readph(){
  int buf[10];                //buffer for read analog
  for(int i=0;i<10;i++)       //Get 10 sample value from the sensor for smooth the value
  for(int i=0;i<9;i++)        //sort the analog from small to large
    for(int j=i+1;j<10;j++)
        int temp=buf[i];
  for(int i=2;i<8;i++)                      //take the average value of 6 center sample
  float phValue=(float)avgValue*5.0/1024/6; //convert the analog into millivolt
  phValue=3.5*phValue+Offset;                      //convert the millivolt into pH value
  Serial.print("    pH:"); 
  Serial.println(" ");
  digitalWrite(13, HIGH);      
  digitalWrite(13, LOW);
  a = phValue;
  //tb.sendTelemetryFloat("ph" , phValue);

Hmm I’m not too sure how to write a code to turn on and off a particular probe.

Yes, at a glance it looks like both are just on and your only interface to them is through analogRead()…

And it seems obvious that if you took the trouble to arrange so that one was off &c., by, say, manually disconnecting power between the two sensor read calls as an experiment, everything would be fine.

At this point the path diverges. I would spend time or let ppl here look at the code closer. It might be better to spend time figuring out how to turn the sensors on and off through code (easy to do, but the sensors mightn’t like it so much) and/or googling elsewhere for known interactions between the two sensors.



This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.