Skip to main content

Meadow.Foundation.Sensors.Environmental.MiniPID2

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

Code Example

MiniPID2 sensor;

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

sensor = new MiniPID2(Device.Pins.A01, MiniPID2.MiniPID2Type.PPB_WR);

var consumer = MiniPID2.CreateObserver(
handler: result =>
{
Resolver.Log.Info($"Observer: VOC concentration changed by threshold; new: {result.New.PartsPerBillion:N1}ppm");
},
filter: result =>
{
if (result.Old is { } oldCon &&
result.New is { } newCon)
{
return Math.Abs((newCon - oldCon).PartsPerMillion) > 10;
}
return false;
}
);

sensor?.Subscribe(consumer);

if (sensor != null)
{
sensor.Updated += (sender, result) =>
{
Resolver.Log.Info($" VOC Concentration: {result.New.PartsPerMillion:N1}ppm");
};
}

sensor?.StartUpdating(TimeSpan.FromSeconds(2));

return base.Initialize();
}

Sample project(s) available on GitHub