NAV Navbar
Logo

Introduction

Measure Electrical Conductivity in Siemens, Total Dissolved Solids in PPM, Salinity in PSU and PPT.

Monitor hydroponic nutrient levels, salinity levels in aquariums or the ocean, saltwater pools, soil salinity, water quality etc.

It uses the standard Arduino Wire library to interface with the device. It’s operating principle is based on sending a very short-duration DC pulse from one probe pin and measuring the conductivity on the other pin. The conductivity is then converted to a temperature compensated Siemen. Salinity is also derived from the measure and is in PSU, PPT, and PPM.

Characteristics

Connections

I2C Connections

Making the connections to the device is as follows:

EC Salinity Probe Master device
GND GND
SCL SCL
SDA SDA
VCC 2.7 - 5V

Temperature Probe Connections

The temperature probe should be connected as follows:

EC Salinity Probe Temperature Probe
+ VCC (red)
D Data (yellow)
- GND (black)

EC Probe Connections

The EC probe has two pins and can be connected either way.

Probe Selection

Any 2-electrode probe can be attached to the device.

A probe with a K constant of

Calibration

#include <ECSalinity.h>
EC_Salinity ec;
float calibrationSolution_mS = 2.77;

ec.setK(10.0);
ec.calibrateProbe(calibrationSolution_mS, ec.tempCoefEC);

When the device is powered for the first time, it will be uncalibrated. There are two calibration options: single and dual or double point. Single point determines a percent difference between actual readings and expected readings, then uses it to adjust the readings. Double point uses two points, a high and low, to determine the adjustment to make. The choice of single or double depends on the expected use. A small range might be better measured by single point calibration whereas a large range may be more accurate with double point.

Before any measurements can be made, to include measurements to calibrate the probe, the cell constant (K) must be specified. This number is typically 0.1, 1.0, or 10.0. The exact value may be found on the probe itself (9.988 for example). After K has been set, you can expect to see values being returned. It will not be accurate and must be calibrated.

To begin the single point calibration process, place the thermometer and probe in a calibration solution then call the calibrateProbe function.

For best results, the probe should be cleaned with distilled water and then placed in the solution for 5-10 minutes before the probe is used. It shouldn’t be placed on the bottom or side of the solution container. Note that any turbidity, air bubbles, large particles, etc will effect readings. An unstable temperature will decrease accuracy as well.

When calibrating the probe, it is important to consider the expected temperature range. EC measurements are very temperature dependent, effecting the results by approximately 2% per degree C. The probe should be calibrated at the median expected temperature.

Likewise, the probe should be calibrated in the median expected EC range. For example, if you are planning to measure the salinity of an aquarium, you might expect readings ±5 from 35PPT (equivalent to 53mS). So a 53mS solution for calibration would be appropriate, whereas a hydroponic calibration might be 2.77mS or lower.

Another consideration is the placement of the probe. When the probe sends out a pulse of electricity, it leaves the probe in 360 degrees. If it is near a metal surface, you will experience fringing effects. The probe should be calibrated in an environment as similar as possible to the location it will be deployed in.

Single Point

float solutionEC = 53.0;
ec.calibrationProbe(solutionEC, ec.tempCoefSalinity);

After K has been set, you can calibrate the probe using a single point. For this method of calibrating, submerge the probe and wait for the readings to stabilize. Then call calibrateProbe. The calibration information will be stored in EEPROM and is the percent difference from the measured value and the expected value.

Dual Point

Two calibration solutions are required, the low and high values you expect to measure between.

float readingLow = 51.0;
float readingHigh = 60.2;
ec.setDualPointCalibration(50.0, 58.0, readingLow, readingHigh);
ec.useDualPoint(true);
  1. Determine the lowest and highest measurement you expect in mS. For example, to measure salinity in an aquarium, the lowest level you would expect to measaure might be 30 PPT and the highest might be 38 PPT. These points are referred to as referenceLow and referenceHigh
  2. Using the calibrated probe and a calibration solution at referenceLow, call measureEC and see what the actual reading is. Do the same for referenceHigh. These readings are referred to as readingLow and readingHigh. As an example, the readingLow might be 27 and readingHigh might be 40.
  3. Call setDualPointCalibration to save the values to the device, then enable dual point calibration. By default, the device does not use dual point. A call to useDualPoint must be made to enable it each time the device is powered.
float solutionECLow = 53.0;
float solutionECHigh = 58.0;
ec.calibrateProbeLow(solutionECLow, ec.tempCoefSalinity);
ec.calibrateProbeHigh(solutionECHigh, ec.tempCoefSalinity);

calibrateProbeLow and calibrateProbeHigh can be used to programatically determine the values.

getCalibrateHigh and getCalibrateLow can be used to get the currently set reference values.

Each call to measureEC will use the calibration to adjust the reading. It can be disabled by ec.useDualPoint(false);

Use

float tempC = ec.measureTemp();

Once the probe has been calibrated, a reading can be taken. The device will use the most recent temperature measurement obtained from measureTemp if temperature compensation is enabled.The probe should be placed in the solution to be measured and measureEC called to start a measurement.

After the measurement is taken, the following class variables are updated:

Temperature Coefficients

float pureWaterCompensation = 0.0455;
ec.measureEC(pureWaterCompensation);
ec.measureEC();
ec.measureSalinity();

If the solution to be measured is saltwater, use measureSalinity(), if it is freshwater, use measureEC(). A custom temperature coefficient can be used by passing it to measureEC().

Temperature Compensation

byte tempConstant = 25;
ec.setTempConstant(tempConstant);

ec.setTempConstant(0xFF);

To set the temperature used for compensation, call setTempConstant() and pass the temperature to use. To use the actual temperature, pass 0xFF.

Accuracy

ec.setAccuracy(21);

The accuracy of the device can be adjusted by modifying setAccuracy. By default, 9 measurements are taken. A running median sort is applied and the middle third of the nine measurements are averaged together to provide the final result. Any number of measurements can be taken as long as it is evenly divisible by 3. The least number of measures possible is 3.

Measurement Time

Each individual EC measurement takes 10ms. If the default accuracy is set to 9, a call to measureEC will return in about 90ms. A temperature measurement takes 750ms.

Summary

Members Descriptions
defineEC_SALINITY EC Salinity probe I2C address
defineEC_MEASURE_EC Command to start an EC measure
defineEC_MEASURE_TEMP Command to measure temperature
defineEC_CALIBRATE_PROBE Command to calibrate the probe
defineEC_CALIBRATE_LOW Command to calibrate the low point of the probe
defineEC_CALIBRATE_HIGH Command to calibrate the high point of the probe
defineEC_VERSION_REGISTER version register
defineEC_MS_REGISTER mS register
defineEC_TEMP_REGISTER temperature in C register
defineEC_K_REGISTER cell constant register
defineEC_SOLUTION_REGISTER calibration solution register
defineEC_TEMPCOEF_REGISTER temperatue coefficient register
defineEC_CALIBRATE_REFHIGH_REGISTER reference low register
defineEC_CALIBRATE_REFLOW_REGISTER reference high register
defineEC_CALIBRATE_READHIGH_REGISTER reading low register
defineEC_CALIBRATE_READLOW_REGISTER reading high register
defineEC_CALIBRATE_OFFSET_REGISTER caliration offset
defineEC_SALINITY_PSU Salinity register
defineEC_TEMP_COMPENSATION_REGISTER temperature compensation register
defineEC_ACCURACY_REGISTER accuracy register
defineEC_CONFIG_REGISTER config register
defineEC_TASK_REGISTER task register
defineEC_EC_MEASURMENT_TIME delay between EC measurements
defineEC_TEMP_MEASURE_TIME delay for temperature measurement
defineEC_CALIBRATE_DELAY delay between EC calibration measurements
defineEC_DUALPOINT_CONFIG_BIT dual point config bit
defineEC_TEMP_COMPENSATION_CONFIG_BIT temperature compensation config bit
definePSU_TO_PPT_CONVERSION conversion factor for PSU to PPT
classEC_Salinity EC Salinity Class

Members

defineEC_SALINITY

EC Salinity probe I2C address

defineEC_MEASURE_EC

Command to start an EC measure

defineEC_MEASURE_TEMP

Command to measure temperature

defineEC_CALIBRATE_PROBE

Command to calibrate the probe

defineEC_CALIBRATE_LOW

Command to calibrate the low point of the probe

defineEC_CALIBRATE_HIGH

Command to calibrate the high point of the probe

defineEC_VERSION_REGISTER

version register

defineEC_MS_REGISTER

mS register

defineEC_TEMP_REGISTER

temperature in C register

defineEC_K_REGISTER

cell constant register

defineEC_SOLUTION_REGISTER

calibration solution register

defineEC_TEMPCOEF_REGISTER

temperatue coefficient register

defineEC_CALIBRATE_REFHIGH_REGISTER

reference low register

defineEC_CALIBRATE_REFLOW_REGISTER

reference high register

defineEC_CALIBRATE_READHIGH_REGISTER

reading low register

defineEC_CALIBRATE_READLOW_REGISTER

reading high register

defineEC_CALIBRATE_OFFSET_REGISTER

caliration offset

defineEC_SALINITY_PSU

Salinity register

defineEC_TEMP_COMPENSATION_REGISTER

temperature compensation register

defineEC_ACCURACY_REGISTER

accuracy register

defineEC_CONFIG_REGISTER

config register

defineEC_TASK_REGISTER

task register

defineEC_EC_MEASURMENT_TIME

delay between EC measurements

defineEC_TEMP_MEASURE_TIME

delay for temperature measurement

defineEC_CALIBRATE_DELAY

delay between EC calibration measurements

defineEC_DUALPOINT_CONFIG_BIT

dual point config bit

defineEC_TEMP_COMPENSATION_CONFIG_BIT

temperature compensation config bit

definePSU_TO_PPT_CONVERSION

conversion factor for PSU to PPT

class EC_Salinity

Members

S

public floatS

EC in Siemens

mS

public floatmS

EC in milli-Siemens

uS

public floatuS

EC in micro-Siemens

PPM_500

public longPPM_500

Parts per million using 500 as a multiplier

PPM_640

public longPPM_640

Parts per million using 640 as a multiplier

PPM_700

public longPPM_700

Parts per million using 700 as a multiplier

salinityPSU

public floatsalinityPSU

Salinity measured practical salinity units

salinityPPT

public floatsalinityPPT

Salinity measured parts per thousand

salinityPPM

public floatsalinityPPM

Salinity measured parts per million

tempC

public floattempC

Temperature in C

tempF

public floattempF

Temperature in F

EC_Salinity

publicEC_Salinity()

Class constructor.

~EC_Salinity

public~EC_Salinity()

Class destructor.

measureEC

public floatmeasureEC(float tempCoefficient)

Starts an EC measurement.

The device starst an EC measurement. The accuracy can be specified in EC_Salinity::setAccuracy.

Parameter Description
tempCoefficient the coefficient used to compensate for temperature.

uS, mS, S, tempC, tempF, PPM_500, PPM_640, PPM_700, salinityPPM, salinityPPT, and salinityPSU are updated

PPM is not valid if salinity is being measured

Returns: milli-Siemens

measureEC

public floatmeasureEC()

Convenience function.

Calls EC_Salinity::measureEC(EC_Salinity::tempCoefEC) Returns: salinity in PSU

measureSalinity

public floatmeasureSalinity()

Convenience function.

Calls EC_Salinity::measureEC(EC_Salinity::tempCoefSalinity) Returns: salinity in PSU

measureTemp

public floatmeasureTemp()

Starts a temperature measurement.

tempC and tempF are updated

A value of -127 means the device is not connected.

Returns: temperature in C

calibrateProbe

public voidcalibrateProbe(float solutionEC,float tempCoef)

Calibrates the connected probe and saves the result in EEPROM.

Parameter Description
solutionEC the EC of the calibration solution in mS

tempCoef | the coefficient used to calibrate the probe

cell constant will be saved in the device’s EEPROM and used automatically thereafter

calibrateProbeLow

public voidcalibrateProbeLow(float solutionEC,float tempCoef)

Calibrates the dual-point values for the low reading and saves them in the devices’s EEPROM.

Parameter Description
solutionEC the EC of the calibration solution in mS

tempCoef | the coefficient used to calibrate the probe

calibrateProbeHigh

public voidcalibrateProbeHigh(float solutionEC,float tempCoef)

Calibrates the dual-point values for the high reading and saves them in the devices’s EEPROM.

Parameter Description
solutionEC the EC of the calibration solution in mS

tempCoef | the coefficient used to calibrate the probe

setDualPointCalibration

public voidsetDualPointCalibration(float refLow,float refHigh,float readLow,float readHigh)

Sets all the values for dual point calibration and saves them in the devices’s EEPROM.

Parameter Description
refLow the reference low point

refHigh | the reference high point

readLow | the measured low point in mS

readHigh | the measured high point in mS

setK

public voidsetK(float k)

Updates the device with a new cell constant and saves it in EEPROM.

Parameter Description
k the new cell constant

getK

public floatgetK()

Retrieves the cell constant from the device.

Returns: the new cell constant

setAccuracy

public voidsetAccuracy(byte b)

Configures the accuracy of the device.

The device maintains a running median of values. It throws out the top and bottom third of values, then averages the middle third together to return a single value. The accuracy incrases with a high number. It must be evenly divisible by 3.

Parameter Description
b accuracy of the device

getAccuracy

public bytegetAccuracy()

Retrieves the accuracy configuration of the device.

Returns: accuracy

reset

public voidreset()

Resets all the stored calibration information.

setTempConstant

public voidsetTempConstant(byte b)

Configures device to use the provided temperature constant.

By default, the temperature constant is set to 0xFF which instructs the actual temperature to be used for temperature compensation, however any number can be specified. To use the actual temperature, restore the value to 0xFF.

Parameter Description
b the temperature to use for compensation

getTempConstant

public bytegetTempConstant()

Retrieves the temperature constant.

Returns: the temperature to used for compensation

useTemperatureCompensation

public voiduseTemperatureCompensation(bool b)

Configures device to use temperature compensation or not.

Parameter Description
b true for compensation, false to not use it

usingTemperatureCompensation

public boolusingTemperatureCompensation()

Determines if temperature compensation is being used.

Returns: true if using compensation, false otherwise

useDualPoint

public voiduseDualPoint(bool b)

Configures device to use dual-point calibration.

Parameter Description
b true for yes, false for no

usingDualPoint

public boolusingDualPoint()

Determines if dual point calibration is being used.

Returns: true if using compensation, false otherwise

getCalibrateHigh

public floatgetCalibrateHigh()

Retrieves the dual-point calibration high value.

Returns: the dual-point calibration high value

getCalibrateLow

public floatgetCalibrateLow()

Retrieves the dual-point calibration low value.

Returns: the dual-point calibration low value

getCalibrateHighReading

public floatgetCalibrateHighReading()

Retrieves the dual-point calibration reading high value.

Returns: the dual-point calibration high value

getCalibrateLowReading

public floatgetCalibrateLowReading()

Retrieves the dual-point calibration reading low value.

Returns: the dual-point calibration low value

setCalibrateOffset

public voidsetCalibrateOffset(float offset)

Sets the single point offset value.

Parameter Description
offset single point offset value

getCalibrateOffset

public floatgetCalibrateOffset()

Retrieves the single point offset value.

Returns: single point offset value

getVersion

public bytegetVersion()

Retrieves the firmware version of the device.

Returns: version of firmware

Generated by Moxygen