Introduction

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

Monitor hydroponic nutrient levels, salinity in aquariums, pools, or soil.

Characteristics

  • EC range: ~0.06 - ~200 mS depending on probe
  • Salinity range: 2 - 42
  • Accuracy: ± 5%
  • Temperature Precision: 0.05 C
  • Temperature range: -2 - 35C
  • Interface: I2C
  • Current use: ~10mA peak, low idle current ~1mA
  • Voltage range: 3.3 - 5.5V

Connections

I2C Connections

The connection to the device is as follows:

EC Salinity Probe Master device
GND GND
SCL SCL
SDA SDA
3.3/5v 3.3 - 5V

Temperature Probe Connections

The temperature probe comes with a 3-wire header; any 3-wire DS18B20 will work. The VCC pin is labeled with a triangle:

EC Salinity Probe Temperature Probe
▲ (VCC
(Data) (pin 2)
(GND) (pin 3)

A standalone DS18B20 can be directly connected to the board, no resistor is required.

I2C Bus Pull-ups

Each device comes with 4.7k resistor pullups on the I2C bus. They pass through a 3-pad solder paste jumper. The outer pads are connected to the middle by thin traces. To disable the pullups, use a utility knife to cut both traces. To re-enable the pullups, connect all three pads together with solder.

solder paste jumper

EC Probe Connections

A board with a BNC connector is available and the preferred connection method. For probes that use an alternate connector, the board can be purchased with a two-pin header instead of the BNC. Modification of the probe's wires may be needed and isn't recommended unless you know what you are doing.

Probe Selection

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

A probe with a K cell-constant of:

  • 0.1K can measure from 0.06 - 199.9 uS
  • 1K from 0 - 1999 uS
  • 10K from 1 - 200 mS

Getting Started

To start developing for the device, you need to install a library for your board/platform.

  • Arduino IDE: go to the library manager (Sketch / Include Library / Manage Libraries...) and search for EC Salinity.

  • PlatformIO: install the library using the library manager (PlatformIO / PlatformIO Home / Libraries) and search for EC Salinity.

  • Particle.io: search for EC_Salinity in the Libraries section of the IDE.

  • MicroPython: clone the GitHub repo. In the python/MicroPython directory, you will find the files for various boards and their accompanying README files with instructions.

  • Raspberry Pi: clone the GitHub repo. In the python/RaspberryPi directory, you will find the files for various boards and their accompanying README files with instructions. Be sure to read the section below for instructions.

  • Rust: Download/install/documentation for the crate

Raspberry Pi

Before you can run anything, you will need to enable software I2C, since the Pi's hardware implementation has a clock-stretching bug that will prevent it from working with the probe (or any other device that uses clock-stretching).

  1. sudo nano /boot/config.txt and scroll to the bottom

  2. Add dtoverlay=i2c-gpio,i2c_gpio_sda=<pin>,i2c_gpio_scl=<pin> replacing <pin> with whatever pin you'd like to use. Refer here for the pin functions, you will need to use the orange GPIO xx labels in the picture to locate the pins.

  3. ctrl + x to exit, y to save, and enter to confirm the filename.

  4. Reboot

The shell Example

An interactive shell interface is provided with all frameworks and is a quick and easy way to get started using the device. You will find the equivalent commands in the code area to the right when applicable. Upload it to your master device, start a serial terminal and you will be presented with a > prompt where you can enter commands and receive a response, similar to a shell command line or REPL. It is often quicker to experiment with things this way rather than rewriting, compiling, and uploading new versions every time.

Changing the I2C Address

If needed, the I2C address can be changed programatically by calling setI2CAddress. The device will permanently change the address and continue to use it after a power reset. If you forget the new address, you will need to use an I2C bus scanner to locate it again.

Class Initialization

  • C++: There are several class constructors available.
    • Default: EC_Salinity ec;
    • Custom I2C Address: EC_Salinity ec(0x4C);
    • ESP32 I2C Pins (SDA, SCL): EC_Salinity ec(19, 23);
    • ESP32 I2C Pins and I2C Address: EC_Salinity ec(19, 23, 0x4C);
  • Raspberry Pi Python: Always pass the I2C address in the constructor, 0x3f by default. 3 indicates the third I2C device (/dev/i2c-3).
    • Default: ec = ecsalinity(0x3c, 3)
  • MicroPython: Always pass the I2C address in the constructor, 0x3c by default. -1 indicates to use software I2C, and then specify the SCL and SDA pins.
    • Default: ec = ecsalinity(0x3c, -1, 5, 4)

Calibration

When the device is powered for the first time, it will be uncalibrated. There are two calibration options: single and dual point. Single point determines a percent difference between actual readings and expected readings, then uses it to make adjustments. Dual point uses two points, a high and low, to determine the adjustment to make. The choice of single or dual 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 dual 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). See setK.

After setting K, you can optionally calibrate the probe to determine the reading it returns when it is dry. calibrateDry will record the measurment and automatically be used for subsequent measurements. If the value is equal to or less than the dry value, -1 is returned. This indicates the probe is dry or also if it is unconnected.

For best results, the probe should be cleaned with distilled water or vinegar and then placed in the solution for 5-10 minutes before measurements are taken. It shouldn't be placed on the bottom or side of the solution container. Any turbidity, air bubbles, large particles, or unstable temperature will effect readings.

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.0mS 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 metal, 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

For this method of calibration, submerge the probe and wait for the readings to stabilize. Then call calibrateProbe. The calibration information will be stored in EEPROM.

Dual Point

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

  1. Determine the lowest and highest measurement you expect. For example, the lowest level you might measure would be 50 mS and the highest might be 58 mS. These points will be referred to as referenceLow and referenceHigh
  2. Put the EC probe in a calibration solution at referenceLow and wait for readings to stabilize, then call calibrateProbeLow. Do the same for referenceHigh by calling calibrateProbeHigh.
  3. By default, the device does not use dual point, even if the values are provided. A call to useDualPoint must be made to enable it. It will be saved in the configuration and used automatically.

You can also set all four values directly using setDualPointCalibration.

Use

Once the probe has been calibrated, a reading can be taken.

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

Temperature Compensation

Conductivity naturally changes with temperature. When the temperature drops, the solution condences, molecules move closer together and allow a charge to more easily pass. The opposite occurs when the temperature increases.

Temperature compensation is used to calculate what the measured conductivity would be if it were measured at a different temperature. This is just an approximation and is determined by the temperature coefficient as explained below.

To set the temperature used for compensation, call setTempConstant and pass the temperature to use; the temperature probe must be connected for this measurement. Calling measureEC or measureSalinity will also call measureTemp before taking a measurement if usingTemperatureCompensation has been set to true.

The values passed to setTempConstant and useTemperatureCompensation will be saved and used automatically.

Using Temperature from Another Device

If there is an alternate source of temperature information, it can be provided to the device by calling setTemp. It should be called before each call to measureEC or measureSalinity. Be sure to use the longform measureEC measureEC(EC_Salinity::tempCoefEC, false).

Temperature Coefficients

Temperature coefficients are used in compensating for temperature. Values vary depending on the type of solution being measured and the source providing the numbers. In common usage, ultra-pure, freshwater, and saltwater have distinct values.

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.

Measurement Time

Each EC measurement takes 250ms. A temperature measurement takes 750ms.

Isolation and Interference

Using any water quality measuring probe with another probe will likely cause interference. There are many factors that determine the amount, to include the grounding of the solution, the type of probes, the solution itself, chemical reactions that may take place, etc. The EC-Salinity board doesn't provide a path from the probe's electrodes to ground, minimizing the interference, however it doesn't mean it has zero impact. The only way to ensure interference doesn't cause faulty measurements is to isolate the circuit. uFire's ISO board has been designed to work with both the EC-Salinity board and the ISE Probe Interface.

More Help

If you have any questions, find a bug, or have any suggestions, go to this project's GitHub page and submit an Issue or Pull Request. Or you can send an email to questions@ufire.co.