Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
INA219 Class Reference
INA219 High-Side Measurement,Bi-Directional CURRENT/POWER MONITOR with I2C Interface. More...
#include <INA219.h>
Public Member Functions | |
| INA219 (PinName p_sda, PinName p_scl, const INA219_TypeDef *ina219_parameter) | |
| Configure data pin. | |
| INA219 (I2C &p_i2c, const INA219_TypeDef *ina219_parameter) | |
| Configure data pin (with other devices on I2C line) | |
| float | read_current (void) |
| Read Current data. | |
| float | read_power (void) |
| Read Power data. | |
| float | read_bus_voltage (void) |
| Read Bus voltage. | |
| float | read_shunt_voltage (void) |
| Read Shunt voltage data. | |
| uint16_t | read_config (void) |
| Read configration reg. | |
| uint16_t | set_config (uint16_t cfg) |
| Set configration reg. | |
| uint16_t | read_calb (void) |
| Read calibration reg. | |
| uint16_t | set_calb (uint16_t clb) |
| Set calibration reg. | |
| void | frequency (int hz) |
| Set I2C clock frequency. | |
| uint8_t | read_reg (uint8_t addr) |
| Read register (general purpose) | |
| uint8_t | write_reg (uint8_t addr, uint8_t data) |
| Write register (general purpose) | |
Detailed Description
INA219 High-Side Measurement,Bi-Directional CURRENT/POWER MONITOR with I2C Interface.
//--------- Default setting ----------------- #include "mbed.h" #include "INA219.h" // I2C Communication INA219 current(dp5, dp27, INA219_ADDR_GG); // If you connected I2C line not only this device but also other devices, // you need to declare following method. I2C i2c(dp5, dp27); INA219 current(I2C& p_i2c, INA219_ADDR_GG); int main() { while(1){ printf("I=%+6.3f [mA]\r\n", current.read_current()); wait(1.0): } } //--------- Detail setting ----------------- #include "mbed.h" #include "INA219.h" const INA219_TypeDef ina219_my_paramtr = { // I2C Address INA219_ADDR_GG, // CONFIG Reg. INA219_PAR_R_100MOHM, // 100 milli-ohm INA219_CFG_B16V, // 16V max INA219_PAR_G_40MV, // Gain x1 INA219_PAR_M_SHNTBUS_CONT,// Measure continuously // CALIB 16384 // Calibration data is nothing }; I2C i2c(dp5,dp27); INA219 current(I2C& p_i2c, &ina219_my_paramtr); int main() { while(1){ printf("I=%+6.3f [mA]\r\n", current.read_current()); wait(1.0): } }
Definition at line 182 of file INA219.h.
Constructor & Destructor Documentation
| INA219 | ( | PinName | p_sda, |
| PinName | p_scl, | ||
| const INA219_TypeDef * | ina219_parameter | ||
| ) |
Configure data pin.
- Parameters:
-
data SDA and SCL pins parameter address chip (INA219_TypeDef) or just set address or just port
Definition at line 16 of file INA219.cpp.
| INA219 | ( | I2C & | p_i2c, |
| const INA219_TypeDef * | ina219_parameter | ||
| ) |
Configure data pin (with other devices on I2C line)
- Parameters:
-
I2C previous definition parameter address chip (INA219_TypeDef) or just set address or just port
Definition at line 44 of file INA219.cpp.
Member Function Documentation
| void frequency | ( | int | hz ) |
| float read_bus_voltage | ( | void | ) |
| uint16_t read_calb | ( | void | ) |
Read calibration reg.
- Parameters:
-
none
- Returns:
- calibration register value
Definition at line 143 of file INA219.cpp.
| uint16_t read_config | ( | void | ) |
Read configration reg.
- Parameters:
-
none
- Returns:
- configrartion register value
Definition at line 122 of file INA219.cpp.
| float read_current | ( | void | ) |
| float read_power | ( | void | ) |
| uint8_t read_reg | ( | uint8_t | addr ) |
Read register (general purpose)
- Parameters:
-
register's address
- Returns:
- register data
Definition at line 164 of file INA219.cpp.
| float read_shunt_voltage | ( | void | ) |
Read Shunt voltage data.
- Parameters:
-
none
- Returns:
- voltage [v]
Definition at line 102 of file INA219.cpp.
| uint16_t set_calb | ( | uint16_t | clb ) |
Set calibration reg.
- Parameters:
-
@return calibration register value
Definition at line 153 of file INA219.cpp.
| uint16_t set_config | ( | uint16_t | cfg ) |
Set configration reg.
- Parameters:
-
@return configrartion register value
Definition at line 132 of file INA219.cpp.
| uint8_t write_reg | ( | uint8_t | addr, |
| uint8_t | data | ||
| ) |
Write register (general purpose)
- Parameters:
-
register's address data
- Returns:
- register data
Definition at line 172 of file INA219.cpp.
Generated on Wed Jul 13 2022 15:14:54 by
1.7.2