Example Code for Arduino-Calibration for Higher Accuracy

Last revision 2026/01/12

Calibration is generally required to improve measurement accuracy in practical use due to quality differences among probes. You can follow the steps outlined in this document.

The steps are as follows:

  1. Connect the EC probe to Arduino and upload the calibration program.
  2. Immerse the EC probe in a calibration solution with known conductivity, it is recommended to use a 1413 us/cm electrical conductivity standard solution for calibration.
    If the complimentary calibration solution runs out, purchase or prepare it according to the appendix. See the appendix for detailed specification.
  3. Check the probe and shake it slightly to remove air bubbles so as to avoid interference
  4. Input C calibration solution electrical conductivity in the serial monitor for calibration. For example, C 1413 means calibrating the probe in 1413 us/cm electrical conductivity standard solution.
  5. Record the calibration value K returned from the serial monitor. K should be close to 1.0. Please check the calibration steps if there's too much deviation.
  6. Replace K with the actual measured data in ec.setCalibration(K value) and re-upload the program to improve the accuracy of the measurement results.

It is recommended to recalibrate to maintain high accuracy when the probe is replaced or the ADC reference voltage changes.
In practical use, it is recommended to write a program to store calibration values using Arduino built-in EEPROM or external SD card and read them automatically when it is powered on.

Hardware Preparation

  • DFRduino UNO R3 x 1
  • Electrical Conductivity Probe x 1
  • Electrical Conductivity Signal Conversion Board x 1
  • PT1000 RTD Signal Conversion Board x 1
  • Electrical Conductivity Calibration Solution 1413us/cm x 1
  • Jumper wires
  • Tested Solution

Software Preparation

Probe - Signal Conversion Board

Probe Wire Signal Conversion Board
S+ (EC) Electrical Conductivity Board S+
S- (EC) Electrical Conductivity Board S-
TEMP PT1000 Board T+
TEMP PT1000 Board T-

Signal Conversion Board - Arduino

Signal Conversion Board Arduino UNO
Electrical Conductivity Board A1
PT1000 Board A2

Other Preparation Work

  1. Immerse the EC probe in a calibration solution with known conductivity, it is recommended to use a 1413 us/cm electrical conductivity standard solution for calibration.
    If the complimentary calibration solution runs out, purchase or prepare it according to the appendix. See the appendix for detailed specification.
  2. Check the probe and shake it slightly to remove air bubbles so as to avoid interference

Sample Code

#include "DFRobot_ECPRO.h"

#define EC_PIN A1
#define TE_PIN A2

DFRobot_ECPRO ec;
DFRobot_ECPRO_PT1000 ecpt;

uint16_t EC_Voltage, TE_Voltage;
float Conductivity, Temp;

void setup()
{
  Serial.begin(115200);

  ec.setCalibration(1);
  Serial.println("Default Calibration K=" + String(ec.getCalibration()));
  Serial.println("Immerse the probe in the calibration solution and enter \"C + conductivity\" to calibrate");
  Serial.println("e.g. \"C 1413\"");

  delay(2000);
}

void loop()
{
  EC_Voltage = (uint32_t)analogRead(EC_PIN) * 5000 / 1024;
  //TE_Voltage = (uint32_t)analogRead(TE_PIN) * 5000 / 1024;
  TE_Voltage = 783;

  Temp = ecpt.convVoltagetoTemperature_C((float)TE_Voltage / 1000);
  Conductivity = ec.getEC_us_cm(EC_Voltage, Temp);

  Serial.print("EC_Voltage: " + String(EC_Voltage) + " mV\t");
  Serial.print("Conductivity: " + String(Conductivity) + " us/cm\t");
  Serial.print("TE_Voltage: " + String(TE_Voltage) + " mV\t");
  Serial.println("Temp: " + String(Temp) + " ℃");

  delay(1000);
}

void serialEvent()
{
  String args = Serial.readStringUntil('\n');
  if (args[0] == 'C')
  {
    args.remove(0, 2);
    float calSoluion=args.toFloat();
    ec.setCalibration(ec.calibrate(EC_Voltage,calSoluion));
    Serial.print("calSoluion: " + String(calSoluion)+"\t");
    Serial.println("calK: "+ String(ec.getCalibration(),6));
    delay(5000);
  }
  else
    Serial.println("command error");
}

Result

Record the calibration value K returned from the serial monitor. K should be close to 1.0.

Was this article helpful?

TOP