Skip to main content

Meadow.Foundation.Sensors.Atmospheric.Bh1900Nux

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

Code Example

private Bh1900Nux _sensor;

public override Task Initialize()
{
Resolver.Log.Info("Initializing...");

_sensor = new Bh1900Nux(Device.CreateI2cBus(), Bh1900Nux.Addresses.Default);

var consumer = Bh1900Nux.CreateObserver(
handler: result =>
{
Resolver.Log.Info($"Observer: Temp changed by threshold; new temp: {result.New.Celsius:N2}C, old: {result.Old?.Celsius:N2}C");
},
filter: result =>
{
if (result.Old is { } old)
{
return (result.New - old).Abs().Celsius > 0.5;
}
return false;
}
);
_sensor.Subscribe(consumer);

_sensor.Updated += (sender, result) =>
{
Resolver.Log.Info($" Temperature: {result.New.Celsius:N2}C");
};

return Task.CompletedTask;
}

public async override Task Run()
{
var conditions = await _sensor.Read();
Resolver.Log.Info("Initial Readings:");
Resolver.Log.Info($" Temperature: {conditions.Celsius:N2}C");

_sensor.StartUpdating(TimeSpan.FromSeconds(1));
}

Sample project(s) available on GitHub

Wiring Example

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

Bh1900NuxMeadow Pin
GNDGND
VCC3.3V
SCLD08
SDAD07

Class Bh1900Nux

Represents a Bh1900Nux temperature sensor

Assembly: Bh1900Nux.dll
View Source
Declaration
public class Bh1900Nux : ByteCommsSensorBase<Temperature>, IObservable<IChangeResult<Temperature>>, IDisposable, ITemperatureSensor, ISamplingSensor<Temperature>, ISensor<Temperature>, ISensor, ISamplingSensor, II2cPeripheral

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

Implements:
System.IObservable<Meadow.IChangeResult<Meadow.Units.Temperature>>, System.IDisposable, Meadow.Peripherals.Sensors.ITemperatureSensor, Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Temperature>, Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Temperature>, Meadow.Peripherals.Sensors.ISensor, Meadow.Peripherals.Sensors.ISamplingSensor, Meadow.Hardware.II2cPeripheral

Properties

Temperature

The current temperature

View Source
Declaration
public Temperature? Temperature { get; }

DefaultI2cAddress

The default I2C address for the peripheral

View Source
Declaration
public byte DefaultI2cAddress { get; }

MeasurementMode

The measurement mode

View Source
Declaration
public Bh1900Nux.MeasurementModes MeasurementMode { get; set; }

FaultQueueDepth

The fault queue depth

View Source
Declaration
public Bh1900Nux.FaultQueue FaultQueueDepth { get; set; }

AlertPolarity

The alert polarity

View Source
Declaration
public Bh1900Nux.Polarity AlertPolarity { get; set; }

AlertIsActive

Is the alert active

View Source
Declaration
public bool AlertIsActive { get; }

LowLimit

The temperature low limit

View Source
Declaration
public Temperature LowLimit { get; set; }

HighLimit

The temperature high limit

View Source
Declaration
public Temperature HighLimit { get; set; }

Methods

Reset()

Reset the sensor

View Source
Declaration
public void Reset()

Sleep()

Set the sensor to sleep state

View Source
Declaration
public void Sleep()

Wake()

Wake the device

View Source
Declaration
public void Wake()

ReadSensor()

Read the temperature

View Source
Declaration
protected override Task<Temperature> ReadSensor()
Returns

System.Threading.Tasks.Task<Meadow.Units.Temperature>: The current temperature value

Implements

  • System.IObservable<Meadow.IChangeResult<Meadow.Units.Temperature>>
  • System.IDisposable
  • Meadow.Peripherals.Sensors.ITemperatureSensor
  • Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Temperature>
  • Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Temperature>
  • Meadow.Peripherals.Sensors.ISensor
  • Meadow.Peripherals.Sensors.ISamplingSensor
  • Meadow.Hardware.II2cPeripheral