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

API for the DFRobot pH Sensors. More...

Detailed Description

This sensor family returns an analog voltage proportional to the acidity or alkalinity of a liquid – it's pH value.

This driver was developed using the DFRobot Analog pH meter and the DFRobot Analog pH Meter Pro.

Calibration instructions, taken and slightly reworded from the DFRobot wiki at: http://dfrobot.com/wiki/index.php/PH_meter%28SKU:_SEN0161%29

1) Connect equipment: the pH electrode is connected to the BNC connector on the pH meter board, and then the pH meter board is connected to the analog port 0 of the controller. When the controller gets power, you will see the blue LED on board is on.

2) Put the pH electrode into the standard solution whose pH value is 7.00. Run the dfrph example and note the pH output value. Compare the value with 7.00, and calculate the difference. This is the value you should supply to the setOffset() method.

3) Put the pH electrode into the pH standard solution whose value is 4.00. Then wait about one minute, and adjust the potentiometer on the interface board. Let the value stabilise at around 4.00. At this time,the acidic calibration has been completed and you can measure the pH value of an acidic solution.

4) According to the linear characteristics of pH electrode itself, after the above calibration,you can directly measure the pH value of the alkaline solution. If you want to get better accuracy, you can recalibrate it. Alkaline calibration use the standard solution whose pH value is 9.18. Also adjust the potentiometer and let the value stabilise at around 9.18. After this calibration, you can measure the pH value of an alkaline solution.

dfrph.jpg
// Instantiate a DFRPH sensor on analog pin A0, with an analog
// reference voltage of DFRPH_AREF
upm::DFRPH sensor(0, DFRPH_AREF);
// After calibration, set the offset (based on calibration with a pH
// 7.0 buffer solution). See the UPM sensor documentation for
// calibrations instructions.
sensor.setOffset(0.065);
// Every second, sample the pH and output it's corresponding
// analog voltage.
while (shouldRun) {
cout << "Detected volts: " << sensor.volts() << endl;
cout << "pH value: " << sensor.pH() << endl;
cout << endl;
upm_delay(1);
}

Public Member Functions

 DFRPH (int pin, float vref=5.0)
 
 ~DFRPH ()
 
void setOffset (float offset)
 
void setScale (float scale)
 
float volts ()
 
float pH (unsigned int samples=15)
 

Constructor & Destructor Documentation

DFRPH ( int  pin,
float  vref = 5.0 
)

DFRPH constructor

Parameters
pinAnalog pin to use
vrefAnalog reference voltage; default is 5.0 V
~DFRPH ( )

DFRPH destructor

Here is the call graph for this function:

Member Function Documentation

void setOffset ( float  offset)

Specifies the offset determined from calibration. The default is 0.0.

Parameters
offsetThe offset value to use

Here is the call graph for this function:

void setScale ( float  scale)

Specifies the scale determined from calibration. The default is 1.0.

Parameters
scaleThe scale value to use

Here is the call graph for this function:

float pH ( unsigned int  samples = 15)

Take a number of samples and return the detected pH value. The default number of samples is 15.

Parameters
samplesThe number of samples to average over, default 15
Returns
The pH value detected

Here is the call graph for this function:


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