Commit 5b3fb815 authored by user2684's avatar user2684 Committed by GitHub
Browse files

Adde rain/soil moisture sensor. Updated documentation (#123)

* Added new sensors, updated docs

* Added SensorRain

* Added SensorSoilMoisture

* Updated docs with how to contribute instructions
parent 040a160a
......@@ -673,6 +673,36 @@ void SensorRainGauge::onReceive(const MyMessage & message) {
}
}
/*
SensorRain
*/
// contructor
SensorRain::SensorRain(int child_id, int pin): SensorAnalogInput(child_id, pin) {
// set presentation and type and reverse
setPresentation(S_RAIN);
setType(V_RAINRATE);
setReference(DEFAULT);
setOutputPercentage(true);
setReverse(true);
setRangeMin(100);
}
/*
SensorSoilMoisture
*/
// contructor
SensorSoilMoisture::SensorSoilMoisture(int child_id, int pin): SensorAnalogInput(child_id, pin) {
// set presentation and type and reverse
setPresentation(S_MOISTURE);
setType(V_LEVEL);
setReference(DEFAULT);
setOutputPercentage(true);
setReverse(true);
setRangeMin(100);
}
/*
* SensorMQ
......@@ -1935,6 +1965,8 @@ int NodeManager::registerSensor(int sensor_type, int pin, int child_id) {
else if (sensor_type == SENSOR_ML8511) return registerSensor(new SensorML8511(child_id, pin));
else if (sensor_type == SENSOR_ACS712) return registerSensor(new SensorACS712(child_id, pin));
else if (sensor_type == SENSOR_RAIN_GAUGE) return registerSensor(new SensorRainGauge(child_id, pin));
else if (sensor_type == SENSOR_RAIN) return registerSensor(new SensorRain(child_id, pin));
else if (sensor_type == SENSOR_SOIL_MOISTURE) return registerSensor(new SensorSoilMoisture(child_id, pin));
#endif
#if MODULE_DIGITAL_INPUT == 1
else if (sensor_type == SENSOR_DIGITAL_INPUT) return registerSensor(new SensorDigitalInput(child_id, pin));
......
......@@ -175,6 +175,10 @@ enum supported_sensors {
SENSOR_ACS712,
// rain gauge sensor
SENSOR_RAIN_GAUGE,
// Rain sensor, return the percentage of rain from an attached analog sensor
SENSOR_RAIN,
// Soil moisture sensor, return the percentage of moisture from an attached analog sensor
SENSOR_SOIL_MOISTURE,
#endif
#if MODULE_DIGITAL_INPUT == 1
// Generic digital sensor, return a pin's digital value
......@@ -603,6 +607,22 @@ class SensorRainGauge: public Sensor {
long _last_report = 0;
};
/*
SensorRain
*/
class SensorRain: public SensorAnalogInput {
public:
SensorRain(int child_id, int pin);
};
/*
SensorSoilMoisture
*/
class SensorSoilMoisture: public SensorAnalogInput {
public:
SensorSoilMoisture(int child_id, int pin);
};
/*
SensorDigitalInput: read the digital input of the configured pin
*/
......
......@@ -34,7 +34,7 @@ void before() {
* Register below your sensors
*/
/*
* Register above your sensors
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment