2014-12-02 16:45:40 -07:00
|
|
|
/*
|
|
|
|
* Author: Jon Trulson <jtrulson@ics.com>
|
|
|
|
* Copyright (c) 2014 Intel Corporation.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
|
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
|
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <mraa/aio.h>
|
|
|
|
|
|
|
|
namespace upm {
|
2015-04-09 17:34:46 -07:00
|
|
|
/**
|
2016-09-12 15:25:45 -07:00
|
|
|
* @brief Moisture Sensor library
|
2015-04-09 17:34:46 -07:00
|
|
|
* @defgroup grovemoisture libupm-grovemoisture
|
2015-06-24 13:39:09 -07:00
|
|
|
* @ingroup seeed analog liquid eak hak
|
2015-04-09 17:34:46 -07:00
|
|
|
*/
|
2014-12-02 16:45:40 -07:00
|
|
|
|
|
|
|
/**
|
2016-09-12 15:25:45 -07:00
|
|
|
* @library moisture
|
|
|
|
* @sensor moisture
|
2016-12-15 15:15:21 -08:00
|
|
|
* @comname Analog Moisture Sensor
|
2016-09-12 15:25:45 -07:00
|
|
|
* @altname Grove Moisture Sensor
|
2015-04-09 17:34:46 -07:00
|
|
|
* @type liquid
|
|
|
|
* @man seeed
|
|
|
|
* @con analog
|
2015-06-24 13:39:09 -07:00
|
|
|
* @kit eak hak
|
2015-04-09 17:34:46 -07:00
|
|
|
*
|
2016-09-12 15:25:45 -07:00
|
|
|
* @brief API for the Moisture Sensor
|
2014-12-02 16:45:40 -07:00
|
|
|
*
|
2016-09-12 15:25:45 -07:00
|
|
|
* UPM module for the Moisture Sensor.
|
2014-12-02 16:45:40 -07:00
|
|
|
* 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.
|
2015-08-09 22:51:25 +03:00
|
|
|
* Note: this sensor is not designed to be left in soil
|
2014-12-02 16:45:40 -07:00
|
|
|
* nor to be used outdoors.
|
|
|
|
*
|
2016-09-16 12:43:34 -07:00
|
|
|
* @image html moisture.jpg
|
2016-09-12 15:25:45 -07:00
|
|
|
* @snippet moisture.cxx Interesting
|
2014-12-02 16:45:40 -07:00
|
|
|
*/
|
2016-09-12 15:25:45 -07:00
|
|
|
class Moisture {
|
2014-12-02 16:45:40 -07:00
|
|
|
public:
|
|
|
|
/**
|
2016-09-12 15:25:45 -07:00
|
|
|
* Analog moisture sensor constructor
|
2014-12-02 16:45:40 -07:00
|
|
|
*
|
2015-08-09 22:51:25 +03:00
|
|
|
* @param pin Analog pin to use
|
2014-12-02 16:45:40 -07:00
|
|
|
*/
|
2016-09-12 15:25:45 -07:00
|
|
|
Moisture(int pin);
|
2014-12-02 16:45:40 -07:00
|
|
|
/**
|
2016-09-12 15:25:45 -07:00
|
|
|
* Moisture destructor
|
2014-12-02 16:45:40 -07:00
|
|
|
*/
|
2016-09-12 15:25:45 -07:00
|
|
|
~Moisture();
|
2014-12-02 16:45:40 -07:00
|
|
|
/**
|
2015-08-09 22:51:25 +03:00
|
|
|
* Gets the moisture value from the sensor
|
2014-12-02 16:45:40 -07:00
|
|
|
*
|
2015-08-09 22:51:25 +03:00
|
|
|
* @return Moisture reading
|
2014-12-02 16:45:40 -07:00
|
|
|
*/
|
|
|
|
int value();
|
|
|
|
|
|
|
|
private:
|
|
|
|
mraa_aio_context m_aio;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|