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