upm  0.5.1
Sensor/Actuator repository for libmraa (v0.9.1)
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
Public Member Functions
GroveMoisture Class Reference

API for the Grove Moisture Sensor. More...

Detailed Description

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
// 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;
sleep(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: