Skip to main content

Meadow.Foundation.Sensors.Weather.WindVane

WindVane
StatusStatus badge: working
Source codeGitHub
Datasheet(s)GitHub
NuGet packageNuGet 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