Meadow.Foundation.Sensors.Atmospheric.AdafruitMPRLS
AdafruitMPRLS | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
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:
MPRLS | Meadow Pin |
---|---|
GND | GND |
VCC | 3.3V |
SCL | D08 |
SDA | D07 |
Class AdafruitMPRLS
Device driver for the Adafruit MPRLS Ported Pressure Sensor Breakout
Assembly: AdafruitMPRLS.dll
View Source
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
public byte DefaultI2cAddress { get; }
IsDevicePowered
Set by the sensor, to tell us it has power.
View Source
public bool IsDevicePowered { get; set; }
IsDeviceBusy
Set by the sensor, to tell us it's busy.
View Source
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
public bool HasMemoryIntegrityFailed { get; set; }
RawPsiMeasurement
Returns the current raw pressure value in pounds per square inch (PSI)
View Source
public Pressure? RawPsiMeasurement { get; }
Pressure
Returns the current pressure reading
View Source
public Pressure? Pressure { get; }
InternalMathSaturated
Indicates the sensor has reached its pressure limit.
View Source
public bool InternalMathSaturated { get; set; }
Methods
RaiseEventsAndNotify(IChangeResult<(Pressure? Pressure, Pressure? RawPsiMeasurement)>)
Notify subscribers of PressureUpdated event handler
View Source
protected override void RaiseEventsAndNotify(IChangeResult<(Pressure? Pressure, Pressure? RawPsiMeasurement)> changeResult)
Parameters
Type | Name |
---|---|
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
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