Skip to content

Commit

Permalink
Issue #87
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnd Zanduino authored and Arnd Zanduino committed Jan 16, 2022
1 parent c4f58f2 commit f052476
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/INA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ int32_t INA_Class::getShuntMicroVolts(const uint8_t deviceNumber) {
if (ina.type == INA260) // INA260 has a built-in shunt
{
int32_t busMicroAmps = getBusMicroAmps(deviceNumber); // Get the amps on the bus from device
shuntVoltage = busMicroAmps / 200; // 2mOhm resistor, convert wiht Ohm's law
shuntVoltage = busMicroAmps / 200; // 2mOhm resistor, convert with Ohm's law
} else {
if (ina.type == INA228) {
shuntVoltage = shuntVoltage * ina.shuntVoltage_LSB / 10; // Convert to microvolts
Expand Down Expand Up @@ -709,6 +709,7 @@ int64_t INA_Class::getBusMicroWatts(const uint8_t deviceNumber) {
} else {
microWatts =
(int64_t)readWord(INA_POWER_REGISTER, ina.address) * (int64_t)ina.power_LSB / (int64_t)1000;
if (getShuntRaw(deviceNumber) < 0) microWatts *= -1; // Invert if negative voltage
} // of if-then-else an INA3221
return (microWatts);
} // of method getBusMicroWatts()
Expand Down
2 changes: 1 addition & 1 deletion src/INA.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Written by Arnd <[email protected]> at https://www.github.com/SV-Zanshin
| Version | Date | Developer | Comments
| ------- | ---------- | ----------- | --------
| 1.1.2 | 2021-05-13 | SV-Zanshin | Issue #77. Add support for INA228
| 1.1.2 | 2022-01-16 | Oleg-Sob | Issue #87. getBusMicroWatts() only returns positive values
| 1.1.1 | 2021-03-12 | x3mEr | Issue #79. Documentation Update
| 1.0.14 | 2020-12-01 | SV-Zanshin | Issue #72. Allow INA structures to be in memory rather than EEPROM
| 1.0.14 | 2020-11-30 | johntaves | Issue #64. begin() does not set values on subsequent calls
Expand Down

0 comments on commit f052476

Please sign in to comment.