INA234 HAL Based Library 1.0.1
This library is a software library that works with the INA234 current, voltage, and power monitor chip. This library provides a convenient and efficient way to access the I2C interfaces of the chip, allowing developers to easily integrate this power meter into their systems.
|
The INA234 device is a 12-bit digital current monitor with an I2C/SMBus-compatible interface that is compliant with a wide range of digital bus voltages such as 1.2 V, 1.8 V, 3.3 V, and 5.0 V. The device monitors the voltage across an external sense resistor and reports values for current, bus voltage, and power. (Click for more info)
This library is a software library that works with the INA234 current, voltage, and power monitor chip. This library provides a convenient and efficient way to access the I2C interfaces of the chip, allowing developers to easily integrate this power meter into their systems.
The library is designed to be easy to use and provides a simple, intuitive API for accessing the I2C interfaces of the INA234. It includes a range of functions for performing common I2C operations, such as sending and receiving data, querying the status of the chip, reading the measured parameters, and configuring the INA234 settings.
With this library, developers can quickly and easily integrate the INA234 into their systems, enabling them to take full advantage of the chip's capabilities.
The full documents are available here
Is it helpfull?
ina234.c
and ina234.h
file to your project directory and add them to your IDE if necessary.INA234_readAll
function to read the meassured data: Here is the whole code:
If you want to use UART or virtual USB COM port on youe microcontroller, it is recommended to use this print function:
By applying the above trick, you can simply use this one to see the variables on the serial terminal:
INA234 can assert an alert on several situations like convertion ready, over power, over current, bus over voltage, bus under voltage, etc. To initialize alert functionality, use INA234_alert_init
function:
Each argument is described on the doc page.
** NOTE1 ** If you choose ALERT_LATCHED
for alert latch mode, you have to reset the alert pin by calling INA234_resetAlert
function after each alert assertion. (see more)
** NOTE2 ** If you enabled convertion ready alert as well as limit reach functions (like shunt over voltage etc), you have to distinguish the alert source bt calling INA234_getAlertSource
function. (see more)
** NOTE3 ** The alert pin is open-drain. So don not forget to add a pull-up resistor on this pin.
You can read each parameter individually instead of INA234_readAll
by calling each of these functions:
INA234_getShuntVoltage(&ina234);
to read shunt voltage (in mV)INA234_getBusVoltage(&ina234);
to read bus voltage (in V)INA234_getPower(&ina234);
to read power (in W)INA234_getCurrent(&ina234);
to read current (in A)Example:
You can send a reset command to all of the INA234 chips on the same bus by calling INA234_SoftResetAll
function. (see more)
You can change each of the configurations on the fly using these functions:
INA234_setADCRange
to change the ADC full scale range (see more)INA234_setNumberOfADCSamples
to change the number of averaging ADC samples (see more)INA234_setVBusConversionTime
to change the conversion period of VBus (see more)INA234_setVShuntConversionTime
to change the conversion period of VBus (see more)INA234_setMode
to change the operating mode (see more)If you want to get the manufacturer or device ID, you can use these functions:
For example:
INA234 can also give the state of internal modules like CPU and memory. By calling INA234_getErrors
function you can see if there is any error or not. (see more)