API for the EC-EZO EC Sensor.
More...
This driver was tested with the Atlas Scientific Electrical Conductivity kit.
This device can operate in either UART or I2C modes.
while (shouldRun) {
cout << "EC " << sensor.getEC() << " uS/cm, TDS " << sensor.getTDS() << " mg/L, Salinity "
<< sensor.getSalinity() << " PSS-78, SG " << sensor.getSG() << endl;
upm_delay(5);
}
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
-
bus | Specify which uart or I2C bus to use |
addrBaud | Specify the baudrate if using UART, or the I2C address of the device if using I2C. |
isI2C | true if using I2C, false if using a UART |
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().
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
-
temp | The temperature of the liquid being measured |
- Returns
- UPM result
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
-
k | The K value of the probe |
void setSleep |
( |
bool |
enable | ) |
|
Enable or disable Sleep mode.
- Parameters
-
enable | True to enable sleep mode, false to wake up |
Retrieve the last measured Electrical Conductivity (EC) value in microsiemens. update() must have been called before calling this function.
- Returns
- EC value in microsiemens
Retrieve the last measured Total Dissolved solids (TDS) value. update() must have been called before calling this function.
- Returns
- TDS value
Retrieve the last measured Salinity value. update() must have been called before calling this function.
- Returns
- Salinity value
Retrieve the last measured Specific Gravity (SG) value. update() must have been called before calling this function.
- Returns
- SG value
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:
- CLEAR the calibration data
- with a dry probe, set the DRY point.
- 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:
- CLEAR the calibration data
- with a dry probe, set the DRY point.
- with the probe immersed in the lowest EC standardized solution, set the LOW parameter to the solution's known EC value in microsiemens.
- with the probe immersed in the highest EC standardized solution, set the HIGH parameter to the solution's known EC value in microsiemens.
- Parameters
-
cal | One of the ECEZO_CALIBRATION_T values |
ec | The EC value of the calibration fluid. This parameter is ignored when cal is either ECEZO_CALIBRATE_CLEAR or ECEZO_CALIBRATE_DRY. |
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
-
enable | true to enable continuous mode, false to disable. |
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
-
cmd | a String containing the command to send to the device. See the datasheet for valid commands. |
- Returns
- The string response, if any
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
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
-
data | The string containing data to write. |
The documentation for this class was generated from the following files: