API Reference

Class Members

public float S

EC in Siemens per centimeter

public float mS

EC in milli-Siemens per centimeter

public long uS

EC in micro-Siemens per centimeter

public long PPM_500

Parts per million using 500 as a multiplier

public long PPM_640

Parts per million using 640 as a multiplier

public long PPM_700

Parts per million using 700 as a multiplier

public float salinityPSU

Salinity measured practical salinity units

public float tempC

Temperature in C

public float tempF

Temperature in F

Class Functions

begin

Starts the device. You can optionally pass a non-default I2C address. You would use this if you have changed the I2C address to have more than one device connected at a time. You can also optionally pass the Wire instance to use. You might use this to have multiple I2C busses at a time, with different devices on each. You need to call Wire.begin() prior to calling this. ::begin is not implemented in the Python implementation.

Parameters

The function can be overloaded with the following parameters:

  • i2c_address the address of the device (default is 0x3C).
  • wirePort the wire instance to use.

Usage

uFire_EC::begin();
uFire_EC::begin(uint8_t i2c_address);
uFire_EC::begin(uint8_t i2c_address, TwoWire &wirePort);
// begin using default 0x3C address and default `Wire` instance
uFire_EC::begin()

// begin using an alternate I2C address
uFire_EC::begin(0x3D)

// begin by passing I2C address and Wire port
uFire_EC::begin(0x3C, Wire1)

Example

#include <uFire_EC.h>
uFire_EC ec;

Wire.begin()
ec.begin();
ec.begin(0x3d);
ec.begin(0x3c, Wire1);

Related

Returns

true if successful, false otherwise

measureEC

Starts an EC measurement.

uS, mS, S, PPM_500, PPM_640, PPM_700, salinityPSU are updated.

Parameters

The function can be overloaded with the following parameters:

  • temperature the temperature of the solution.
  • temp_constant the temperature to adjust the EC reading to.

Usage

uFire_EC::measureEC();
uFire_EC::measureEC(float temperature);
uFire_EC::measureEC(float temperature, float temperature_constant);
// take a temperature measurement without temperature compensation
uFire_EC::measureEC()

// take a temperature measurement with temperature compensation using the passed temperature
uFire_EC::measureEC(20.1)

// take a temperature measurement with temperature compensation using the passed temperature
// and also set the temperature to adjust to (this defaults to 25C)
uFire_EC::measureEC(20.1, 20)

Example

#include <uFire_EC.h>
uFire_EC ec;

float mS = ec.measureEC();

Related

Returns

EC in mS/cm, -1 on error

measureTemp

Starts a temperature measurement.

Usage

uFire_EC::measureTemp();

Example

#include <uFire_EC.h>
uFire_EC ec;

float C = ec.measureTemp();

Related

Returns

temperature in C

ALSO...

Class variables tempC and tempF are updated.

WARNING

A value of -127 means the temperature sensor is not connected.

calibrateProbe

Calibrates the connected probe to a single point. The value will be saved in the device's EEPROM and used automatically thereafter.

If a temperature is passed, temperature compensation will be used to calculate the temperature at whatever the getTempConstant temperature is set to, 25 C by default.

Parameters

  • solutionEC the EC of the calibration solution in mS/cm
  • tempC optional, the temperature in C of the calibration solution

Usage

uFire_EC::calibrateProbe(float solutionEC);
uFire_EC::calibrateProbe(float solutionEC, float tempC);

Example

#include <uFire_EC.h>
uFire_EC ec;

float offset = ec.calibrateProbe(2.0);
float offset = ec.calibrateProbe(2.0, 20.1);

Related

Returns

the single-point calibration offset

calibrateProbeLow

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

Dual point uses two measures for low and high points. It needs the measured value (reading value) and the known value (reference value). Calling calibrateProbeLow saves both the reading and reference value.

When there are high and low calibration points, the device will automatically use them to adjust readings. To disable dual-point adjustment, call reset to remove all calibration data.

If a temperature is passed, temperature compensation will be used to calculate the temperature at whatever the getTempConstant temperature is set to, 25 C by default.

Parameters

  • solutionEC the EC of the calibration solution in mS/cm
  • tempC optional, the temperature in C of the calibration solution

Usage

uFire_EC::calibrateProbeLow(float solutionEC, float tempC);

Example

#include <uFire_EC.h>
uFire_EC ec;

float lowCalibration = ec.calibrateProbeLow(0.7, 20.1);

Related

Returns

the dual-point low calibration offset

calibrateProbeHigh

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

Dual point uses two measures for low and high points. It needs the measured value (reading value) and the known value (reference value). Calling calibrateProbeLow saves both the reading and reference value.

When there are high and low calibration points, the device will automatically use them to adjust readings. To disable dual-point adjustment, call reset to remove all calibration data.

If a temperature is passed, temperature compensation will be used to calculate the temperature at whatever the getTempConstant temperature is set to, 25 C by default.

Parameters

  • solutionEC the EC of the calibration solution in mS/cm
  • tempC optional, the temperature in C of the calibration solution

Usage

uFire_EC::calibrateProbeHigh(float solutionEC, float tempC);

Example

#include <uFire_EC.h>
uFire_EC ec;

float highCalibration = ec.calibrateProbeHigh(12.88, 20.1);

Related

Returns

the dual-point high calibration offset

setI2CAddress

Changes the default I2C address. It must be between 1 and 127 (decimal).

Usage

uFire_EC::setI2CAddress(59);

Example

#include <uFire_EC.h>
uFire_EC ec;

ec.setI2CAddress(59);

Returns

none

setBlocking

The library uses delay to wait for the device to finish taking the measurement. To have all calls that use delay immediatly return, you can use this call by passing false. measureEC, measureTemp, calibrateProbe, calibrateProbeLow, and calibrateProbeHigh will all return immediately. To get updated readings, you will need to call readData. For firmware version 1 and 2, an EC reading (and calibrations) takes 750 ms and a temperature reading takes 750 ms. For firmware version 3, an EC reading takes 500 ms and a temperature reading takes 750 ms.

Parameters

  • bool true/false to use blocking

Usage

uFire_EC::setBlocking(bool blocking );

Example

#include <uFire_EC.h>
uFire_EC ec;

ec.setBlocking(false);
ec.measureEC();
// continue program immediately
ec.readData();
float ms = ec.mS;

Related

Returns

none

getBlocking

Determines if the library is set to use blocking calls instead of returning immediately. Refer to setBlocking for more details.

Parameters

none

Usage

bool blocking = uFire_EC::getBlocking();

Example

#include <uFire_EC.h>
uFire_EC ec;

bool blocking = ec.getBlocking();

Related

Returns

none

readData

Reads all the meausurement data. This is used in conjunction with setBlocking which makes all calls that delay return immediately.

Parameters

none

Usage

uFire_EC::readData();

Example

#include <uFire_EC.h>
uFire_EC ec;

ec.readData();
float ms = uFire_EC::mS;

Related

Returns

none

setDualPointCalibration

Sets all the values for dual point calibration and saves them in the devices's EEPROM. The reference values will come from the known solution, the reading values will come from the actual probe to be calibrated taking a reading in the reference solution. Each probe and each device will be different.

Parameters

  • refLow the reference low point
  • refHigh the reference high point
  • readLow the measured low point in mS/cm
  • readHigh the measured high point in mS/cm

Usage

uFire_EC::setDualPointCalibration(float refLow, float refHigh, float readLow, float readHigh);

Example

#include <uFire_EC.h>
uFire_EC ec;

ec.setDualPointCalibration(0.7, 1.0, 0.9, 2.2);

Returns

none

getCalibrateHighReference

Returns the dual-point calibration high-reference value.

Usage

uFire_EC::getCalibrateHighReference();

Example

#include <uFire_EC.h>
uFire_EC ec;

float refHigh = ec.getCalibrateHighReference();

Related

Returns

the dual-point calibration high-reference value

TIP

If there is no calibration information NaN is returned. You can check for a NaN by #include <math.h> and using isnan(). It returns true if the return result is NaN.

getCalibrateLowReference

Returns the dual-point calibration low-reference value.

Usage

uFire_EC::getCalibrateLowReference();

Example

#include <uFire_EC.h>
uFire_EC ec;

float lowRef = ec.getCalibrateLowReference();

Related

Returns

the dual-point calibration low-reference value

TIP

If there is no calibration information NaN is returned. You can check for a NaN by #include <math.h> and using isnan(). It returns true if the return result is NaN.

getCalibrateHighReading

Returns the dual-point calibration high-reading value.

Usage

uFire_EC::getCalibrateHighReading();

Example

#include <uFire_EC.h>
uFire_EC ec;

float highRef = ec.getCalibrateHighReading();

Related

Returns

the dual-point calibration high-reading value

TIP

If there is no calibration information NaN is returned. You can check for a NaN by #include <math.h> and using isnan(). It returns true if the return result is NaN.

getCalibrateLowReading

Returns the dual-point calibration low-reading value.

Usage

uFire_EC::getCalibrateLowReading();

Example

#include <uFire_EC.h>
uFire_EC ec;

float lowRead = ec.getCalibrateLowReading();

Related

Returns

the dual-point calibration low-reading value

TIP

If there is no calibration information NaN is returned. You can check for a NaN by #include <math.h> and using isnan(). It returns true if the return result is NaN.

setCalibrateOffset

Sets the single point offset value rather than having the device determine it using calibrateProbe. This value would be previously determined and is different for each probe and device combination.

Parameters

  • offset single point offset value

Usage

uFire_EC::setCalibrateOffset(float offset);

Example

#include <uFire_EC.h>
uFire_EC ec;

ec.setCalibrateOffset(0.13);

Related

Returns

none

getCalibrateOffset

Retrieves the single point offset value.

Usage

uFire_EC::getCalibrateOffset();

Example

#include <uFire_EC.h>
uFire_EC ec;

float offset = ec.getCalibrateOffset();

Related

Returns

single point offset value

TIP

If there is no calibration information NaN is returned. You can check for a NaN by #include <math.h> and using isnan(). It returns true if the return result is NaN.

reset

Resets all the stored calibration information.

Usage

uFire_EC::reset();

Example

#include <uFire_EC.h>
uFire_EC ec;

ec.reset();

Related

Returns

none

setTempConstant

Configures device to use the provided temperature constant. The effect of using temperature compensation, will apply a formula that attempts to estimate what the reading would be at another temperature, referred to as the temperature constant.

Parameters

  • temp_constant the temperature to use for compensation

Usage

uFire_EC::setTempConstant(uint8_t temp_constant);

Example

#include <uFire_EC.h>
uFire_EC ec;

ec.setTempConstant(25);
ec.measureEC(false);

Related

Returns

none

getTempConstant

Retrieves the temperature constant.

Usage

uFire_EC::getTempConstant();

Example

#include <uFire_EC.h>
uFire_EC ec;

float tempConst = ec.getTempConstant();

Related

Returns

the temperature used for compensation

setTempCoefficient

Configures device to use the provided temperature coefficient. The default value is set to 0.019, the generally accepted value for freshwater.

Parameters

  • temp_coefficient the temperature coefficient factor to use

Usage

uFire_EC::setTempCoefficient(float temp_coefficient);

Example

#include <uFire_EC.h>
uFire_EC ec;

ec.setTempCoefficient(0.019);

Related

Returns

none

getTempCoefficient

Retrieves the temperature coefficient.

Usage

uFire_EC::getTempCoefficient();

Example

#include <uFire_EC.h>
uFire_EC ec;

float tempCoef = ec.getTempCoefficient();

Related

Returns

the temperature coefficient

setTemp

Sets the temperature used by the device without using the attached temperature sensor.

Parameters

  • float tempC

Usage

uFire_EC::setTemp(tempC);

Example

#include <uFire_EC.h>
uFire_EC ec;

ec.setTemp(20.2);

Related

Returns

none

getVersion

Retrieves the hardware version of the device.

Usage

uFire_EC::getVersion();

Example

#include <uFire_EC.h>
uFire_EC ec;

uint8_t version = ec.getVersion();

Related

Returns

version of firmware

getFirmware

Retrieves the firmware version of the device.

Usage

uFire_EC::getFirmware();

Example

#include <uFire_EC.h>
uFire_EC ec;

uint8_t version = ec.getFirmware();

Related

Returns

version of firmware