Skip to main content

Meadow.Foundation.Grove.Sensors.Environmental.WaterSensor

WaterSensor
StatusStatus badge: working
Source codeGitHub
NuGet packageNuGet Gallery for Meadow.Foundation.Grove.Sensors.Environmental.WaterSensor

Code Example

WaterSensor waterSensor;

public override Task Initialize()
{
Resolver.Log.Info("Initialize...");

waterSensor = new WaterSensor(Device.Pins.A01);

waterSensor.Subscribe(WaterSensor.CreateObserver(
h => Resolver.Log.Info($"Water level changed by 10 mm; new: {h.New}, old: {h.Old}"),
null //e => { return Math.Abs(e.Delta) > 0.1f; }
));

waterSensor.Updated += (object sender, IChangeResult<float> e) =>
{
Resolver.Log.Info($"Level Changed, level: {e.New}cm");
};

return Task.CompletedTask;
}

public override async Task Run()
{
var conditions = await waterSensor.Read();
Resolver.Log.Info($"Initial level: {conditions}");

waterSensor.StartUpdating(TimeSpan.FromSeconds(5));
}

Sample project(s) available on GitHub

Wiring Example

WaterSensorMeadow Pin
GNDGND
VCC3.3V
RXD01
TXD00

Class WaterSensor

Represents a water sensor that can detect the level of water.

Assembly: WaterSensor.dll
View Source
Declaration
public class WaterSensor : AnalogWaterLevel, IObservable<IChangeResult<float>>, ISamplingSensor<float>, ISensor<float>, ISensor, ISamplingSensor

Inheritance: System.Object -> Meadow.Foundation.ObservableBase<System.Single> -> Meadow.Foundation.SamplingSensorBase<System.Single> -> Meadow.Foundation.Sensors.Environmental.AnalogWaterLevel

Implements:
System.IObservable<Meadow.IChangeResult<System.Single>>, Meadow.Peripherals.Sensors.ISamplingSensor<System.Single>, Meadow.Peripherals.Sensors.ISensor<System.Single>, Meadow.Peripherals.Sensors.ISensor, Meadow.Peripherals.Sensors.ISamplingSensor

Implements

  • System.IObservable<Meadow.IChangeResult<System.Single>>
  • Meadow.Peripherals.Sensors.ISamplingSensor<System.Single>
  • Meadow.Peripherals.Sensors.ISensor<System.Single>
  • Meadow.Peripherals.Sensors.ISensor
  • Meadow.Peripherals.Sensors.ISamplingSensor