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.
Dependents: INA219-HelloWorld INA_219 Light example-ublox-cellular-psm ... more
INA219 Class Reference
A class to represent the INA219 breakout board from Adafruit. More...
#include <INA219.hpp>
Public Member Functions | |
| INA219 (PinName sda, PinName scl, int addr=0x40, int freq=100000, resolution_t res=RES_12BITS) | |
| Creates an instance of the INA219 device. | |
| int16_t | read_current_raw () |
| Reads the current raw value of current from the INA219. | |
| float | read_current_mA () |
| Reads the current from the INA219 and calculates the actual value in mA. | |
| void | calibrate_16v_400mA () |
| Reads the raw power value from the INA219. | |
Protected Member Functions | |
| void | write_register (uint8_t reg, uint8_t *data, int length) |
| Writes a uint8_t array to the specified I2C register. | |
| void | write_register_u16 (uint8_t reg, uint16_t data) |
| Writes a uint16_t to the specified I2C register. | |
| uint16_t | read_register_u16 (uint8_t reg) |
| Reads a value from the specified I2C register. | |
| void | write_null (uint8_t reg) |
| Writes nothing to a specified register. | |
Detailed Description
A class to represent the INA219 breakout board from Adafruit.
Definition at line 25 of file INA219.hpp.
Constructor & Destructor Documentation
| INA219 | ( | PinName | sda, |
| PinName | scl, | ||
| int | addr = 0x40, |
||
| int | freq = 100000, |
||
| resolution_t | res = RES_12BITS |
||
| ) |
Creates an instance of the INA219 device.
- Parameters:
-
sda An I2C data pin. scl An I2C clock pin. addr The I2C address of the INA219. (Default = 0x40) freq The I2C clock frequency. res The desired resolution of the INA219's ADC.
Definition at line 3 of file INA219.cpp.
Member Function Documentation
| void calibrate_16v_400mA | ( | ) |
Reads the raw power value from the INA219.
- See also:
- read_power_mW
- Returns:
- A value between -32768 and +32768. Depending on the calibration and configuration register values, the actual power can be calculated. Reads the power from the INA219 and calculates the actual value in mW.
- See also:
- read_power_raw
- Returns:
- A floating point value corresponding to the power being used in the circuit, in mW. Reads the raw shunt voltage value from the INA219.
- See also:
- read_shunt_voltage_mV
- Returns:
- A value between -32768 and +32768. Depending on the calibration and configuration register values, the actual shunt voltage can be calculated. Reads the shunt voltage from the INA219 and calculates the actual value in mV.
- See also:
- read_shunt_voltage_raw
- Returns:
- A floating point value corresponding to the potential difference across the current shunt, in mV. Reads the raw bus voltage.
- See also:
- read_bus_voltage
- Returns:
- A value between -32768 and +32768 corresponding to the bus voltage. Reads the bus voltage and uses it to calculate the actual bus voltage.
- See also:
- read_bus_voltage_raw
- Returns:
- A floating point value corresponding to the voltage of V+ (in V). Sets the calibration register.
Specifies a maximum bus voltage of 16V and maximum current of 400mA.
Definition at line 51 of file INA219.cpp.
| float read_current_mA | ( | ) |
Reads the current from the INA219 and calculates the actual value in mA.
- See also:
- read_current_raw
- Returns:
- A floating point value corresponding to the current flowing through the current shunt, in mA.
Definition at line 84 of file INA219.cpp.
| int16_t read_current_raw | ( | ) |
Reads the current raw value of current from the INA219.
- See also:
- read_current_mA
- Returns:
- A value between -32768 and +32768. Depending on the current calibration and configuration register values, the corresponding current can be calculated.
Definition at line 79 of file INA219.cpp.
| uint16_t read_register_u16 | ( | uint8_t | reg ) | [protected] |
Reads a value from the specified I2C register.
- See also:
- write_register
- write_register_u16
- Parameters:
-
reg (8-Bit) Register to be read from.
- Returns:
- The contents of the specified register, as a 16 bit integer.
Definition at line 38 of file INA219.cpp.
| void write_null | ( | uint8_t | reg ) | [protected] |
Writes nothing to a specified register.
(Used to tell the chip that we want to read from that register)
- See also:
- read_register_u16
- Parameters:
-
reg The register for nothing to be written to.
Definition at line 34 of file INA219.cpp.
| void write_register | ( | uint8_t | reg, |
| uint8_t * | data, | ||
| int | length | ||
| ) | [protected] |
Writes a uint8_t array to the specified I2C register.
- See also:
- write_register_u16
- Parameters:
-
reg (8-Bit) Register address to be written to. data An array of bytes with the data to be written. length The length of the array.
Definition at line 13 of file INA219.cpp.
| void write_register_u16 | ( | uint8_t | reg, |
| uint16_t | data | ||
| ) | [protected] |
Writes a uint16_t to the specified I2C register.
- See also:
- write_register
- Parameters:
-
reg (8-Bit) Register address to be written to. data (16-Bit) Data to be written.
Definition at line 24 of file INA219.cpp.
Generated on Tue Jul 12 2022 13:24:03 by
1.7.2
INA219 High Side Current Sensor