Remarks

MaxBotix
Status Status badge: working
Source code GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Distance.MaxBotix

Code Example



Sample project(s) available on GitHub

Wiring Example

To wire a MaxBotix to your Meadow board, connect the following:

MaxBotix Meadow Pin
GND GND
SCL D08 (SCL)
SDA D07 (SDA)
VCC 3V3
Characteristic Locus
Inheritance System.Object ObservableBase<Length> SensorBase<Length> SamplingSensorBase<Length> ByteCommsSensorBase<Length> > MaxBotix
Implements IDisposable IRangeFinder
Inherited Members ByteCommsSensorBase<Length>.Peripheral ByteCommsSensorBase<Length>.ReadBuffer ByteCommsSensorBase<Length>.WriteBuffer ByteCommsSensorBase<Length>.Init(Int32, Int32) ByteCommsSensorBase<Length>.Dispose(Boolean) ByteCommsSensorBase<Length>.Dispose() SensorBase<Length>.Updated SensorBase<Length>.samplingLock SensorBase<Length>.SamplingTokenSource SensorBase<Length>.Conditions SensorBase<Length>.IsSampling SensorBase<Length>.UpdateInterval SensorBase<Length>.RaiseEventsAndNotify(IChangeResult<>) SensorBase<Length>.Read() ObservableBase<Length>.observers ObservableBase<Length>.NotifyObservers(IChangeResult<>) Meadow.Foundation.ObservableBase<Length>.Subscribe(IObserver<>) Meadow.Foundation.ObservableBase<Length>.CreateObserver(Action<>, System.Nullable<Predicate<IChangeResult<UNIT>>>)
Namespace Meadow.Foundation.Sensors.Distance
Assembly MaxBotix.dll

Syntax

public class MaxBotix : ByteCommsSensorBase<Length>, IDisposable, IRangeFinder

Constructors

MaxBotix(IAnalogInputPort, MaxBotix.SensorType)

Declaration
public MaxBotix(IAnalogInputPort analogIntputPort, MaxBotix.SensorType sensor)

Parameters

Type Name Description
IAnalogInputPort analogIntputPort
MaxBotix.SensorType sensor

MaxBotix(II2cBus, MaxBotix.SensorType, Byte)

Declaration
public MaxBotix(II2cBus i2cBus, MaxBotix.SensorType sensor, byte address = null)

Parameters

Type Name Description
II2cBus i2cBus
MaxBotix.SensorType sensor
System.Byte address

MaxBotix(IMeadowDevice, SerialPortName, MaxBotix.SensorType)

Declaration
public MaxBotix(IMeadowDevice device, SerialPortName serialPort, MaxBotix.SensorType sensor)

Parameters

Type Name Description
IMeadowDevice device
SerialPortName serialPort
MaxBotix.SensorType sensor

MaxBotix(ISerialMessagePort, MaxBotix.SensorType)

Declaration
public MaxBotix(ISerialMessagePort serialMessage, MaxBotix.SensorType sensor)

Parameters

Type Name Description
ISerialMessagePort serialMessage
MaxBotix.SensorType sensor

MaxBotix(MaxBotix.SensorType, IMeadowDevice, IPin, Int32, Nullable<TimeSpan>, Nullable<Voltage>)

Declaration
public MaxBotix(MaxBotix.SensorType sensor, IMeadowDevice device, IPin analogInputPin, int sampleCount = 5, TimeSpan? sampleInterval = null, Voltage? voltage = null)

Parameters

Type Name Description
MaxBotix.SensorType sensor
IMeadowDevice device
IPin analogInputPin
System.Int32 sampleCount
System.Nullable<TimeSpan> sampleInterval
System.Nullable<Voltage> voltage

Properties

Distance

Distance from sensor to object

Declaration
public Length? Distance { get; protected set; }

Property Value

Type Description
System.Nullable<Length>

VCC

voltage common collector (VCC) typically 3.3V

Declaration
public double VCC { get; set; }

Property Value

Type Description
System.Double

Methods

MeasureDistance()

Declaration
public void MeasureDistance()

RaiseEventsAndNotify(IChangeResult<Length>)

Raise distance change event for subscribers

Declaration
protected override void RaiseEventsAndNotify(IChangeResult<Length> changeResult)

Parameters

Type Name Description
IChangeResult<Length> changeResult

ReadSensor()

Read the distance from the sensor

Declaration
protected override Task<Length> ReadSensor()

Returns

Type Description
Task<Length>

Overrides

Meadow.Foundation.SensorBase<Length>.ReadSensor()

StartUpdating(Nullable<TimeSpan>)

Start updating distances

Declaration
public override void StartUpdating(TimeSpan? updateInterval)

Parameters

Type Name Description
System.Nullable<TimeSpan> updateInterval

StopUpdating()

Stops sampling the temperature.

Declaration
public override void StopUpdating()

Overrides

Meadow.Foundation.SamplingSensorBase<Length>.StopUpdating()

Events

DistanceUpdated

Raised when the value of the reading changes.

Declaration
public event EventHandler<IChangeResult<Length>> DistanceUpdated

Event Type

Type Description
EventHandler<IChangeResult<Length>>