adafruit_ina3221

CircuitPython driver for the INA3221 Triple 0-26 VDC, ±3.2 Amp Power Monitor

  • Author(s): Liz Clark

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_ina3221.AVG_MODE

Enumeration for the averaging mode options in INA3221.

AVG_1_SAMPLE

Average 1 sample.

Type:

int

AVG_4_SAMPLES

Average 4 samples.

Type:

int

AVG_16_SAMPLES

Average 16 samples.

Type:

int

AVG_64_SAMPLES

Average 64 samples.

Type:

int

AVG_128_SAMPLES

Average 128 samples.

Type:

int

AVG_256_SAMPLES

Average 256 samples.

Type:

int

AVG_512_SAMPLES

Average 512 samples.

Type:

int

AVG_1024_SAMPLES

Average 1024 samples.

Type:

int

class adafruit_ina3221.CONV_TIME

Enumeration for conversion time options in INA3221.

CONV_TIME_140US

Conversion time 140µs.

Type:

int

CONV_TIME_204US

Conversion time 204µs.

Type:

int

CONV_TIME_332US

Conversion time 332µs.

Type:

int

CONV_TIME_588US

Conversion time 588µs.

Type:

int

CONV_TIME_1MS

Conversion time 1ms.

Type:

int

CONV_TIME_2MS

Conversion time 2ms.

Type:

int

CONV_TIME_4MS

Conversion time 4ms.

Type:

int

CONV_TIME_8MS

Conversion time 8ms.

Type:

int

class adafruit_ina3221.INA3221(i2c, address: int = DEFAULT_ADDRESS, enable: List = [0, 1, 2], probe: bool = True)

Driver for the INA3221 device with three channels.

Initializes the INA3221 class over I2C :param i2c: The I2C bus to which the INA3221 is connected. :type i2c: I2C :param address: The I2C address of the INA3221. Defaults to DEFAULT_ADDRESS. :type address: int, optional :param enable: channels to initialize at start (default: all) :type enable: List[int], optional :param probe: Probe for the device upon object creation, default is true :type probe: bool, optional

property averaging_mode: int

Averaging mode.

Returns:

The current averaging mode (0-7). 0: 1 SAMPLE, 1: 4_SAMPLES, 2: 16_SAMPLES, 3: 64_SAMPLES, 4: 128_SAMPLES, 5: 256_SAMPLES, 6: 512_SAMPLES, 7: 1024_SAMPLES

Return type:

int

property bus_voltage_conv_time: int

Bus voltage conversion time.

Returns:

The current bus voltage conversion time (0-7). 0: 140µs, 1: 204µs, 2: 332µs, 3: 588µs, 4: 1ms, 5: 2ms, 6: 4ms, 7: 8ms

Return type:

int

property die_id: int

Die ID of the INA3221.

Returns:

The Die ID in integer format.

Return type:

int

property flags: int

Flag indicators from the Mask/Enable register.

Returns:

The current flag indicators from the Mask/Enable register, masked for relevant flag bits.

Return type:

int

property manufacturer_id: int

Manufacturer ID of the INA3221.

Returns:

The Manufacturer ID in integer format.

Return type:

int

property mode: int

Operating mode of the INA3221.

Returns:

The current mode value. 0: Power down mode, 1: Trigger shunt voltage measurement, 2: Trigger bus voltage measurement, 3: Trigger both shunt and bus voltage measurements, 4: Alternate power down mode, 5: Continuous shunt voltage measurement, 6: Continuous bus voltage measurement, 7: Continuous shunt and bus voltage measurements

Return type:

int

property power_valid_limits: tuple

Power-Valid upper and lower voltage limits in volts.

Returns:

A tuple containing the lower and upper voltage limits in volts as (lower_limit, upper_limit).

Return type:

tuple

reset() None

Perform a soft reset on the INA3221.

Returns:

None

property shunt_voltage_conv_time: int

Shunt voltage conversion time.

Returns:

The current shunt voltage conversion time (0-7). 0: 140µs, 1: 204µs, 2: 332µs, 3: 588µs, 4: 1ms, 5: 2ms, 6: 4ms, 7: 8ms

Return type:

int

class adafruit_ina3221.INA3221Channel(device: Any, channel: int)

Represents a single channel of the INA3221.

Parameters:
  • device (Any) – The device INA3221 instance managing the I2C communication.

  • channel (int) – The channel number (1, 2, or 3) for this instance.

property bus_voltage: float

Bus voltage in volts.

property critical_alert_threshold: float

Critical-Alert threshold in amperes

Returns:

The current critical alert threshold in amperes.

Return type:

float

property current: float

Returns the current in mA

The current is calculated using the formula: I = Vshunt / Rshunt. If the shunt voltage is NaN (e.g., no valid measurement), it returns NaN.

enable(flag: bool = True) None

Enable/disable this channel

property enabled: bool

return buffered enable-state

property shunt_resistance: float

Shunt resistance in ohms.

property shunt_voltage: float

Shunt voltage in millivolts.

property summation_channel: bool

Status of summation channel

property warning_alert_threshold: float

Warning-Alert threshold in amperes

Returns:

The current warning alert threshold in amperes.

Return type:

float

class adafruit_ina3221.MODE

Enumeration for operating modes in INA3221.

POWER_DOWN

Power down mode.

Type:

int

SHUNT_TRIG

Trigger shunt voltage measurement.

Type:

int

BUS_TRIG

Trigger bus voltage measurement.

Type:

int

SHUNT_BUS_TRIG

Trigger both shunt and bus voltage measurements.

Type:

int

POWER_DOWN2

Alternate power down mode.

Type:

int

SHUNT_CONT

Continuous shunt voltage measurement.

Type:

int

BUS_CONT

Continuous bus voltage measurement.

Type:

int

SHUNT_BUS_CONT

Continuous shunt and bus voltage measurements.

Type:

int