1
1
// FILE: INA219.h
2
2
// AUTHOR: Rob Tillaart
3
- // VERSION: 0.3.0
3
+ // VERSION: 0.3.1
4
4
// DATE: 2021-05-18
5
5
// PURPOSE: Arduino library for INA219 voltage, current and power sensor
6
6
// URL: https://github.com/RobTillaart/INA219
@@ -40,7 +40,7 @@ INA219::INA219(const uint8_t address, TwoWire *wire)
40
40
{
41
41
_address = address;
42
42
_wire = wire;
43
- // not calibrated values by default.
43
+ // no calibrated values by default.
44
44
_current_LSB = 0 ;
45
45
_maxCurrent = 0 ;
46
46
_shunt = 0 ;
@@ -75,7 +75,7 @@ uint8_t INA219::getAddress()
75
75
float INA219::getShuntVoltage ()
76
76
{
77
77
uint16_t value = _readRegister (INA219_SHUNT_VOLTAGE);
78
- return value * 1e-5 ; // fixed 10 uV
78
+ return value * 1e-5 ; // fixed 10 uV
79
79
}
80
80
81
81
@@ -85,16 +85,16 @@ float INA219::getBusVoltage()
85
85
uint8_t flags = value & 0x03 ;
86
86
// math overflow handling
87
87
if (flags & 0x01 ) return -100 ;
88
- // if flags && 0x02 ==> convert flag; not handled
89
- float voltage = (value >> 3 ) * 4e-3 ; // fixed 4 mV
88
+ // if flags && 0x02 ==> convert flag; not handled
89
+ float voltage = (value >> 3 ) * 4e-3 ; // fixed 4 mV
90
90
return voltage;
91
91
}
92
92
93
93
94
94
float INA219::getPower ()
95
95
{
96
96
uint16_t value = _readRegister (INA219_POWER);
97
- return value * _current_LSB * 20 ;
97
+ return value * ( _current_LSB * 20 ); // fixed 20 Watt
98
98
}
99
99
100
100
// TODO CHECK
@@ -129,7 +129,7 @@ bool INA219::reset()
129
129
uint16_t config = _readRegister (INA219_CONFIGURATION);
130
130
config |= 0x8000 ;
131
131
uint16_t wrrv = _writeRegister (INA219_CONFIGURATION, config);
132
- // reset calibration
132
+ // reset calibration
133
133
_current_LSB = 0 ;
134
134
_maxCurrent = 0 ;
135
135
_shunt = 0 ;
0 commit comments