Soil Moisture Sensor
The SoilMoisture sensor class provides access to a soil moisture sensor.
Constructor
Section titled “Constructor”SoilMoisture(options)
Section titled “SoilMoisture(options)”Creates a new SoilMoisture object instance.
SoilMoisture(options)Parameters
Section titled “Parameters”options
An object of properties used to construct the class.
sensor- The hardware connection definition.
interval(optional) - The sampling interval in milliseconds.
Instance Methods
Section titled “Instance Methods”sample()
Section titled “sample()”Returns a sample object containing the current soil moisture data.
sample()Return Value
Section titled “Return Value”An object with the following property:
moisture- A number between 0 and 1 (inclusive) that represents the sampled relative soil moisture level, with 0 being the most dry and 1 the most wet.
Examples
Section titled “Examples”const sensor = new device.sensor.SoilMoisture({ sensor: { io: device.io.Analog, pin: 33 }});
const sample = sensor.sample();console.log(`Soil moisture: ${sample.moisture * 100}%`);