API Reference

adafruit_ina228

CircuitPython driver for the INA228 I2C 85V, 20-bit High or Low Side Power Monitor

  • Author(s): Liz Clark

Implementation Notes

Hardware:

Software and Dependencies:

class adafruit_ina228.AlertType

Alert type constants for INA2XX

class adafruit_ina228.AveragingCount

Averaging count constants for INA2XX

class adafruit_ina228.ConversionTime

Conversion time constants for INA2XX

class adafruit_ina228.INA228(i2c_bus: busio.I2C, address: int = 0x40, skip_reset: bool = False)

Driver for the INA228 power and current sensor

property alert_flags: dict

All diagnostic and alert flags

Returns a dictionary with the status of each flag: - ‘ENERGYOF’: bool - Energy overflow - ‘CHARGEOF’: bool - Charge overflow - ‘MATHOF’: bool - Math overflow - ‘TMPOL’: bool - Temperature overlimit - ‘SHNTOL’: bool - Shunt voltage overlimit - ‘SHNTUL’: bool - Shunt voltage underlimit - ‘BUSOL’: bool - Bus voltage overlimit - ‘BUSUL’: bool - Bus voltage underlimit - ‘POL’: bool - Power overlimit - ‘CNVRF’: bool - Conversion ready - ‘MEMSTAT’: bool - ADC conversion status

property alert_type: int

Alert type configuration.

property bus_voltage: float

Bus voltage in volts.

property bus_voltage_overlimit: float

Bus voltage overlimit threshold in volts

property bus_voltage_underlimit: float

Bus voltage underlimit threshold in volts

property charge: float

Accumulated charge in coulombs

clear_overflow_flags() None

Clear energy, charge, and math overflow flags

property conversion_ready: bool

Check if conversion is complete.

property current: float

Current in amperes.

property die_temperature: float

Die temperature in degrees Celsius.

property energy: float

Energy measurement in Joules

property power: float

Power in watts.

property power_limit: float

Power overlimit threshold in watts

reset_accumulators() None

Reset the energy and charge accumulators

set_calibration(shunt_res: float = 0.015, max_current: float = 10.0) None

Set the calibration based on shunt resistance and maximum expected current.

Parameters:
  • shunt_res (float) – Shunt resistance in ohms

  • max_current (float) – Maximum expected current in amperes

set_calibration_16V_400mA() None

Configure for 16V and up to 400mA measurements

set_calibration_32V_1A() None

Configure for 32V and up to 1A measurements

set_calibration_32V_2A() None

Configure for 32V and up to 2A measurements

property shunt_tempco: int

Shunt temperature coefficient in ppm/°C

property shunt_voltage: float

Shunt voltage in volts.

property shunt_voltage_overlimit: float

Shunt voltage overlimit threshold in volts

property shunt_voltage_underlimit: float

Shunt voltage underlimit threshold in volts

property temperature_limit: float

Temperature overlimit threshold in degrees Celsius

trigger_measurement() None

Trigger a one-shot measurement when in triggered mode

class adafruit_ina228.INA2XX(i2c_bus: busio.I2C, address: int = _INA2XX_DEFAULT_ADDR, skip_reset: bool = False)

Base driver for INA2XX series power and current sensors.

Parameters:
  • i2c_bus (I2C) – The I2C bus the INA2XX is connected to.

  • address (int) – The I2C device address. Defaults to 0x40

  • skip_reset (bool) – Skip resetting the device on init. Defaults to False.

property adc_range: int

ADC range setting. 0 = ±163.84mV, 1 = ±40.96mV

property alert_latch: int

Alert latch enable. 0 = transparent, 1 = latched.

property alert_polarity: int

Alert pin polarity. 0 = active high, 1 = active low.

property averaging_count: int

Number of samples to average.

property bus_voltage_conv_time: int

Bus voltage conversion time setting.

property device_id: int

Device ID

property mode: int

Operating mode of the sensor.

reset() None

Reset the sensor to default configuration.

property shunt_resistance: float

The shunt resistance in ohms.

property shunt_voltage_conv_time: int

Shunt voltage conversion time setting.

property temp_conv_time: int

Temperature conversion time setting.

class adafruit_ina228.Mode

Operating mode constants for INA2XX