upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions | Protected Member Functions | Protected Attributes

API for the EC-EZO EC Sensor. More...

Detailed Description

This driver was tested with the Atlas Scientific Electrical Conductivity kit.

This device can operate in either UART or I2C modes.

// Instantiate a ECEZO sensor on uart 0 at 9600 baud.
upm::ECEZO sensor(0, 9600, false);
// For I2C, assuming the device is configured for address 0x64 on
// I2C bus 0, you could use something like:
//
// upm::ECEZO sensor(0, 0x64, true);
while (shouldRun) {
// this will take about 1 second to complete
sensor.update();
cout << "EC " << sensor.getEC() << " uS/cm, TDS " << sensor.getTDS() << " mg/L, Salinity "
<< sensor.getSalinity() << " PSS-78, SG " << sensor.getSG() << endl;
upm_delay(5);
}

Public Member Functions

 ECEZO (unsigned int bus=0, unsigned int addrBaud=9600, bool isI2C=false)
 
 ~ECEZO ()
 
void update ()
 
void setTemperature (float temp)
 
void setKValue (float k)
 
void setSleep (bool enable)
 
float getEC ()
 
float getTDS ()
 
float getSalinity ()
 
float getSG ()
 
void calibrate (ECEZO_CALIBRATION_T cal, float ec)
 

Protected Member Functions

void setContinuous (bool enable)
 
std::string sendCommand (std::string cmd)
 
std::string read ()
 
void write (std::string data)
 

Protected Attributes

ecezo_context m_ecezo
 

Constructor & Destructor Documentation

ECEZO ( unsigned int  bus = 0,
unsigned int  addrBaud = 9600,
bool  isI2C = false 
)

ECEZO object constructor. This can use either UART (default) or I2C communications. For UART, specify the uart number as the bus parameter, the baudrate as the addrBaud parameter, and false for the isI2C parameter.

For I2C, specify the bus parameter, the I2C address as the addrBaud parameter, and true for the isI2C parameter.

Parameters
busSpecify which uart or I2C bus to use
addrBaudSpecify the baudrate if using UART, or the I2C address of the device if using I2C.
isI2Ctrue if using I2C, false if using a UART

Here is the call graph for this function:

~ECEZO ( )

ECEZO object destructor

Here is the call graph for this function:

Member Function Documentation

void update ( void  )

Query the device for a reading, parse the response, and store the read values into the device context. This function must be called prior to calling any function that returns the data, like getEC().

Here is the call graph for this function:

void setTemperature ( float  temp)

For accurate readings, the temperature of the liquid being measured should be known. This function allows you to specify the liquid's temperature (in Celsius) so that proper compensation can take place. How you measure this temperature is up to you. By default, the device will assume a temperature of 25C.

Parameters
tempThe temperature of the liquid being measured
Returns
UPM result

Here is the call graph for this function:

void setKValue ( float  k)

Set the K value of the probe being used. By default, this is 1.0. Valid values are between 0.1 and 10.0.

Parameters
kThe K value of the probe

Here is the call graph for this function:

void setSleep ( bool  enable)

Enable or disable Sleep mode.

Parameters
enableTrue to enable sleep mode, false to wake up

Here is the call graph for this function:

float getEC ( )

Retrieve the last measured Electrical Conductivity (EC) value in microsiemens. update() must have been called before calling this function.

Returns
EC value in microsiemens

Here is the call graph for this function:

float getTDS ( )

Retrieve the last measured Total Dissolved solids (TDS) value. update() must have been called before calling this function.

Returns
TDS value

Here is the call graph for this function:

float getSalinity ( )

Retrieve the last measured Salinity value. update() must have been called before calling this function.

Returns
Salinity value

Here is the call graph for this function:

float getSG ( )

Retrieve the last measured Specific Gravity (SG) value. update() must have been called before calling this function.

Returns
SG value

Here is the call graph for this function:

void calibrate ( ECEZO_CALIBRATION_T  cal,
float  ec 
)

Specify calibration data for calibrating the device. See the datasheet for details on how calibration is performed. This function provides a mechanism for clearing out, and setting calibration data.

A simple one point calibration might work as follows:

  1. CLEAR the calibration data
  2. with a dry probe, set the DRY point.
  3. with the probe immersed in a standardized solution, set the ONE parameter to the solution's known EC value in microsiemens.

A two point calibration might work as follows:

  1. CLEAR the calibration data
  2. with a dry probe, set the DRY point.
  3. with the probe immersed in the lowest EC standardized solution, set the LOW parameter to the solution's known EC value in microsiemens.
  4. with the probe immersed in the highest EC standardized solution, set the HIGH parameter to the solution's known EC value in microsiemens.
Parameters
calOne of the ECEZO_CALIBRATION_T values
ecThe EC value of the calibration fluid. This parameter is ignored when cal is either ECEZO_CALIBRATE_CLEAR or ECEZO_CALIBRATE_DRY.

Here is the call graph for this function:

void setContinuous ( bool  enable)
protected

Enable or disable "continuous" operation. In continuous operation, the device will sample and emit readings every second. The driver disables this mode by default. If you wish to use continuous mode, you will be responsible for reading and parsing the returned data yourself.

The functionality of this driver depends on continuous mode being disabled. When disabled, the driver will manually request a reading when desired via ecezo_update().

Parameters
enabletrue to enable continuous mode, false to disable.

Here is the call graph for this function:

string sendCommand ( std::string  cmd)
protected

Directly send a command to the device and optionally get a response. This is a low level function and should not be called unless you know what you are doing.

Parameters
cmda String containing the command to send to the device. See the datasheet for valid commands.
Returns
The string response, if any

Here is the call graph for this function:

string read ( )
protected

Read character data from the device. This is a low level function and should not be called unless you know what you are doing.

Returns
A string containing the data read back, if any

Here is the call graph for this function:

void write ( std::string  data)
protected

Write character data to the device. This is a low level function and should not be called unless you know what you are doing.

Parameters
dataThe string containing data to write.

Here is the call graph for this function:

Collaboration diagram for ECEZO:
Collaboration graph
[legend]

The documentation for this class was generated from the following files: