Skip to main content

Class WindVane

Driver for a wind vane that outputs variable voltage, based on the azimuth of the wind. Matches the input voltage to the AzimuthVoltages dictionary lookup and returns the nearest azimuth to the voltage specified.

By default it will use look ups that match voltage outputs from the windvane in the Sparkfun/Shenzen Fine Offset Electronics with a voltage divider of 4.7kΩ / 1kΩ, as can be found in the SparkFun weather shield, or Wilderness Labs Clima Pro board.

Assembly: WindVane.dll
View Source
public class WindVane : SamplingSensorBase<Azimuth>, IObservable<IChangeResult<Azimuth>>, IWindVane, ISamplingSensor<Azimuth>, ISensor<Azimuth>, ISensor, ISamplingSensor, IDisposable

Inheritance: System.Object -> Meadow.Foundation.ObservableBase<UNIT> -> Meadow.Foundation.SamplingSensorBase<UNIT>

Implements:
System.IObservable<Meadow.IChangeResult<Meadow.Units.Azimuth>>, Meadow.Peripherals.Sensors.Weather.IWindVane, Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Azimuth>, Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Azimuth>, Meadow.Peripherals.Sensors.ISensor, Meadow.Peripherals.Sensors.ISamplingSensor, System.IDisposable

Properties

WindAzimuth

The last recorded azimuth of the wind

View Source
public Azimuth? WindAzimuth { get; protected set; }

SampleCount

Number of samples to take per reading. Default is 2

View Source
public int SampleCount { get; set; }

SampleInterval

Duration of time between samples (default is 40ms)

View Source
public TimeSpan SampleInterval { get; set; }

AzimuthVoltages

Voltage -> wind azimuth lookup dictionary

View Source
public ReadOnlyDictionary<Voltage, Azimuth>? AzimuthVoltages { get; protected set; }

IsDisposed

Is the object disposed

View Source
public bool IsDisposed { get; }

Methods

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.

View Source
public override void StartUpdating(TimeSpan? updateInterval)
Parameters
TypeNameDescription
System.Nullable<System.TimeSpan>updateIntervalA TimeSpan that specifies how long to
 wait between readings. This value influences how often `*Updated`
 events are raised and `IObservable` consumers are notified. |

StopUpdating()

Stops sampling the sensor

View Source
public override void StopUpdating()

ReadSensor()

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

View Source
protected override Task<Azimuth> ReadSensor()
Returns

System.Threading.Tasks.Task<Meadow.Units.Azimuth>: A float value that's an average value of all the samples taken### HandleAnalogUpdate(IChangeResult<Voltage>) Takes the analog reading and converts to the wind azimuth, then raises the event/updates subscribers

View Source
protected void HandleAnalogUpdate(IChangeResult<Voltage> result)
Parameters
TypeName
Meadow.IChangeResult<Meadow.Units.Voltage>result

LookupWindDirection(Voltage)

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

View Source
protected Azimuth LookupWindDirection(Voltage voltage)
Returns

Meadow.Units.Azimuth: The Azimuth value

Parameters
TypeNameDescription
Meadow.Units.VoltagevoltageThe voltage

GetDefaultAzimuthVoltages()

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

View Source
protected ReadOnlyDictionary<Voltage, Azimuth> GetDefaultAzimuthVoltages()
Returns

System.Collections.ObjectModel.ReadOnlyDictionary<Meadow.Units.Voltage,Meadow.Units.Azimuth>

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

View Source
public void Dispose()

Dispose(bool)

Dispose of the object

View Source
protected virtual void Dispose(bool disposing)
Parameters
TypeNameDescription
System.BooleandisposingIs disposing

Implements

  • System.IObservable<Meadow.IChangeResult<Meadow.Units.Azimuth>>
  • Meadow.Peripherals.Sensors.Weather.IWindVane
  • Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Azimuth>
  • Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Azimuth>
  • Meadow.Peripherals.Sensors.ISensor
  • Meadow.Peripherals.Sensors.ISamplingSensor
  • System.IDisposable