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
Declaration
public class WindVane : SamplingSensorBase<Azimuth>, IObservable<IChangeResult<Azimuth>>, IWindVane, ISamplingSensor<Azimuth>, ISensor<Azimuth>, ISensor, ISamplingSensor, IDisposable

Inheritance: System.Object -> Meadow.Foundation.ObservableBase<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
Declaration
public Azimuth? WindAzimuth { get; protected set; }

SampleCount

Number of samples to take per reading. Default is 2

View Source
Declaration
public int SampleCount { get; set; }

SampleInterval

Duration of time between samples (default is 40ms)

View Source
Declaration
public TimeSpan SampleInterval { get; set; }

AzimuthVoltages

Voltage -> wind azimuth lookup dictionary

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

IsDisposed

Is the object disposed

View Source
Declaration
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
Declaration
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
Declaration
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
Declaration
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
Declaration
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
Declaration
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
Declaration
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
Declaration
public void Dispose()

Dispose(bool)

Dispose of the object

View Source
Declaration
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