Remarks

AdafruitMPRLS
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Atmospheric.AdafruitMPRLS

Code Example

AdafruitMPRLS sensor;

public override Task Initialize()
{
    Console.WriteLine("Initializing...");

    sensor = new AdafruitMPRLS(Device.CreateI2cBus());
    sensor.Updated += PressureSensor_Updated;

    return Task.CompletedTask;
}

public override Task Run()
{
    sensor.StartUpdating(TimeSpan.FromSeconds(1));

    return Task.CompletedTask;
}

void PressureSensor_Updated(object sender, IChangeResult<(Pressure? Pressure, Pressure? RawPsiMeasurement)> result)
{
    Console.WriteLine($"New pressure PSI: {result.New.Pressure?.Psi}, Old pressure PSI: {result.Old?.Pressure?.Psi}");

    Console.WriteLine($"Pressure in Pascal: {result.New.Pressure?.Pascal}");

    Console.WriteLine($"Raw sensor value: {result.New.RawPsiMeasurement?.Psi}");
}

Sample project(s) available on GitHub

Wiring Example

To wire a Adafruit MPRLS Sensor to your Meadow board, connect the following:

MPRLS Meadow Pin
GND GND
VCC 3.3V
SCL D08
SDA D07
Characteristic Locus
Inheritance System.Object ObservableBase<System.ValueTuple<System.Nullable<Pressure>, System.Nullable<Pressure>>> SensorBase<System.ValueTuple<System.Nullable<Pressure>, System.Nullable<Pressure>>> SamplingSensorBase<System.ValueTuple<System.Nullable<Pressure>, System.Nullable<Pressure>>> ByteCommsSensorBase<System.ValueTuple<System.Nullable<Pressure>, System.Nullable<Pressure>>> > AdafruitMPRLS
Implements IDisposable IBarometricPressureSensor
Inherited Members ByteCommsSensorBase<(Nullable<Pressure> Pressure, Nullable<Pressure> RawPsiMeasurement)>.Peripheral ByteCommsSensorBase<(Nullable<Pressure> Pressure, Nullable<Pressure> RawPsiMeasurement)>.ReadBuffer ByteCommsSensorBase<(Nullable<Pressure> Pressure, Nullable<Pressure> RawPsiMeasurement)>.WriteBuffer ByteCommsSensorBase<(Nullable<Pressure> Pressure, Nullable<Pressure> RawPsiMeasurement)>.Init(Int32, Int32) ByteCommsSensorBase<(Nullable<Pressure> Pressure, Nullable<Pressure> RawPsiMeasurement)>.Dispose(Boolean) ByteCommsSensorBase<(Nullable<Pressure> Pressure, Nullable<Pressure> RawPsiMeasurement)>.Dispose() SamplingSensorBase<(Nullable<Pressure> Pressure, Nullable<Pressure> RawPsiMeasurement)>.StartUpdating(Nullable<TimeSpan>) SamplingSensorBase<(Nullable<Pressure> Pressure, Nullable<Pressure> RawPsiMeasurement)>.StopUpdating() SensorBase<(Nullable<Pressure> Pressure, Nullable<Pressure> RawPsiMeasurement)>.Updated SensorBase<(Nullable<Pressure> Pressure, Nullable<Pressure> RawPsiMeasurement)>.samplingLock SensorBase<(Nullable<Pressure> Pressure, Nullable<Pressure> RawPsiMeasurement)>.SamplingTokenSource SensorBase<(Nullable<Pressure> Pressure, Nullable<Pressure> RawPsiMeasurement)>.Conditions SensorBase<(Nullable<Pressure> Pressure, Nullable<Pressure> RawPsiMeasurement)>.IsSampling SensorBase<(Nullable<Pressure> Pressure, Nullable<Pressure> RawPsiMeasurement)>.UpdateInterval SensorBase<(Nullable<Pressure> Pressure, Nullable<Pressure> RawPsiMeasurement)>.ReadSensor() SensorBase<(Nullable<Pressure> Pressure, Nullable<Pressure> RawPsiMeasurement)>.RaiseEventsAndNotify(IChangeResult<>) SensorBase<(Nullable<Pressure> Pressure, Nullable<Pressure> RawPsiMeasurement)>.Read() ObservableBase<(Nullable<Pressure> Pressure, Nullable<Pressure> RawPsiMeasurement)>.observers ObservableBase<(Nullable<Pressure> Pressure, Nullable<Pressure> RawPsiMeasurement)>.NotifyObservers(IChangeResult<>) Meadow.Foundation.ObservableBase<System.ValueTuple<System.Nullable<Pressure>, System.Nullable<Pressure>>>.Subscribe(IObserver<>) Meadow.Foundation.ObservableBase<System.ValueTuple<System.Nullable<Pressure>, System.Nullable<Pressure>>>.CreateObserver(Action<>, System.Nullable<Predicate<IChangeResult<UNIT>>>)
Namespace Meadow.Foundation.Sensors.Atmospheric
Assembly AdafruitMPRLS.dll

Syntax

public class AdafruitMPRLS : ByteCommsSensorBase<(Pressure? Pressure, Pressure? RawPsiMeasurement)>, IDisposable, IBarometricPressureSensor

Constructors

AdafruitMPRLS(II2cBus, Int32, Int32)

Declaration
public AdafruitMPRLS(II2cBus i2cbus, int psiMin = 0, int psiMax = 25)

Parameters

Type Name Description
II2cBus i2cbus
System.Int32 psiMin
System.Int32 psiMax

Properties

HasMemoryIntegrityFailed

Set by the sensor, to tell us whether or not there's an issue with its own memory.

Declaration
public bool HasMemoryIntegrityFailed { get; set; }

Property Value

Type Description
System.Boolean

InternalMathSaturated

Declaration
public bool InternalMathSaturated { get; set; }

Property Value

Type Description
System.Boolean

IsDeviceBusy

Set by the sensor, to tell us it's busy.

Declaration
public bool IsDeviceBusy { get; set; }

Property Value

Type Description
System.Boolean

IsDevicePowered

Set by the sensor, to tell us it has power.

Declaration
public bool IsDevicePowered { get; set; }

Property Value

Type Description
System.Boolean

Pressure

Declaration
public Pressure? Pressure { get; }

Property Value

Type Description
System.Nullable<Pressure>

RawPsiMeasurement

Declaration
public Pressure? RawPsiMeasurement { get; }

Property Value

Type Description
System.Nullable<Pressure>

Methods

RaiseEventsAndNotify(IChangeResult<(Nullable<Pressure> Pressure, Nullable<Pressure> RawPsiMeasurement)>)

Declaration
protected override void RaiseEventsAndNotify(IChangeResult<(Pressure? Pressure, Pressure? RawPsiMeasurement)> changeResult)

Parameters

Type Name Description
IChangeResult<System.ValueTuple<System.Nullable<Pressure>, System.Nullable<Pressure>>> changeResult

ReadSensor()

Declaration
protected override Task<(Pressure? Pressure, Pressure? RawPsiMeasurement)> ReadSensor()

Returns

Type Description
Task<System.ValueTuple<System.Nullable<Pressure>, System.Nullable<Pressure>>>

Overrides

Meadow.Foundation.SensorBase<System.ValueTuple<System.Nullable<Pressure>, System.Nullable<Pressure>>>.ReadSensor()

Events

PressureUpdated

Declaration
public event EventHandler<IChangeResult<Pressure>> PressureUpdated

Event Type

Type Description
EventHandler<IChangeResult<Pressure>>