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

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