Remarks
Lm75 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Lm75 lm75;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
lm75 = new Lm75(Device.CreateI2cBus());
var consumer = Lm75.CreateObserver(
handler: result =>
{
Resolver.Log.Info($"Temperature New Value { result.New.Celsius}C");
Resolver.Log.Info($"Temperature Old Value { result.Old?.Celsius}C");
},
filter: null
);
lm75.Subscribe(consumer);
lm75.TemperatureUpdated += (object sender, IChangeResult<Meadow.Units.Temperature> e) =>
{
Resolver.Log.Info($"Temperature Updated: {e.New.Celsius:n2}C");
};
return Task.CompletedTask;
}
public override async Task Run()
{
var temp = await lm75.Read();
Resolver.Log.Info($"Temperature New Value {temp.Celsius}C");
lm75.StartUpdating();
}
Sample project(s) available on GitHub
Syntax
public class Lm75 : ByteCommsSensorBase<Units.Temperature>, ISamplingSensor<Units.Temperature>, ISamplingSensor<Units.Temperature>, IDisposable, ITemperatureSensor
Constructors
Lm75(II2cBus, Byte)
Create a new TMP102 object using the default configuration for the sensor
Declaration
public Lm75(II2cBus i2cBus, byte address = null)
Parameters
Type | Name | Description |
---|---|---|
II2cBus | i2cBus | The I2C bus |
System.Byte | address | I2C address of the sensor |
Properties
Temperature
The Temperature value from the last reading
Declaration
public Units.Temperature? Temperature { get; protected set; }
Property Value
Type | Description |
---|---|
System.Nullable<Units.Temperature> |
Methods
RaiseEventsAndNotify(IChangeResult<Units.Temperature>)
Raise events for subcribers and notify of value changes
Declaration
protected override void RaiseEventsAndNotify(IChangeResult<Units.Temperature> changeResult)
Parameters
Type | Name | Description |
---|---|---|
IChangeResult<Units.Temperature> | changeResult | The updated sensor data |
ReadSensor()
Update the Temperature property
Declaration
protected override Task<Units.Temperature> ReadSensor()
Returns
Type | Description |
---|---|
Task<Units.Temperature> |
Overrides
Meadow.Foundation.SamplingSensorBase<Units.Temperature>.ReadSensor()
Events
TemperatureUpdated
Raised when the value of the reading changes
Declaration
public event EventHandler<IChangeResult<Units.Temperature>> TemperatureUpdated
Event Type
Type | Description |
---|---|
EventHandler<IChangeResult<Units.Temperature>> |