Remarks
Ina260 | |
---|---|
Status | |
Source code | GitHub |
Datasheet(s) | GitHub |
NuGet package |
Code Example
Ina260 ina260;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var bus = Device.CreateI2cBus();
ina260 = new Ina260(bus);
Resolver.Log.Info($"-- INA260 Sample App ---");
Resolver.Log.Info($"Manufacturer: {ina260.ManufacturerID}");
Resolver.Log.Info($"Die: {ina260.DieID}");
ina260.Updated += (s, v) =>
{
Resolver.Log.Info($"{v.New.Item2}V @ {v.New.Item3}A");
};
return Task.CompletedTask;
}
public override Task Run()
{
ina260.StartUpdating(TimeSpan.FromSeconds(2));
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Syntax
public class Ina260 : ByteCommsSensorBase<(Units.Power? Power, Units.Voltage? Voltage, Units.Current? Current)>, ISamplingSensor<(Units.Power? Power, Units.Voltage? Voltage, Units.Current? Current)>, ISamplingSensor<(Units.Power? Power, Units.Voltage? Voltage, Units.Current? Current)>, IDisposable
Constructors
Ina260(II2cBus, Byte)
Create a new INA260 object
Declaration
public Ina260(II2cBus i2cBus, byte address = null)
Parameters
Type | Name | Description |
---|---|---|
II2cBus | i2cBus | The I2C bus |
System.Byte | address | The I2C address |
Properties
Current
The value of the current (in Amps) flowing through the shunt resistor from the last reading
Declaration
public Units.Current? Current { get; }
Property Value
Type | Description |
---|---|
System.Nullable<Units.Current> |
DieID
Reads the unique die identification number
Declaration
public int DieID { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
ManufacturerID
Reads the unique manufacturer identification number
Declaration
public int ManufacturerID { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Power
The power from the last reading..
Declaration
public Units.Power? Power { get; }
Property Value
Type | Description |
---|---|
System.Nullable<Units.Power> |
Voltage
The voltage from the last reading..
Declaration
public Units.Voltage? Voltage { get; }
Property Value
Type | Description |
---|---|
System.Nullable<Units.Voltage> |
Methods
RaiseEventsAndNotify(IChangeResult<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>)
Raise events for subcribers and notify of value changes
Declaration
protected override void RaiseEventsAndNotify(IChangeResult<(Units.Power? Power, Units.Voltage? Voltage, Units.Current? Current)> changeResult)
Parameters
Type | Name | Description |
---|---|---|
IChangeResult<System.ValueTuple<System.Nullable<Units.Power>, System.Nullable<Units.Voltage>, System.Nullable<Units.Current>>> | changeResult | The updated sensor data |
ReadSensor()
Reads data from the sensor
Declaration
protected override Task<(Units.Power? Power, Voltage? Voltage, Current? Current)> ReadSensor()
Returns
Type | Description |
---|---|
Task<System.ValueTuple<System.Nullable<Units.Power>, System.Nullable<Voltage>, System.Nullable<Current>>> | The latest sensor reading |
Overrides
Meadow.Foundation.SamplingSensorBase<System.ValueTuple<System.Nullable<Units.Power>, System.Nullable<Units.Voltage>, System.Nullable<Units.Current>>>.ReadSensor()
Events
CurrentUpdated
Raised when the current value changes
Declaration
public event EventHandler<IChangeResult<Units.Current>> CurrentUpdated
Event Type
Type | Description |
---|---|
EventHandler<IChangeResult<Units.Current>> |
PowerUpdated
Raised when the power value changes
Declaration
public event EventHandler<IChangeResult<Units.Power>> PowerUpdated
Event Type
Type | Description |
---|---|
EventHandler<IChangeResult<Units.Power>> |
VoltageUpdated
Raised when the voltage value changes
Declaration
public event EventHandler<IChangeResult<Units.Voltage>> VoltageUpdated
Event Type
Type | Description |
---|---|
EventHandler<IChangeResult<Units.Voltage>> |