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 ISamplingSensor<Length> 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>, ISamplingSensor<Length>, IDisposable, IRangeFinder

Constructors

MaxBotix(IAnalogInputPort, MaxBotix.SensorType)

Creates a new MaxBotix object communicating over analog

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

Parameters

Type Name Description
IAnalogInputPort analogIntputPort

The port for the analog input pin

MaxBotix.SensorType sensor

The distance sensor type

MaxBotix(II2cBus, MaxBotix.SensorType, Byte)

Creates a new MaxBotix object communicating over I2C

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

Parameters

Type Name Description
II2cBus i2cBus

The I2C bus

MaxBotix.SensorType sensor

The distance sensor type

System.Byte address

The I2C address

MaxBotix(IMeadowDevice, SerialPortName, MaxBotix.SensorType)

Creates a new MaxBotix object communicating over serial

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

Parameters

Type Name Description
IMeadowDevice device

The device conected to the sensor

SerialPortName serialPort

The serial port

MaxBotix.SensorType sensor

The distance sensor type

MaxBotix(ISerialMessagePort, MaxBotix.SensorType)

Creates a new MaxBotix object communicating over serial

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

Parameters

Type Name Description
ISerialMessagePort serialMessage

The serial message port

MaxBotix.SensorType sensor

The distance sensor type

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

Creates a new MaxBotix object communicating over analog

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

The distance sensor type

IMeadowDevice device

The device connected to the sensor

IPin analogInputPin

The analog input pin

System.Int32 sampleCount

The sample count for reading

System.Nullable<TimeSpan> sampleInterval

The sample interval

System.Nullable<Voltage> voltage

The reference 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()

Start a distance measurement

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>>