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