Remarks

Ina260
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Ina260

Code Example

public MeadowApp()
{
    Console.WriteLine("Initialize...");
    var bus = Device.CreateI2cBus();
    var ina = new Ina260(bus);

    Console.WriteLine($"-- INA260 Sample App ---");
    Console.WriteLine($"Manufacturer: {ina.ManufacturerID}");
    Console.WriteLine($"Die: {ina.DieID}");
    ina.Updated += (s, v) =>
    {
        Console.WriteLine($"{v.New.Item2}V @ {v.New.Item3}A");
    };

    ina.StartUpdating(TimeSpan.FromSeconds(2));
}

Sample project(s) available on GitHub

Characteristic Locus
Inheritance System.Object ObservableBase<System.ValueTuple<System.Nullable<Units.Power>, System.Nullable<Units.Voltage>, System.Nullable<Units.Current>>> SensorBase<System.ValueTuple<System.Nullable<Units.Power>, System.Nullable<Units.Voltage>, System.Nullable<Units.Current>>> SamplingSensorBase<System.ValueTuple<System.Nullable<Units.Power>, System.Nullable<Units.Voltage>, System.Nullable<Units.Current>>> ByteCommsSensorBase<System.ValueTuple<System.Nullable<Units.Power>, System.Nullable<Units.Voltage>, System.Nullable<Units.Current>>> > Ina260
Implements IDisposable
Inherited Members ByteCommsSensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.Peripheral ByteCommsSensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.ReadBuffer ByteCommsSensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.WriteBuffer ByteCommsSensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.Init(Int32, Int32) ByteCommsSensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.Dispose(Boolean) ByteCommsSensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.Dispose() SamplingSensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.StartUpdating(Nullable<TimeSpan>) SamplingSensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.StopUpdating() SensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.Updated SensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.samplingLock SensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.SamplingTokenSource SensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.Conditions SensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.IsSampling SensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.UpdateInterval SensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.ReadSensor() SensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.RaiseEventsAndNotify(IChangeResult<ValueTuple<Nullable<Units.Power>, Nullable<Units.Voltage>, Nullable<Units.Current>>>) SensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.Read() ObservableBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.observers ObservableBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.NotifyObservers(IChangeResult<ValueTuple<Nullable<Units.Power>, Nullable<Units.Voltage>, Nullable<Units.Current>>>) Meadow.Foundation.ObservableBase<System.ValueTuple<System.Nullable<Units.Power>, System.Nullable<Units.Voltage>, System.Nullable<Units.Current>>>.Subscribe(IObserver<>) Meadow.Foundation.ObservableBase<System.ValueTuple<System.Nullable<Units.Power>, System.Nullable<Units.Voltage>, System.Nullable<Units.Current>>>.CreateObserver(Action<>, System.Nullable<Predicate<Meadow.IChangeResult<UNIT>>>)
Namespace Meadow.Foundation.Sensors.Power
Assembly Ina260.dll

Syntax

public class Ina260 : ByteCommsSensorBase<(Units.Power? Power, Units.Voltage? Voltage, Units.Current? Current)>, IDisposable

Constructors

Ina260(II2cBus, Byte, Int32)

Declaration
public Ina260(II2cBus i2cBus, byte address = null, int updateIntervalMs = 1000)

Parameters

Type Name Description
II2cBus i2cBus
System.Byte address
System.Int32 updateIntervalMs

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)>)

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

ReadSensor()

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>>>

Overrides

Meadow.Foundation.SensorBase<System.ValueTuple<System.Nullable<Units.Power>, System.Nullable<Units.Voltage>, System.Nullable<Units.Current>>>.ReadSensor()

Events

CurrentUpdated

Declaration
public event EventHandler<IChangeResult<Units.Current>> CurrentUpdated

Event Type

Type Description
EventHandler<IChangeResult<Units.Current>>

PowerUpdated

Declaration
public event EventHandler<IChangeResult<Units.Power>> PowerUpdated

Event Type

Type Description
EventHandler<IChangeResult<Units.Power>>

VoltageUpdated

Declaration
public event EventHandler<IChangeResult<Units.Voltage>> VoltageUpdated

Event Type

Type Description
EventHandler<IChangeResult<Units.Voltage>>