Table of Contents

Class Ina219

Namespace
Pamoja.Sensors
Assembly
Pamoja.Sensors.dll

A TI INA219 current, voltage, and power monitor.

public static class Ina219
Inheritance
Ina219
Inherited Members

Methods

BusMillivolts(ushort)

Converts a raw bus-voltage register to millivolts.

public static uint BusMillivolts(ushort raw)

Parameters

raw ushort

The register value.

Returns

uint

The bus voltage.

BusRegister(uint)

Builds the bus-voltage register a monitor reports for a bus voltage.

public static ushort BusRegister(uint millivolts)

Parameters

millivolts uint

The bus voltage in millivolts.

Returns

ushort

The register value, with the conversion-ready flag set.

Calibration(uint, uint)

Computes the calibration register for a shunt and resolution.

public static ushort Calibration(uint currentLsbMicroamps, uint shuntMilliohms)

Parameters

currentLsbMicroamps uint

The microamps per count wanted.

shuntMilliohms uint

The shunt resistor value.

Returns

ushort

The register value to write.

ConversionReady(ushort)

Reports whether a bus-voltage register says a conversion is ready.

public static bool ConversionReady(ushort raw)

Parameters

raw ushort

The register value.

Returns

bool

Whether the conversion-ready flag is set.

CurrentMicroamps(short, uint)

Converts a raw current register to microamps.

public static int CurrentMicroamps(short raw, uint currentLsbMicroamps)

Parameters

raw short

The signed register value.

currentLsbMicroamps uint

The resolution the calibration selected.

Returns

int

The current.

CurrentRegister(int, uint)

Builds the current register a monitor reports for a current.

public static short CurrentRegister(int microamps, uint currentLsbMicroamps)

Parameters

microamps int

The current in microamps.

currentLsbMicroamps uint

The current LSB the calibration was set for.

Returns

short

The signed register value.

MathOverflow(ushort)

Reports whether a bus-voltage register flags a math overflow.

public static bool MathOverflow(ushort raw)

Parameters

raw ushort

The register value.

Returns

bool

Whether the current and power readings are meaningless, which means the calibration needs revisiting.

MinimumCurrentLsbMicroamps(uint)

Returns the smallest resolution that still covers a maximum.

public static uint MinimumCurrentLsbMicroamps(uint maxExpectedMicroamps)

Parameters

maxExpectedMicroamps uint

The largest current measured.

Returns

uint

The minimum current LSB in microamps.

PowerMicrowatts(ushort, uint)

Converts a raw power register to microwatts.

public static uint PowerMicrowatts(ushort raw, uint currentLsbMicroamps)

Parameters

raw ushort

The register value.

currentLsbMicroamps uint

The resolution the calibration selected.

Returns

uint

The power. The power LSB is fixed at twenty times the current LSB.

PowerRegister(uint, uint)

Builds the power register a monitor reports for a power.

public static ushort PowerRegister(uint microwatts, uint currentLsbMicroamps)

Parameters

microwatts uint

The power in microwatts.

currentLsbMicroamps uint

The current LSB the calibration was set for.

Returns

ushort

The register value.

ShuntMicrovolts(short)

Converts a raw shunt-voltage register to microvolts.

public static int ShuntMicrovolts(short raw)

Parameters

raw short

The signed register value.

Returns

int

The shunt voltage.

ShuntRegister(int)

Builds the shunt-voltage register a monitor reports for a shunt voltage.

public static short ShuntRegister(int microvolts)

Parameters

microvolts int

The shunt voltage in microvolts.

Returns

short

The signed register value, at 10 uV per count.

Remarks

The inverse of ShuntMicrovolts(short), so a node can be written and tested against what a monitor sends without one attached.