Remarks

WindVane
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Weather.WindVane

Code Example

WindVane windVane;

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

    // initialize the wind vane driver
    windVane = new WindVane(Device.Pins.A00);

    //==== Classic event example:
    windVane.Updated += (sender, result) => Resolver.Log.Info($"Updated event {result.New.DecimalDegrees}");

    //==== IObservable Pattern
    var observer = WindVane.CreateObserver(
        handler: result => Resolver.Log.Info($"Wind Direction: {result.New.Compass16PointCardinalName}"),
        filter: null
    );
    windVane.Subscribe(observer);

    return Task.CompletedTask;
}

public override async Task Run()
{
    // get initial reading, just to test the API
    Azimuth azi = await windVane.Read();
    Resolver.Log.Info($"Initial azimuth: {azi.Compass16PointCardinalName}");

    // start updating
    windVane.StartUpdating(TimeSpan.FromSeconds(1));
}

Sample project(s) available on GitHub

Characteristic Locus
Inheritance object ObservableBase<Azimuth> SamplingSensorBase<Azimuth> > WindVane
Implements IObservable<IChangeResult<Azimuth>> IWindVane ISamplingSensor<Azimuth> ISensor<Azimuth>
Inherited Members SamplingSensorBase<Azimuth>.samplingLock SamplingSensorBase<Azimuth>.RaiseEventsAndNotify(IChangeResult<Azimuth>) SamplingSensorBase<Azimuth>.Read() SamplingSensorBase<Azimuth>.SamplingTokenSource SamplingSensorBase<Azimuth>.Conditions SamplingSensorBase<Azimuth>.IsSampling SamplingSensorBase<Azimuth>.UpdateInterval SamplingSensorBase<Azimuth>.Updated ObservableBase<Azimuth>.NotifyObservers(IChangeResult<Azimuth>) ObservableBase<Azimuth>.Subscribe(IObserver<IChangeResult<Azimuth>>) ObservableBase<Azimuth>.CreateObserver(Action<IChangeResult<Azimuth>>, Predicate<IChangeResult<Azimuth>>) ObservableBase<Azimuth>.observers object.Equals(object) object.Equals(object, object) object.GetHashCode() object.GetType() object.MemberwiseClone() object.ReferenceEquals(object, object) object.ToString()
Namespace Meadow.Foundation.Sensors.Weather
Assembly WindVane.dll

Syntax

public class WindVane : SamplingSensorBase<Azimuth>, IObservable<IChangeResult<Azimuth>>, IWindVane, ISamplingSensor<Azimuth>, ISensor<Azimuth>

Constructors

WindVane(IAnalogInputPort, IDictionary<Voltage, Azimuth>)

Creates a new WindVane on the specified input port. Optionally, with a custom voltage to azimuth lookup.

Declaration
public WindVane(IAnalogInputPort inputPort, IDictionary<Voltage, Azimuth> azimuthVoltages = null)

Parameters

Type Name Description
IAnalogInputPort inputPort

The analog input

IDictionary<Voltage, Azimuth> azimuthVoltages

Optional. Supply if you have custom azimuth voltages

Remarks

WindVane
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Weather.WindVane

Code Example

WindVane windVane;

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

    // initialize the wind vane driver
    windVane = new WindVane(Device.Pins.A00);

    //==== Classic event example:
    windVane.Updated += (sender, result) => Resolver.Log.Info($"Updated event {result.New.DecimalDegrees}");

    //==== IObservable Pattern
    var observer = WindVane.CreateObserver(
        handler: result => Resolver.Log.Info($"Wind Direction: {result.New.Compass16PointCardinalName}"),
        filter: null
    );
    windVane.Subscribe(observer);

    return Task.CompletedTask;
}

public override async Task Run()
{
    // get initial reading, just to test the API
    Azimuth azi = await windVane.Read();
    Resolver.Log.Info($"Initial azimuth: {azi.Compass16PointCardinalName}");

    // start updating
    windVane.StartUpdating(TimeSpan.FromSeconds(1));
}

Sample project(s) available on GitHub

WindVane(IPin, IDictionary<Voltage, Azimuth>, TimeSpan?, int, TimeSpan?)

Creates a new WindVane on the specified IO Device's analog input Optionally, with a custom voltage to azimuth lookup

Declaration
public WindVane(IPin analogInputPin, IDictionary<Voltage, Azimuth> azimuthVoltages = null, TimeSpan? updateInterval = null, int sampleCount = 1, TimeSpan? sampleInterval = null)

Parameters

Type Name Description
IPin analogInputPin

The analog input pin

IDictionary<Voltage, Azimuth> azimuthVoltages

Optional - Supply if you have custom azimuth voltages

TimeSpan? updateInterval

The sensor update interval

int sampleCount

Sample couple

TimeSpan? sampleInterval

Sample interval

Remarks

WindVane
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Weather.WindVane

Code Example

WindVane windVane;

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

    // initialize the wind vane driver
    windVane = new WindVane(Device.Pins.A00);

    //==== Classic event example:
    windVane.Updated += (sender, result) => Resolver.Log.Info($"Updated event {result.New.DecimalDegrees}");

    //==== IObservable Pattern
    var observer = WindVane.CreateObserver(
        handler: result => Resolver.Log.Info($"Wind Direction: {result.New.Compass16PointCardinalName}"),
        filter: null
    );
    windVane.Subscribe(observer);

    return Task.CompletedTask;
}

public override async Task Run()
{
    // get initial reading, just to test the API
    Azimuth azi = await windVane.Read();
    Resolver.Log.Info($"Initial azimuth: {azi.Compass16PointCardinalName}");

    // start updating
    windVane.StartUpdating(TimeSpan.FromSeconds(1));
}

Sample project(s) available on GitHub

Properties

AzimuthVoltages

Voltage -> wind azimuth lookup dictionary

Declaration
public ReadOnlyDictionary<Voltage, Azimuth> AzimuthVoltages { get; protected set; }

Property Value

Type Description
ReadOnlyDictionary<Voltage, Azimuth>

Remarks

WindVane
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Weather.WindVane

Code Example

WindVane windVane;

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

    // initialize the wind vane driver
    windVane = new WindVane(Device.Pins.A00);

    //==== Classic event example:
    windVane.Updated += (sender, result) => Resolver.Log.Info($"Updated event {result.New.DecimalDegrees}");

    //==== IObservable Pattern
    var observer = WindVane.CreateObserver(
        handler: result => Resolver.Log.Info($"Wind Direction: {result.New.Compass16PointCardinalName}"),
        filter: null
    );
    windVane.Subscribe(observer);

    return Task.CompletedTask;
}

public override async Task Run()
{
    // get initial reading, just to test the API
    Azimuth azi = await windVane.Read();
    Resolver.Log.Info($"Initial azimuth: {azi.Compass16PointCardinalName}");

    // start updating
    windVane.StartUpdating(TimeSpan.FromSeconds(1));
}

Sample project(s) available on GitHub

SampleCount

Number of samples to take per reading. Default is 2

Declaration
public int SampleCount { get; set; }

Property Value

Type Description
int

Remarks

WindVane
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Weather.WindVane

Code Example

WindVane windVane;

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

    // initialize the wind vane driver
    windVane = new WindVane(Device.Pins.A00);

    //==== Classic event example:
    windVane.Updated += (sender, result) => Resolver.Log.Info($"Updated event {result.New.DecimalDegrees}");

    //==== IObservable Pattern
    var observer = WindVane.CreateObserver(
        handler: result => Resolver.Log.Info($"Wind Direction: {result.New.Compass16PointCardinalName}"),
        filter: null
    );
    windVane.Subscribe(observer);

    return Task.CompletedTask;
}

public override async Task Run()
{
    // get initial reading, just to test the API
    Azimuth azi = await windVane.Read();
    Resolver.Log.Info($"Initial azimuth: {azi.Compass16PointCardinalName}");

    // start updating
    windVane.StartUpdating(TimeSpan.FromSeconds(1));
}

Sample project(s) available on GitHub

SampleInterval

Duration of time between samples (default is 40ms)

Declaration
public TimeSpan SampleInterval { get; set; }

Property Value

Type Description
TimeSpan

Remarks

WindVane
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Weather.WindVane

Code Example

WindVane windVane;

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

    // initialize the wind vane driver
    windVane = new WindVane(Device.Pins.A00);

    //==== Classic event example:
    windVane.Updated += (sender, result) => Resolver.Log.Info($"Updated event {result.New.DecimalDegrees}");

    //==== IObservable Pattern
    var observer = WindVane.CreateObserver(
        handler: result => Resolver.Log.Info($"Wind Direction: {result.New.Compass16PointCardinalName}"),
        filter: null
    );
    windVane.Subscribe(observer);

    return Task.CompletedTask;
}

public override async Task Run()
{
    // get initial reading, just to test the API
    Azimuth azi = await windVane.Read();
    Resolver.Log.Info($"Initial azimuth: {azi.Compass16PointCardinalName}");

    // start updating
    windVane.StartUpdating(TimeSpan.FromSeconds(1));
}

Sample project(s) available on GitHub

WindAzimuth

The last recorded azimuth of the wind

Declaration
public Azimuth? WindAzimuth { get; protected set; }

Property Value

Type Description
Azimuth?

Remarks

WindVane
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Weather.WindVane

Code Example

WindVane windVane;

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

    // initialize the wind vane driver
    windVane = new WindVane(Device.Pins.A00);

    //==== Classic event example:
    windVane.Updated += (sender, result) => Resolver.Log.Info($"Updated event {result.New.DecimalDegrees}");

    //==== IObservable Pattern
    var observer = WindVane.CreateObserver(
        handler: result => Resolver.Log.Info($"Wind Direction: {result.New.Compass16PointCardinalName}"),
        filter: null
    );
    windVane.Subscribe(observer);

    return Task.CompletedTask;
}

public override async Task Run()
{
    // get initial reading, just to test the API
    Azimuth azi = await windVane.Read();
    Resolver.Log.Info($"Initial azimuth: {azi.Compass16PointCardinalName}");

    // start updating
    windVane.StartUpdating(TimeSpan.FromSeconds(1));
}

Sample project(s) available on GitHub

Methods

GetDefaultAzimuthVoltages()

Loads a default set of voltage -> azimuth lookup values based on a 4.7kΩ / 1kΩ voltage divider

Declaration
protected ReadOnlyDictionary<Voltage, Azimuth> GetDefaultAzimuthVoltages()

Returns

Type Description
ReadOnlyDictionary<Voltage, Azimuth>

Remarks

WindVane
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Weather.WindVane

Code Example

WindVane windVane;

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

    // initialize the wind vane driver
    windVane = new WindVane(Device.Pins.A00);

    //==== Classic event example:
    windVane.Updated += (sender, result) => Resolver.Log.Info($"Updated event {result.New.DecimalDegrees}");

    //==== IObservable Pattern
    var observer = WindVane.CreateObserver(
        handler: result => Resolver.Log.Info($"Wind Direction: {result.New.Compass16PointCardinalName}"),
        filter: null
    );
    windVane.Subscribe(observer);

    return Task.CompletedTask;
}

public override async Task Run()
{
    // get initial reading, just to test the API
    Azimuth azi = await windVane.Read();
    Resolver.Log.Info($"Initial azimuth: {azi.Compass16PointCardinalName}");

    // start updating
    windVane.StartUpdating(TimeSpan.FromSeconds(1));
}

Sample project(s) available on GitHub

HandleAnalogUpdate(IChangeResult<Voltage>)

Takes the analog reading and converts to the wind azimuth, then raises the event/updates subscribers

Declaration
protected void HandleAnalogUpdate(IChangeResult<Voltage> result)

Parameters

Type Name Description
IChangeResult<Voltage> result

Remarks

WindVane
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Weather.WindVane

Code Example

WindVane windVane;

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

    // initialize the wind vane driver
    windVane = new WindVane(Device.Pins.A00);

    //==== Classic event example:
    windVane.Updated += (sender, result) => Resolver.Log.Info($"Updated event {result.New.DecimalDegrees}");

    //==== IObservable Pattern
    var observer = WindVane.CreateObserver(
        handler: result => Resolver.Log.Info($"Wind Direction: {result.New.Compass16PointCardinalName}"),
        filter: null
    );
    windVane.Subscribe(observer);

    return Task.CompletedTask;
}

public override async Task Run()
{
    // get initial reading, just to test the API
    Azimuth azi = await windVane.Read();
    Resolver.Log.Info($"Initial azimuth: {azi.Compass16PointCardinalName}");

    // start updating
    windVane.StartUpdating(TimeSpan.FromSeconds(1));
}

Sample project(s) available on GitHub

LookupWindDirection(Voltage)

Finds the closest wind azimuth that matches the passed in voltage, based on the AziumuthVoltages

Declaration
protected Azimuth LookupWindDirection(Voltage voltage)

Parameters

Type Name Description
Voltage voltage

The voltage

Returns

Type Description
Azimuth

The Azimuth value

Remarks

WindVane
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Weather.WindVane

Code Example

WindVane windVane;

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

    // initialize the wind vane driver
    windVane = new WindVane(Device.Pins.A00);

    //==== Classic event example:
    windVane.Updated += (sender, result) => Resolver.Log.Info($"Updated event {result.New.DecimalDegrees}");

    //==== IObservable Pattern
    var observer = WindVane.CreateObserver(
        handler: result => Resolver.Log.Info($"Wind Direction: {result.New.Compass16PointCardinalName}"),
        filter: null
    );
    windVane.Subscribe(observer);

    return Task.CompletedTask;
}

public override async Task Run()
{
    // get initial reading, just to test the API
    Azimuth azi = await windVane.Read();
    Resolver.Log.Info($"Initial azimuth: {azi.Compass16PointCardinalName}");

    // start updating
    windVane.StartUpdating(TimeSpan.FromSeconds(1));
}

Sample project(s) available on GitHub

ReadSensor()

Convenience method to get the current wind azimuth. For frequent reads, use StartSampling() and StopSampling() in conjunction with the SampleBuffer

Declaration
protected override Task<Azimuth> ReadSensor()

Returns

Type Description
Task<Azimuth>

A float value that's an average value of all the samples taken

Overrides

Meadow.Foundation.SamplingSensorBase<Meadow.Units.Azimuth>.ReadSensor()

Remarks

WindVane
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Weather.WindVane

Code Example

WindVane windVane;

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

    // initialize the wind vane driver
    windVane = new WindVane(Device.Pins.A00);

    //==== Classic event example:
    windVane.Updated += (sender, result) => Resolver.Log.Info($"Updated event {result.New.DecimalDegrees}");

    //==== IObservable Pattern
    var observer = WindVane.CreateObserver(
        handler: result => Resolver.Log.Info($"Wind Direction: {result.New.Compass16PointCardinalName}"),
        filter: null
    );
    windVane.Subscribe(observer);

    return Task.CompletedTask;
}

public override async Task Run()
{
    // get initial reading, just to test the API
    Azimuth azi = await windVane.Read();
    Resolver.Log.Info($"Initial azimuth: {azi.Compass16PointCardinalName}");

    // start updating
    windVane.StartUpdating(TimeSpan.FromSeconds(1));
}

Sample project(s) available on GitHub

StartUpdating(TimeSpan?)

Starts continuously sampling the sensor.

This method also starts raising Updated events and IObservable subscribers getting notified. Use the standbyDuration parameter to specify how often events and notifications are raised/sent.

Declaration
public override void StartUpdating(TimeSpan? updateInterval)

Parameters

Type Name Description
TimeSpan? updateInterval

A TimeSpan that specifies how long to wait between readings. This value influences how often *Updated events are raised and IObservable consumers are notified.

Overrides

Remarks

WindVane
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Weather.WindVane

Code Example

WindVane windVane;

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

    // initialize the wind vane driver
    windVane = new WindVane(Device.Pins.A00);

    //==== Classic event example:
    windVane.Updated += (sender, result) => Resolver.Log.Info($"Updated event {result.New.DecimalDegrees}");

    //==== IObservable Pattern
    var observer = WindVane.CreateObserver(
        handler: result => Resolver.Log.Info($"Wind Direction: {result.New.Compass16PointCardinalName}"),
        filter: null
    );
    windVane.Subscribe(observer);

    return Task.CompletedTask;
}

public override async Task Run()
{
    // get initial reading, just to test the API
    Azimuth azi = await windVane.Read();
    Resolver.Log.Info($"Initial azimuth: {azi.Compass16PointCardinalName}");

    // start updating
    windVane.StartUpdating(TimeSpan.FromSeconds(1));
}

Sample project(s) available on GitHub

StopUpdating()

Stops sampling the sensor

Declaration
public override void StopUpdating()

Overrides

Meadow.Foundation.SamplingSensorBase<Meadow.Units.Azimuth>.StopUpdating()

Remarks

WindVane
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Weather.WindVane

Code Example

WindVane windVane;

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

    // initialize the wind vane driver
    windVane = new WindVane(Device.Pins.A00);

    //==== Classic event example:
    windVane.Updated += (sender, result) => Resolver.Log.Info($"Updated event {result.New.DecimalDegrees}");

    //==== IObservable Pattern
    var observer = WindVane.CreateObserver(
        handler: result => Resolver.Log.Info($"Wind Direction: {result.New.Compass16PointCardinalName}"),
        filter: null
    );
    windVane.Subscribe(observer);

    return Task.CompletedTask;
}

public override async Task Run()
{
    // get initial reading, just to test the API
    Azimuth azi = await windVane.Read();
    Resolver.Log.Info($"Initial azimuth: {azi.Compass16PointCardinalName}");

    // start updating
    windVane.StartUpdating(TimeSpan.FromSeconds(1));
}

Sample project(s) available on GitHub