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

DFRobot EC Meter. More...

Detailed Description

The driver was tested with the DFRobot EC Analog Sensor.

This device measure the electrical conductivity of an aqueous solution. The included probe is a K=1 model.

Calibration is somewhat complicated - see the DFRobot wiki for instructions on calibration. Functions are provided to supply the appropriate values. By default, the values used in the DFRobot arduino example are used.

wiki: https://www.dfrobot.com/wiki/index.php/Analog_EC_Meter_SKU:DFR0300

// Instantiate a DFRobot EC sensor on analog pin A0, with a ds18b20
// temperature sensor connected to UART 0, and a device index (for
// the ds1820b uart bus) of 0, and an analog reference voltage of
// 5.0.
upm::DFREC sensor(0, 0, 0, 5.0);
// Every 2 seconds, update and print values
while (shouldRun) {
sensor.update();
cout << "EC = " << sensor.getEC() << " ms/cm" << endl;
cout << "Volts = " << sensor.getVolts() << ", Temperature = " << sensor.getTemperature()
<< " C" << endl;
cout << endl;
upm_delay(2);
}

Public Member Functions

 DFREC (unsigned int apin, unsigned int uart_ow, unsigned int device_idx, float a_ref)
 
 ~DFREC ()
 
void update ()
 
void setOffset (float offset)
 
void setScale (float scale)
 
float getEC ()
 
float getVolts ()
 
float getNormalized ()
 
float getTemperature ()
 
void setThresholdMinMax (float min, float max)
 
void setThreshold1 (float thres, float scale, float offset)
 
void setThreshold2 (float thres, float scale, float offset)
 
void setThreshold3 (float scale, float offset)
 

Protected Attributes

dfrec_context m_dfrec
 

Constructor & Destructor Documentation

DFREC ( unsigned int  apin,
unsigned int  uart_ow,
unsigned int  device_idx,
float  a_ref 
)

DFREC object constructor

Parameters
apinAnalog pin to use.
uart_owThe UART that the ds10b20 temperature sensor is connected to.
device_idxThe device index of the ds18b20 sensor to use. If you only have 1 ds18b20 sensor on your DS one wire bus, you would pass 0 here.
a_refThe analog reference voltage in use
Returns
dfrec context
~DFREC ( )

DFREC object destructor

Here is the call graph for this function:

Member Function Documentation

void update ( void  )

Read the sensor status and update internal state. dfrec_update() must have been called before calling any of the other get*() functions.

Here is the call graph for this function:

void setOffset ( float  offset)

Set sensor offset. This offset is applied to the return EC value before scaling. Default is 0.0.

Parameters
offsetThe offset to apply.

Here is the call graph for this function:

void setScale ( float  scale)

Set sensor scale. The return EC value is scaled by this value before the offset is applied. Default is 1.0.

Parameters
scaleThe scale to apply.

Here is the call graph for this function:

float getEC ( )

Get computed EC (ms/cm) value from the sensor. update() must have been called prior to calling this function.

Returns
EC value in ms/cm.

Here is the call graph for this function:

float getVolts ( )

Get the measured volts from the sensor. update() must have been called prior to calling this function.

Returns
The voltage measurement.

Here is the call graph for this function:

float getNormalized ( )

Get the normalized ADC value from the sensor. update() must have been called prior to calling this function.

Returns
The normalized ADC value.

Here is the call graph for this function:

float getTemperature ( void  )

Get the measured temperature from the temperature sensor. The return value will be in Celsius.

Returns
temperature read from the sensor in Celsius.

Here is the call graph for this function:

void setThresholdMinMax ( float  min,
float  max 
)

Set the global threshold min and max values. See the DFRobot wiki for details.

Parameters
minMinimum threshold to be valid. Default 150.
maxMaximum threshold to be valid. Default 3300.

Here is the call graph for this function:

void setThreshold1 ( float  thres,
float  scale,
float  offset 
)

Set the threshold 1 values. See the DFRobot wiki for details.

Parameters
thresThreshold maximum for value section 1. Default 448.
scaleScale for value section 1. Default 6.64.
offsetOffset for value section 1. Default -64.32.

Here is the call graph for this function:

void setThreshold2 ( float  thres,
float  scale,
float  offset 
)

Set the threshold 2 values. See the DFRobot wiki for details.

Parameters
thresThreshold maximum for value section 2. Default 1457.
scaleScale for value section 2. Default 6.98.
offsetOffset for value section 2. Default -127.0.

Here is the call graph for this function:

void setThreshold3 ( float  scale,
float  offset 
)

Set the threshold 3 values. See the DFRobot wiki for details.

Parameters
scaleScale for value section 3. Default 5.3.
offsetOffset for value section 3. Default 2278.

Here is the call graph for this function:

Collaboration diagram for DFREC:
Collaboration graph
[legend]

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