EC Meter Analog Conductivity Meter, incorrect values

Hi guys, I have buy this product on Aliexpress :
EC Meter Analog Conductivity Meter

And i have utilized the code present in description in product ( I attached the code ). I see the value of analog is not stabiled :slight_smile:

const byte numReadings = 20;     // the number of sample times
byte ECsensorPin = A7;  // EC Meter analog output, pin on analog 1
unsigned int AnalogSampleInterval = 25, printInterval = 700;  // analog sample interval; serial print interval
unsigned int readings[numReadings];      // the readings from the analog input
byte indexEC = 0;                  // the index of the current reading
unsigned long AnalogValueTotal = 0;                  // the running total
unsigned int AnalogAverage = 0, averageVoltage = 0;                // the average
unsigned long AnalogSampleTime, printTime;
float temperature = 23.0;  // Fixed temperature
float ECcurrent;

void setup() {
  // initialize serial communication with computer:
  Serial.begin(115200);
    pinMode(ECsensorPin,INPUT); //per il sensore TDS
  // initialize all the readings to 0:
  for (byte thisReading = 0; thisReading < numReadings; thisReading++)
    readings[thisReading] = 0;
  AnalogSampleTime = millis();
  printTime = millis();
}

void loop() {

  if (millis() - AnalogSampleTime > 40U) {
    AnalogSampleTime = millis();
    // subtract the last reading:
    AnalogValueTotal = AnalogValueTotal - readings[indexEC];
    // read from the sensor:
    readings[indexEC] = analogRead(ECsensorPin);
    // add the reading to the total:
    AnalogValueTotal = AnalogValueTotal + readings[indexEC];
    // advance to the next position in the array:
    indexEC = indexEC + 1;

    // if we're at the end of the array...
    if (indexEC >= numReadings)
      // ...wrap around to the beginning:
      indexEC = 0;
    // calculate the average:
    AnalogAverage = AnalogValueTotal / numReadings;

  }
  /*
  Every once in a while, print the information on the serial monitor.
  */
  if (millis() - printTime >= printInterval) {
    printTime = millis();
    averageVoltage = AnalogAverage * (float)5000 / 1024;
    // 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("temp:");
    // Serial.print(temperature);    // fixed temperature
    // Serial.print("^C     EC:");


    float TempCoefficient = 1.0 + 0.0185 * (temperature - 25.0);    // temperature compensation formula: fFinalResult(25^C) = fFinalResult(current)/(1.0+0.0185*(fTP-25.0));

    float CoefficientVolatge = (float)averageVoltage / TempCoefficient;
    // Serial.print("Coefficient Voltage: ");
    // Serial.println(CoefficientVolatge);

    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
    else {
      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
      Serial.println("ms/cm");
    }
  }
}

23:28:13.666 -> ECsensorPin: 589
23:28:13.666 -> ECsensorPin: 1010
23:28:13.712 -> ECsensorPin: 1018
23:28:13.712 -> ECsensorPin: 804
23:28:13.746 -> ECsensorPin: 0
23:28:13.746 -> ECsensorPin: 869
23:28:13.790 -> ECsensorPin: 982
23:28:13.836 -> ECsensorPin: 780
23:28:13.836 -> ECsensorPin: 0
23:28:13.871 -> ECsensorPin: 920
23:28:13.871 -> ECsensorPin: 342

this is Instead the value EC :

23:50:28.444 -> 17.89ms/cm
23:50:29.142 -> 17.75ms/cm
23:50:29.841 -> 18.18ms/cm
23:50:30.542 -> 15.71ms/cm

the value is same if the sensor is in water or in not water.
I not understand why...
I have try the sketch with the sensor disconnected end the value is this:

23:04:26.165 -> Analog value:101 Voltage:493mV Coefficient Voltage: 511.94
23:04:26.201 -> EC: 3.45ms/cm
23:04:26.900 -> Analog value:101 Voltage:493mV Coefficient Voltage: 511.94
23:04:26.900 -> EC:3.45ms/cm

I thank you in advance for your help.

You should tell what arduino board you have and how it's wired to sensor

1 Like

I have Arduino GIGA R1 WIFI, and for this test I have disconnected all sensor and I left only pin A7 for the sensor, which is powered by a 5V plug, as per the product instructions

more precisely?
Please just tell your wiring.

Are you aware that you have 3.3V board and 5V sensor?

1 Like


this is the circuit. I hope I answered the question

I don't see your arduino being powered at all...
Just describe, are they powered from separate power supplies?
Like arduino from usb and sensor from 5v adapter?

1 Like

exactly arduino from usb-C and sensor from 5V adapter

@kiry32
The minus (-) of the EC board need to be connected to the Arduino GND

Ok
You have two major issues here.
First, sensor GND and arduino GND have to be connected.
Second, I'm quite sure that your sensor is outputting 0-5V and your arduinos analog input can handle only 3.3V.
I see from your mistakes, that you are completely beginner in electronics, that's why I make a question: do you have an other arduino board, Uno, Nano or whatever 5V board?
Would be easier for you to get started.

1 Like

no I don't have any other cards, and yes I'm not very knowledgeable in electronics, how can I solve this by using this card?

I have try to connect GND on board, but the sensor remains off, it does not turn on

First, you need to make connection between sensor GND(-) and arduino GND. Alternatively you might be able to power your sensor from arduino 5V and GND pins but I can't guarantee without datasheet of your sensor(max current draw).
Second, you need voltage divider to read that signal from sensor. That can be built with resistors, do you have?

You still need gnd from power supply, connection to arduino is "extra wire"

Also stop playing with wires randomly, you risk to damage your expensive arduino! Disconnect that sensor output wire from arduino.

1 Like

this is dataSheet :
Technical Parameter

  • K=1
  • Operating Voltage: +5.00V
  • PCB size: 45mm *32mm
  • Measurement range: 1ms/cm--20ms/cm
  • Applicable temperature: 5-40 C
  • Accuracy: <+10%F.S. (Specific accuracy depends on your calibration accuracy)
  • XH2.54 Interface (3-foot patch)
  • BNC interface conductivity electrode (electrode constant is 1)
  • Conductive electrode cable length: about 60 cm
  • Power Indicator Lamp

Wiring diagram

EC Meter--Arduino

  • V - - - 5.0V;
  • G - -- GND;
  • A - Analog IO (corresponding to source code)

12:52:07.930 -> Analog value:454 Voltage:1463mV Coefficient Voltage: 1519.21
12:52:07.971 -> EC: 10.33ms/cm
12:52:07.971 -> ECsensorPin: 485
12:52:08.017 -> ECsensorPin: 0
12:52:08.063 -> ECsensorPin: 71
12:52:08.109 -> ECsensorPin: 219
12:52:08.151 -> ECsensorPin: 0
12:52:08.151 -> ECsensorPin: 0
12:52:08.233 -> ECsensorPin: 0
12:52:08.233 -> ECsensorPin: 0
12:52:08.297 -> ECsensorPin: 0
12:52:08.343 -> ECsensorPin: 301
12:52:08.389 -> ECsensorPin: 723
12:52:08.435 -> ECsensorPin: 928
12:52:08.479 -> ECsensorPin: 864
12:52:08.479 -> ECsensorPin: 694
12:52:08.545 -> ECsensorPin: 25
12:52:08.591 -> ECsensorPin: 0
12:52:08.637 -> ECsensorPin: 0

I Use this schematic, for this values:

average total is convert for 3.3V:

    //averageVoltage = AnalogAverage * (float)5000 / 1024;
    averageVoltage = AnalogAverage * (float)3300 / 1024; // Using 3.3V reference

What is your solution ? I not understand sorry

Connect like this

ok thx, I try

Also use any analog input other than A7

A7 is also connected to the Audio jack

You also need a potential divider to reduce the sensor output from 0-5V to 0-3.3V.

You need the potential divider in place before you make the change in the code that you posted in post #15.

You never answered kmin's question.
Do you have any resistors to make a potential divider?

I have try as you said, the values now is :
20:41:06.545 -> Analog value:77 Voltage:248mV temp:23.00^C EC:Coefficient Voltage: 257.53
20:41:06.545 -> 1.70ms/cm
20:41:06.545 -> ECsensorPin: 91
20:41:06.627 -> ECsensorPin: 91
20:41:06.627 -> ECsensorPin: 89
20:41:06.706 -> ECsensorPin: 89
20:41:06.750 -> ECsensorPin: 89
20:41:06.750 -> ECsensorPin: 90
20:41:06.831 -> ECsensorPin: 90
20:41:06.863 -> ECsensorPin: 90
20:41:06.910 -> ECsensorPin: 90
20:41:06.943 -> ECsensorPin: 89

if is in the water or it is not in water. The sensor send only this values.
This is the R

I see 3 resistors instead of 2. Can you describe your divider setup and resistance values used?