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

API for the DFRobot ORP (Oxidation/Reduction Potential) Sensor. More...

Detailed Description

This library was tested with the DFRobot ORP (Oxidation/Reduction Potential) Sensor.

To calibrate:

Disconnect the sensor probe (but leave the sensor interface board connected). Then run one of the examples while holding down the 'calibrate' button on the device. Read the ORP value reported (it should be fairly small).

This value is what you should supply to setCalibrationOffset(). Then reconnect the probe to the interface board and you should be ready to go.

DO NOT press the calibrate button on the interface board while the probe is attached or you can permanently damage the probe.

// Instantiate a DFRobot ORP sensor on analog pin A0 with an analog
// reference voltage of 5.0.
upm::DFRORP sensor(0, 5.0);
// To calibrate:
//
// Disconnect the sensor probe (but leave the sensor interface board
// connected). Then run one of the examples while holding down the
// 'calibrate' button on the device. Read the ORP value reported
// (it should be fairly small).
//
// This value is what you should supply to setCalibrationOffset().
// Then reconnect the probe to the interface board and you should be
// ready to go.
//
// DO NOT press the calibrate button on the interface board while
// the probe is attached or you can permanently damage the probe.
sensor.setCalibrationOffset(0.97);
// Every second, update and print values
while (shouldRun) {
sensor.update();
cout << "ORP: " << sensor.getORP() << " mV" << endl;
cout << endl;
upm_delay(1);
}

Public Member Functions

 DFRORP (int apin, float a_ref=5.0)
 
 ~DFRORP ()
 
void update ()
 
void setOffset (float offset)
 
void setScale (float scale)
 
float getORP ()
 
void setCalibrationOffset (float offset)
 
float getVolts ()
 
float getNormalized ()
 

Protected Attributes

dfrorp_context m_dfrorp
 

Constructor & Destructor Documentation

DFRORP ( int  apin,
float  a_ref = 5.0 
)

DFRORP object constructor

Parameters
apinAnalog pin to use
a_refThe analog reference voltage in use. Default 5.0.
~DFRORP ( )

DFRORP object destructor

Here is the call graph for this function:

Member Function Documentation

void update ( void  )

Read the sensor status an update internal state. update() must have been called before calling getORP(), getNormalized(), or getVolts().

Here is the call graph for this function:

void setOffset ( float  offset)

Set sensor offset. This offset is applied to the return ORP 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 ORP 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 getORP ( )

Get computed ORP (in millivolts) value from the sensor. update() must have been called prior to calling this function.

Returns
ORP value in millivolts

Here is the call graph for this function:

void setCalibrationOffset ( float  offset)

Set the calibration offset for the device. This is determined by disconnecting the sensor probe (but leaving the sensor interface board connected). Then run one of the examples while holding down the 'calibrate' button on the device. Read the ORP value reported.

This (low) ORP value is what you should supply to this function. Then reconnect the probe to the interface board and you should be ready to go.

DO NOT press the calibrate button on the interface board while the probe is attached or you can permanently damage the probe.

Parameters
offsetThe ORP offset obtained during calibration.

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:

Collaboration diagram for DFRORP:
Collaboration graph
[legend]

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