Remarks

WaterSensor
Status Status badge: working
Source code GitHub
NuGet package NuGet 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

WaterSensor Meadow Pin
GND GND
VCC 3.3V
RX D01
TX D00
Characteristic Locus
Inheritance object ObservableBase<float> SamplingSensorBase<float> AnalogWaterLevel > WaterSensor
Implements IObservable<IChangeResult<float>> ISamplingSensor<float> ISensor<float>
Inherited Members AnalogWaterLevel.AnalogInputPort AnalogWaterLevel.LevelCalibration AnalogWaterLevel.WaterLevel AnalogWaterLevel.ReadSensor() AnalogWaterLevel.StartUpdating(TimeSpan?) AnalogWaterLevel.StopUpdating() AnalogWaterLevel.VoltageToWaterLevel(Voltage) SamplingSensorBase<float>.samplingLock SamplingSensorBase<float>.Updated SamplingSensorBase<float>.SamplingTokenSource SamplingSensorBase<float>.Conditions SamplingSensorBase<float>.IsSampling SamplingSensorBase<float>.UpdateInterval SamplingSensorBase<float>.RaiseEventsAndNotify(IChangeResult<float>) SamplingSensorBase<float>.Read() ObservableBase<float>.observers ObservableBase<float>.NotifyObservers(IChangeResult<float>) ObservableBase<float>.Subscribe(IObserver<IChangeResult<float>>) ObservableBase<float>.CreateObserver(Action<IChangeResult<float>>, Predicate<IChangeResult<float>>) object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString()
Namespace Meadow.Foundation.Grove.Sensors.Environmental
Assembly WaterSensor.dll

Syntax

public class WaterSensor : AnalogWaterLevel, IObservable<IChangeResult<float>>, ISamplingSensor<float>, ISensor<float>

Constructors

WaterSensor(IAnalogInputPort, Calibration)

Declaration
public WaterSensor(IAnalogInputPort analogInputPort, AnalogWaterLevel.Calibration calibration = null)

Parameters

Type Name Description
IAnalogInputPort analogInputPort
AnalogWaterLevel.Calibration calibration

Remarks

WaterSensor
Status Status badge: working
Source code GitHub
NuGet package NuGet 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

WaterSensor Meadow Pin
GND GND
VCC 3.3V
RX D01
TX D00

WaterSensor(IPin, Calibration, TimeSpan?)

Declaration
public WaterSensor(IPin analogPin, AnalogWaterLevel.Calibration calibration = null, TimeSpan? updateInterval = null)

Parameters

Type Name Description
IPin analogPin
AnalogWaterLevel.Calibration calibration
TimeSpan? updateInterval

Remarks

WaterSensor
Status Status badge: working
Source code GitHub
NuGet package NuGet 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

WaterSensor Meadow Pin
GND GND
VCC 3.3V
RX D01
TX D00