upm  1.3.0
Sensor/Actuator repository for libmraa (v1.7.0)
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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.

// Instantiate a Moisture sensor on analog pin A0
upm::Moisture* moisture = new upm::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";
cout << "wet";
cout << endl;

Public Member Functions

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

Constructor & Destructor Documentation

Moisture ( int  pin)

Analog moisture sensor constructor

pinAnalog pin to use
~Moisture ( )

Moisture destructor

Member Function Documentation

int value ( )

Gets the moisture value from the sensor

Moisture reading

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