Skip to main content

Meadow.Foundation.Sensors.Atmospheric.AdafruitMPRLS

AdafruitMPRLS
StatusStatus badge: working
Source codeGitHub
Datasheet(s)GitHub
NuGet packageNuGet Gallery for Meadow.Foundation.Sensors.Atmospheric.AdafruitMPRLS

Code Example

AdafruitMPRLS sensor;

public override Task Initialize()
{
Resolver.Log.Info("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)
{
Resolver.Log.Info($"New pressure PSI: {result.New.Pressure?.Psi}, Old pressure PSI: {result.Old?.Pressure?.Psi}");

Resolver.Log.Info($"Pressure in Pascal: {result.New.Pressure?.Pascal}");

Resolver.Log.Info($"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:

MPRLSMeadow Pin
GNDGND
VCC3.3V
SCLD08
SDAD07

Class AdafruitMPRLS

Device driver for the Adafruit MPRLS Ported Pressure Sensor Breakout

Assembly: AdafruitMPRLS.dll
View Source
Declaration
public class AdafruitMPRLS : ByteCommsSensorBase<(Pressure? Pressure, Pressure? RawPsiMeasurement)>, IObservable<IChangeResult<(Pressure? Pressure, Pressure? RawPsiMeasurement)>>, ISamplingSensor<(Pressure? Pressure, Pressure? RawPsiMeasurement)>, ISensor<(Pressure? Pressure, Pressure? RawPsiMeasurement)>, IDisposable, II2cPeripheral, IBarometricPressureSensor, ISamplingSensor<Pressure>, ISensor<Pressure>, ISensor, ISamplingSensor

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

Implements:

Expand

System.IObservable<Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Units.Pressure>,System.Nullable<Meadow.Units.Pressure>>>>, Meadow.Peripherals.Sensors.ISamplingSensor<System.ValueTuple<System.Nullable<Meadow.Units.Pressure>,System.Nullable<Meadow.Units.Pressure>>>, Meadow.Peripherals.Sensors.ISensor<System.ValueTuple<System.Nullable<Meadow.Units.Pressure>,System.Nullable<Meadow.Units.Pressure>>>, System.IDisposable, Meadow.Hardware.II2cPeripheral, Meadow.Peripherals.Sensors.Atmospheric.IBarometricPressureSensor, Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Pressure>, Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Pressure>, Meadow.Peripherals.Sensors.ISensor, Meadow.Peripherals.Sensors.ISamplingSensor

Properties

DefaultI2cAddress

The default I2C address for the peripheral

View Source
Declaration
public byte DefaultI2cAddress { get; }

IsDevicePowered

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

View Source
Declaration
public bool IsDevicePowered { get; set; }

IsDeviceBusy

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

View Source
Declaration
public bool IsDeviceBusy { get; set; }

HasMemoryIntegrityFailed

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

View Source
Declaration
public bool HasMemoryIntegrityFailed { get; set; }

RawPsiMeasurement

Returns the current raw pressure value in pounds per square inch (PSI)

View Source
Declaration
public Pressure? RawPsiMeasurement { get; }

Pressure

Returns the current pressure reading

View Source
Declaration
public Pressure? Pressure { get; }

InternalMathSaturated

Indicates the sensor has reached its pressure limit.

View Source
Declaration
public bool InternalMathSaturated { get; set; }

Methods

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

Notify subscribers of PressureUpdated event handler

View Source
Declaration
protected override void RaiseEventsAndNotify(IChangeResult<(Pressure? Pressure, Pressure? RawPsiMeasurement)> changeResult)
Parameters
TypeName
Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Units.Pressure>,System.Nullable<Meadow.Units.Pressure>>>changeResult

ReadSensor()

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

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

System.Threading.Tasks.Task<System.ValueTuple<System.Nullable<Meadow.Units.Pressure>,System.Nullable<Meadow.Units.Pressure>>>

Implements

  • System.IObservable<Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Units.Pressure>,System.Nullable<Meadow.Units.Pressure>>>>
  • Meadow.Peripherals.Sensors.ISamplingSensor<System.ValueTuple<System.Nullable<Meadow.Units.Pressure>,System.Nullable<Meadow.Units.Pressure>>>
  • Meadow.Peripherals.Sensors.ISensor<System.ValueTuple<System.Nullable<Meadow.Units.Pressure>,System.Nullable<Meadow.Units.Pressure>>>
  • System.IDisposable
  • Meadow.Hardware.II2cPeripheral
  • Meadow.Peripherals.Sensors.Atmospheric.IBarometricPressureSensor
  • Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Pressure>
  • Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Pressure>
  • Meadow.Peripherals.Sensors.ISensor
  • Meadow.Peripherals.Sensors.ISamplingSensor