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

API for the Moisture Sensor. More...

Detailed Description

UPM module for the 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.

moisture.jpg
// Instantiate a Moisture sensor on analog pin A0
upm::Moisture 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

 Moisture (int pin)
 
 ~Moisture ()
 
int value ()
 

Constructor & Destructor Documentation

Moisture ( int  pin)

Analog moisture sensor constructor

Parameters
pinAnalog pin to use
~Moisture ( )

Moisture 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: