Remarks

Ina260
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet Gallery for Meadow.Foundation.Sensors.Power.Ina260

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

Characteristic Locus
Inheritance System.Object ObservableBase<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>>> PollingSensorBase<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 ISamplingSensor<System.ValueTuple<System.Nullable<Units.Power>, System.Nullable<Units.Voltage>, System.Nullable<Units.Current>>> ISamplingSensor<System.ValueTuple<System.Nullable<Units.Power>, System.Nullable<Units.Voltage>, System.Nullable<Units.Current>>> 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() PollingSensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.StartUpdating(Nullable<TimeSpan>) PollingSensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.StopUpdating() SamplingSensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.samplingLock SamplingSensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.Updated SamplingSensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.SamplingTokenSource SamplingSensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.Conditions SamplingSensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.IsSampling SamplingSensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.UpdateInterval SamplingSensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.ReadSensor() SamplingSensorBase<(Nullable<Units.Power> Power, Nullable<Units.Voltage> Voltage, Nullable<Units.Current> Current)>.RaiseEventsAndNotify(IChangeResult<>) SamplingSensorBase<(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<>) 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<IChangeResult<UNIT>>>)
Namespace Meadow.Foundation.Sensors.Power
Assembly Ina260.dll

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