Skip to main content

Meadow.Foundation.Sensors.Temperature.Mcp9600

Mcp9600
StatusStatus badge: working
Source codeGitHub
Datasheet(s)GitHub
NuGet packageNuGet Gallery for Meadow.Foundation.Sensors.Temperature.Mcp960x

Code Example

Mcp9600 sensor;

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

sensor = new Mcp9600(Device.CreateI2cBus());

var consumer = Mcp9600.CreateObserver(
handler: result =>
{
Resolver.Log.Info($"Temperature New Value {result.New.TemperatureHot.Value.Celsius}C");
},
filter: null
);
sensor.Subscribe(consumer);

sensor.Updated += Sensor_Updated;
return Task.CompletedTask;
}

private void Sensor_Updated(object sender, IChangeResult<(Meadow.Units.Temperature? TemperatureHot, Meadow.Units.Temperature? TemperatureCold)> e)
{
Resolver.Log.Info($"Temperature hot: {e.New.TemperatureHot.Value.Celsius:n2}C, Temperature cold: {e.New.TemperatureCold.Value.Celsius:n2}C");
}

public override Task Run()
{
sensor.StartUpdating();
return Task.CompletedTask;
}

Sample project(s) available on GitHub