Skip to main content

Meadow.Foundation.Sensors.Power.Ina260

Ina260
StatusStatus badge: working
Source codeGitHub
Datasheet(s)GitHub
NuGet packageNuGet Gallery for Meadow.Foundation.Sensors.Power.Ina2xx

Code Example

Ina260 ina260;

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

var bus = Device.CreateI2cBus(I2cBusSpeed.Fast);
ina260 = new Ina260(bus);
ina260.Configure(Ina260.ConversionTime.ConversionTime_8244us, Ina260.ConversionTime.ConversionTime_8244us, Ina260.Averaging.Average_4);
//Resolver.SensorService.RegisterSensor(ina260);

Resolver.Log.Info($"--- INA260 Sample App ---");
Resolver.Log.Info($"Manufacturer: {ina260.ManufacturerID}");
Resolver.Log.Info($"DeviceID: 0x{ina260.DeviceID:X3}");
Resolver.Log.Info($"Revision: 0x{ina260.DeviceRevision:X2}");
ina260.Updated += (sender, result) =>
{
Resolver.Log.Info($"{result.New.Voltage:N3} V @ {result.New.Current:N3} A");
};

return Task.CompletedTask;
}

public override Task Run()
{
Resolver.Log.Debug("Run...");
ina260.StartUpdating(TimeSpan.FromSeconds(2));
return Task.CompletedTask;
}

Sample project(s) available on GitHub

Class Ina260

Represents a INA260 Precision Digital Current and Power Monitor

Assembly: Ina260.dll
View Source
Declaration
public class Ina260 : ByteCommsSensorBase<(Power? Power, Voltage? Voltage, Current? Current)>, IObservable<IChangeResult<(Power? Power, Voltage? Voltage, Current? Current)>>, ISamplingSensor<(Power? Power, Voltage? Voltage, Current? Current)>, ISensor<(Power? Power, Voltage? Voltage, Current? Current)>, ISensor, ISamplingSensor, IDisposable, II2cPeripheral

Inheritance: System.Object -> Meadow.Foundation.ObservableBase<UNIT>

Implements:
System.IObservable<Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Units.Power>,System.Nullable<Meadow.Units.Voltage>,System.Nullable<Meadow.Units.Current>>>>, Meadow.Peripherals.Sensors.ISamplingSensor<System.ValueTuple<System.Nullable<Meadow.Units.Power>,System.Nullable<Meadow.Units.Voltage>,System.Nullable<Meadow.Units.Current>>>, Meadow.Peripherals.Sensors.ISensor<System.ValueTuple<System.Nullable<Meadow.Units.Power>,System.Nullable<Meadow.Units.Voltage>,System.Nullable<Meadow.Units.Current>>>, Meadow.Peripherals.Sensors.ISensor, Meadow.Peripherals.Sensors.ISamplingSensor, System.IDisposable, Meadow.Hardware.II2cPeripheral

Properties

DefaultI2cAddress

The default I2C address for the peripheral

View Source
Declaration
public byte DefaultI2cAddress { get; }

Current

The value of the current (in Amps) flowing through the shunt resistor from the last reading

View Source
Declaration
public Current? Current { get; }

Voltage

The voltage from the last reading..

View Source
Declaration
public Voltage? Voltage { get; }

Power

The power from the last reading..

View Source
Declaration
public Power? Power { get; }

ManufacturerID

Reads the unique manufacturer identification number

View Source
Declaration
public int ManufacturerID { get; }

DieID

Reads the unique die identification number

View Source
Declaration
public int DieID { get; }

Methods

ReadSensor()

Reads data from the sensor

View Source
Declaration
protected override Task<(Power? Power, Voltage? Voltage, Current? Current)> ReadSensor()
Returns

System.Threading.Tasks.Task<System.ValueTuple<System.Nullable<Meadow.Units.Power>,System.Nullable<Meadow.Units.Voltage>,System.Nullable<Meadow.Units.Current>>>: The latest sensor reading### RaiseEventsAndNotify(IChangeResult<(Power? Power, Voltage? Voltage, Current? Current)>) Raise events for subscribers and notify of value changes

View Source
Declaration
protected override void RaiseEventsAndNotify(IChangeResult<(Power? Power, Voltage? Voltage, Current? Current)> changeResult)
Parameters
TypeNameDescription
Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Units.Power>,System.Nullable<Meadow.Units.Voltage>,System.Nullable<Meadow.Units.Current>>>changeResultThe updated sensor data

Events

PowerUpdated

Raised when the power value changes

View Source
Declaration
public event EventHandler<IChangeResult<Power>> PowerUpdated
Event Type

System.EventHandler<Meadow.IChangeResult<Meadow.Units.Power>>

VoltageUpdated

Raised when the voltage value changes

View Source
Declaration
public event EventHandler<IChangeResult<Voltage>> VoltageUpdated
Event Type

System.EventHandler<Meadow.IChangeResult<Meadow.Units.Voltage>>

CurrentUpdated

Raised when the current value changes

View Source
Declaration
public event EventHandler<IChangeResult<Current>> CurrentUpdated
Event Type

System.EventHandler<Meadow.IChangeResult<Meadow.Units.Current>>

Implements

  • System.IObservable<Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Units.Power>,System.Nullable<Meadow.Units.Voltage>,System.Nullable<Meadow.Units.Current>>>>
  • Meadow.Peripherals.Sensors.ISamplingSensor<System.ValueTuple<System.Nullable<Meadow.Units.Power>,System.Nullable<Meadow.Units.Voltage>,System.Nullable<Meadow.Units.Current>>>
  • Meadow.Peripherals.Sensors.ISensor<System.ValueTuple<System.Nullable<Meadow.Units.Power>,System.Nullable<Meadow.Units.Voltage>,System.Nullable<Meadow.Units.Current>>>
  • Meadow.Peripherals.Sensors.ISensor
  • Meadow.Peripherals.Sensors.ISamplingSensor
  • System.IDisposable
  • Meadow.Hardware.II2cPeripheral