Skip to content

jegjessing/INA745

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

INA745 Arduino Library

Arduino driver for the Texas Instruments INA745A-Q1 / INA745B-Q1 — a 40 V, 16-bit precision I²C digital power monitor with an integrated 800 µΩ EZShunt™. Because the shunt is on-die, the device ships fully calibrated and no SHUNT_CAL programming is needed.

Datasheet: INA745A-Q1 (SBOSAK9A, May 2025, revised October 2025).

Features

  • Reads bus voltage, current, power, die temperature, energy (40-bit) and charge (40-bit signed) over I²C.
  • Configurable operating mode (continuous / triggered / shutdown), per-input ADC conversion time (50 µs … 4.12 ms) and sample averaging (1 … 1024).
  • ALERT pin support: over/under current, bus over/under voltage, over-temperature, over-power, and conversion-ready, with latch and polarity options.
  • All measurements available in engineering units (V, A, W, °C, J, C) or as raw register values.
  • Connection check via the MANUFACTURER_ID register (0x5449 = "TI").

Supported Hardware

Part Variant Address pins (A1, A0)
INA745A-Q1 A 16 selectable addresses, 0x400x4F
INA745B-Q1 B 16 selectable addresses, 0x400x4F

The 800 µΩ integrated shunt sets the fixed full-scale range to ±39.32 A with a 1.2 mA/LSB current resolution. Bus voltage range is 0 – 40 V at 3.125 mV/LSB.

Installation

Arduino IDE

Either install from the built-in Library Manager (search INA745) or:

  1. Download the repository as a ZIP.
  2. SketchInclude LibraryAdd .ZIP Library….
  3. Select the downloaded ZIP.

PlatformIO

Add to your platformio.ini:

lib_deps = https://github.com/jegjessing/INA745.git

Quick Start

#include <Wire.h>
#include <INA745.h>

INA745 ina;

void setup() {
    Serial.begin(115200);
    Wire.begin();

    if (!ina.begin(INA745_ADDR_DEFAULT)) {     // 0x40 with A1=A0=GND
        Serial.println("INA745 not found");
        while (true) {}
    }

    ina.setAveraging(INA745_AVG_64);            // smoother readings
}

void loop() {
    Serial.print("Vbus="); Serial.print(ina.busVoltage(), 3);     // V
    Serial.print(" I=");   Serial.print(ina.current() * 1000, 2); // mA
    Serial.print(" P=");   Serial.print(ina.power(), 3);          // W
    Serial.print(" T=");   Serial.print(ina.dieTemperature(), 1); // °C
    Serial.println();
    delay(500);
}

Examples

Sketch Purpose
BasicMeasurement Continuous-conversion loop printing V/I/P/T.
TriggeredSingleShot Wakes the device once per period, polls CNVRF, reads, returns to shutdown.
AlertOnOvercurrent Latched over-current alert on the ALERT pin via an interrupt.

API Reference

Construction & lifecycle

Method Description
INA745() Constructor. Uses Wire and address 0x40 until begin() overrides them.
bool begin(uint8_t address = 0x40, TwoWire *wire = &Wire) Verifies the device by reading MANUFACTURER_ID. Returns true if 0x5449 is read.
bool reset() Soft-reset (sets CONFIG.RST).
bool resetAccumulators() Clears the ENERGY and CHARGE registers (sets CONFIG.RSTACC).

ADC and conversion configuration

Method Notes
setMode(INA745_Mode) Continuous / triggered combinations or shutdown.
setBusConvTime(INA745_ConvTime) 50 µs … 4120 µs (default 1052 µs).
setShuntConvTime(INA745_ConvTime) Current conversion time = shunt + temp.
setTempConvTime(INA745_ConvTime) As above.
setAveraging(INA745_Avg) 1, 4, 16, 64, 128, 256, 512, 1024.
setConvDelay(uint8_t steps2ms) 0 … 510 ms initial delay before first conversion.

Measurements (engineering units)

Method Unit Notes
float busVoltage() V 0 … 40 V, 3.125 mV/LSB.
float current() A Signed, 1.2 mA/LSB.
float power() W 240 µW/LSB, unsigned.
float dieTemperature() °C 125 m°C/LSB, signed (12-bit).
double energy() J 3.84 mJ/LSB, 40-bit unsigned.
double charge() C 75 µC/LSB, 40-bit signed.

Raw counterparts are also exposed: busVoltageRaw(), currentRaw(), powerRaw() (24-bit), dieTemperatureRaw() (sign-extended from 12-bit), energyRaw() (40-bit), chargeRaw() (40-bit signed).

Alert thresholds

Each takes a value in the same engineering unit as the matching measurement and writes the corresponding limit register (COL, CUL, BOVL, BUVL, TEMP_LIMIT, PWR_LIMIT):

ina.setCurrentOverLimit(2.5f);     // amperes
ina.setCurrentUnderLimit(-0.5f);
ina.setBusOverVoltage(28.0f);      // volts (>= 0)
ina.setBusUnderVoltage(10.0f);
ina.setTemperatureOverLimit(85.0f); // °C
ina.setPowerOverLimit(50.0f);       // watts (61.44 mW/LSB)

Alert behaviour and diagnostics

Method Description
setAlertLatched(bool) Latched (cleared by reading DIAG_ALRT) vs. transparent.
setAlertPolarityInverted(bool) Active-low (default) vs. active-high (still open-drain).
setAlertOnAveraged(bool) Trigger on averaged value rather than every ADC sample.
enableConversionReadyAlert(bool) Pulse ALERT when a conversion completes.
uint16_t readDiagAlert() Read raw DIAG_ALRT register; reading clears latched flags.
bool conversionReady() Convenience: DIAG_ALRT.CNVRF is set.
uint16_t manufacturerID() Should always return 0x5449.

Bit masks for DIAG_ALRT are exposed as INA745_DIAG_* macros (INA745_DIAG_CURRENTOL, INA745_DIAG_BUSUL, INA745_DIAG_CNVRF, etc.).

Low-level register access

If you need to poke at registers directly:

bool writeRegister16(uint8_t reg, uint16_t value);
bool readRegister16(uint8_t reg, uint16_t &value);
bool readRegister24(uint8_t reg, uint32_t &value);
bool readRegister40(uint8_t reg, uint8_t bytes[5]); // MSB first

Register address constants are exposed as INA745_REG_*.

Notes and caveats

  • Triggered mode updates VBUS / CURRENT / DIETEMP / POWER on each trigger, but does not accumulate ENERGY or CHARGE — those only update in continuous mode.
  • The 12-bit DIETEMP value is sign-extended by an arithmetic right shift on a int16_t. This is the natural behaviour on every Arduino toolchain (AVR / ARM / Xtensa GCC) but is technically implementation-defined for negative values before C++20.
  • The integrated shunt has a ±0.5 % temperature coefficient; the library does not apply any temperature compensation since the measurement engine inside the chip already does that.

License

MIT — see LICENSE if included. If a LICENSE file is not present yet, treat the contents of this repository as MIT-licensed unless stated otherwise.

Contributing

Issues and pull requests are welcome. If you have hardware and bench measurements to validate the conversion math, that's especially helpful — the initial version was written from the datasheet only.

About

INA745x Arduino Library

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages