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

API for the Grove Moisture Sensor. More...

Detailed Description

Deprecated:
This class is being replaced by Moisture

UPM module for the Grove Moisture Sensor. This sensor can be used to detect the moisture content of soil or whether there is water around the sensor. As the moisture content increases, so does the value that is read. Note: this sensor is not designed to be left in soil nor to be used outdoors.

grovemoisture.jpg
// Instantiate a Grove Moisture sensor on analog pin A0
upm::GroveMoisture moisture(0);
// Values (approximate):
// 0-300, sensor in air or dry soil
// 300-600, sensor in humid soil
// 600+, sensor in wet soil or submerged in water.
// Read the value every second and print the corresponding moisture level
while (shouldRun) {
int val = moisture.value();
cout << "Moisture value: " << val << ", ";
if (val >= 0 && val < 300)
cout << "dry";
else if (val >= 300 && val < 600)
cout << "moist";
else
cout << "wet";
cout << endl;
upm_delay(1);
}

Public Member Functions

 GroveMoisture (int pin)
 
 ~GroveMoisture ()
 
int value ()
 

Constructor & Destructor Documentation

GroveMoisture ( int  pin)

Grove analog moisture sensor constructor

Parameters
pinAnalog pin to use

GroveMoisture destructor

Member Function Documentation

int value ( )

Gets the moisture value from the sensor

Returns
Moisture reading

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