Adafruit INA237 and INA238 Arduino Library
Public Member Functions | Protected Member Functions | List of all members
Adafruit_INA237 Class Reference

Class that stores state and functions for interacting with INA237/INA238 Current and Power Sensors. More...

#include <Adafruit_INA237.h>

Inheritance diagram for Adafruit_INA237:
Adafruit_INA238

Public Member Functions

 Adafruit_INA237 ()
 Instantiates a new INA237 class.
 
bool begin (uint8_t i2c_addr=INA237_I2CADDR_DEFAULT, TwoWire *theWire=&Wire, bool skipReset=false)
 Sets up the HW. More...
 
INA237_AlertType getAlertType (void)
 Returns the current alert type. More...
 
void setAlertType (INA237_AlertType alert)
 Sets a new alert type. More...
 
float readDieTemp (void) override
 Reads the die temperature with the INA237-specific conversion factor. More...
 
float readBusVoltage (void) override
 Reads and scales the current value of the Bus Voltage register using INA237-specific conversion factor. More...
 
float readShuntVoltage (void) override
 Reads and scales the current value of the Shunt Voltage register using INA237-specific conversion factor. More...
 
float readCurrent (void) override
 Reads and scales the current value of the Current register using INA237-specific handling. More...
 
float readPower (void) override
 Reads and scales the current value of the Power register using INA237-specific handling. More...
 
void setShunt (float shunt_res=0.1, float max_current=3.2) override
 Sets the shunt calibration by resistor for INA237. More...
 

Protected Member Functions

void _updateShuntCalRegister (void) override
 Updates the shunt calibration value to the INA237 register. The INA237 uses a different calculation than the INA228.
 

Detailed Description

Class that stores state and functions for interacting with INA237/INA238 Current and Power Sensors.

Member Function Documentation

◆ begin()

bool Adafruit_INA237::begin ( uint8_t  i2c_address = INA237_I2CADDR_DEFAULT,
TwoWire *  theWire = &Wire,
bool  skipReset = false 
)

Sets up the HW.

Parameters
i2c_addressThe I2C address to be used.
theWireThe Wire object to be used for I2C connections.
skipResetWhen set to true, will omit resetting all INA237 registers to their default values. Default: false.
Returns
True if initialization was successful, otherwise false.

◆ getAlertType()

INA237_AlertType Adafruit_INA237::getAlertType ( void  )

Returns the current alert type.

Returns
The current alert type

◆ setAlertType()

void Adafruit_INA237::setAlertType ( INA237_AlertType  alert)

Sets a new alert type.

Parameters
alertThe new alert type to be set

◆ readDieTemp()

float Adafruit_INA237::readDieTemp ( void  )
override

Reads the die temperature with the INA237-specific conversion factor.

Returns
The current die temp in deg C

◆ readBusVoltage()

float Adafruit_INA237::readBusVoltage ( void  )
override

Reads and scales the current value of the Bus Voltage register using INA237-specific conversion factor.

Returns
The current bus voltage measurement in V

◆ readShuntVoltage()

float Adafruit_INA237::readShuntVoltage ( void  )
override

Reads and scales the current value of the Shunt Voltage register using INA237-specific conversion factor.

Returns
The current shunt voltage measurement in V

◆ readCurrent()

float Adafruit_INA237::readCurrent ( void  )
override

Reads and scales the current value of the Current register using INA237-specific handling.

Returns
The current measurement in mA

◆ readPower()

float Adafruit_INA237::readPower ( void  )
override

Reads and scales the current value of the Power register using INA237-specific handling.

Returns
The current Power calculation in mW

◆ setShunt()

void Adafruit_INA237::setShunt ( float  shunt_res = 0.1,
float  max_current = 3.2 
)
override

Sets the shunt calibration by resistor for INA237.

Parameters
shunt_resResistance of the shunt in ohms (floating point)
max_currentMaximum expected current in A (floating point)

The documentation for this class was generated from the following files: