Skip to content

Commit 075a12a

Browse files
committed
0.4.2 INA226
1 parent 2a646f2 commit 075a12a

File tree

12 files changed

+172
-79
lines changed

12 files changed

+172
-79
lines changed

libraries/INA226/.github/workflows/arduino-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
lint:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v2
9+
- uses: actions/checkout@v3
1010
- uses: arduino/arduino-lint-action@v1
1111
with:
1212
library-manager: update

libraries/INA226/.github/workflows/arduino_test_runner.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99

1010
steps:
11-
- uses: actions/checkout@v2
11+
- uses: actions/checkout@v3
1212
- uses: ruby/setup-ruby@v1
1313
with:
1414
ruby-version: 2.6

libraries/INA226/.github/workflows/jsoncheck.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
test:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v3
1414
- name: json-syntax-check
1515
uses: limitusus/json-syntax-check@v1
1616
with:

libraries/INA226/CHANGELOG.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
1-
# Change Log I2CKeyPad8x8
1+
# Change Log INA226
22

33
All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this project adheres to [Semantic Versioning](http://semver.org/).
77

88

9+
## [0.4.2] - 2023-04-03
10+
11+
- added **getBusVoltage_uV()** for completeness
12+
- INA226_test_I2C.ino to prep performance tests
13+
- fix changelog.md
14+
- fix keywords.txt
15+
- update readme.md
16+
- update GitHub actions
17+
- update license 2023
18+
- minor edits
19+
20+
921
## [0.4.1] - 2022-11-12
1022
- Add RP2040 support to build-CI.
11-
- Add CHANGELOG.md - replaces release notes to be consistent over libraries.
23+
- Add CHANGELOG.md, replaces release_notes to be consistent over my libraries.
1224
- minor edit unit test
1325

14-
1526
## [0.4.0] - 2022-08-26
1627
- fix #16 - change error to warning for max current
1728
setMaxCurrentShunt now returns an int indicating OK == 0

libraries/INA226/INA226.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
// FILE: INA226.cpp
22
// AUTHOR: Rob Tillaart
3-
// VERSION: 0.4.1
3+
// VERSION: 0.4.2
44
// DATE: 2021-05-18
55
// PURPOSE: Arduino library for INA226 power sensor
66
// URL: https://github.com/RobTillaart/INA226
7-
//
8-
// HISTORY: see changelog.md
97

108

119
#include "INA226.h"
@@ -99,7 +97,7 @@ float INA226::getBusVoltage()
9997
float INA226::getPower()
10098
{
10199
uint16_t val = _readRegister(INA226_POWER);
102-
return val * 25 * _current_LSB; // fixed 25 Watt
100+
return val * 25 * _current_LSB; // fixed 25 Watt
103101
}
104102

105103

@@ -196,7 +194,7 @@ int INA226::setMaxCurrentShunt(float maxCurrent, float shunt, bool normalize)
196194

197195
// fix #16 - datasheet 6.5 Electrical Characteristics
198196
// rounded value to 80 mV
199-
float shuntVoltage = abs(maxCurrent * shunt);
197+
float shuntVoltage = abs(maxCurrent * shunt);
200198
if (shuntVoltage > 0.080) return INA226_ERR_SHUNTVOLTAGE_HIGH;
201199
if (maxCurrent < 0.001) return INA226_ERR_MAXCURRENT_LOW;
202200
if (shunt < 0.001) return INA226_ERR_SHUNT_LOW;
@@ -298,7 +296,7 @@ uint8_t INA226::getMode()
298296

299297
////////////////////////////////////////////////////////
300298
//
301-
// alert
299+
// alert
302300
//
303301
void INA226::setAlertRegister(uint16_t mask)
304302
{
@@ -326,7 +324,7 @@ uint16_t INA226::getAlertLimit()
326324

327325
////////////////////////////////////////////////////////
328326
//
329-
// meta information
327+
// meta information
330328
//
331329
uint16_t INA226::getManufacturerID()
332330
{
@@ -367,5 +365,5 @@ uint16_t INA226::_writeRegister(uint8_t reg, uint16_t value)
367365
}
368366

369367

370-
// -- END OF FILE --
368+
// -- END OF FILE --
371369

libraries/INA226/INA226.h

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22
// FILE: INA226.h
33
// AUTHOR: Rob Tillaart
4-
// VERSION: 0.4.1
4+
// VERSION: 0.4.2
55
// DATE: 2021-05-18
66
// PURPOSE: Arduino library for INA226 power sensor
77
// URL: https://github.com/RobTillaart/INA226
@@ -14,7 +14,7 @@
1414
#include "Wire.h"
1515

1616

17-
#define INA226_LIB_VERSION (F("0.4.1"))
17+
#define INA226_LIB_VERSION (F("0.4.2"))
1818

1919

2020
// set by setAlertRegister
@@ -55,17 +55,19 @@ class INA226
5555

5656

5757
// Core functions
58-
float getBusVoltage();
59-
float getShuntVoltage();
60-
float getCurrent();
61-
float getPower();
58+
float getBusVoltage(); // Volt
59+
float getShuntVoltage(); // Volt
60+
float getCurrent(); // Ampere
61+
float getPower(); // Watt
6262

6363

64-
// Scale helpers
64+
// Scale helpers milli range
6565
float getBusVoltage_mV() { return getBusVoltage() * 1e3; };
6666
float getShuntVoltage_mV() { return getShuntVoltage() * 1e3; };
6767
float getCurrent_mA() { return getCurrent() * 1e3; };
6868
float getPower_mW() { return getPower() * 1e3; };
69+
// Scale helpers micro range
70+
float getBusVoltage_uV() { return getBusVoltage() * 1e6; };
6971
float getShuntVoltage_uV() { return getShuntVoltage() * 1e6; };
7072
float getCurrent_uA() { return getCurrent() * 1e6; };
7173
float getPower_uW() { return getPower() * 1e6; };
@@ -86,7 +88,7 @@ class INA226
8688
// shunt * maxCurrent < 81 mV
8789
// maxCurrent >= 0.001
8890
// shunt >= 0.001
89-
int setMaxCurrentShunt(float macCurrent = 20.0,
91+
int setMaxCurrentShunt(float macCurrent = 20.0,
9092
float shunt = 0.002,
9193
bool normalize = true);
9294
bool isCalibrated() { return _current_LSB != 0.0; };
@@ -108,7 +110,7 @@ class INA226
108110
bool setModeShuntBusTrigger() { return setMode(3); };
109111
bool setModeShuntContinuous() { return setMode(5); };
110112
bool setModeBusContinuous() { return setMode(6); };
111-
bool setModeShuntBusContinuous() { return setMode(7); }; // default.
113+
bool setModeShuntBusContinuous() { return setMode(7); }; // default.
112114

113115

114116
// Alert
@@ -124,8 +126,8 @@ class INA226
124126

125127

126128
// Meta information
127-
uint16_t getManufacturerID(); // should return 0x5449
128-
uint16_t getDieID(); // should return 0x2260
129+
uint16_t getManufacturerID(); // should return 0x5449
130+
uint16_t getDieID(); // should return 0x2260
129131

130132

131133
// DEBUG
@@ -146,5 +148,5 @@ class INA226
146148
};
147149

148150

149-
// -- END OF FILE --
151+
// -- END OF FILE --
150152

libraries/INA226/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021-2022 Rob Tillaart
3+
Copyright (c) 2021-2023 Rob Tillaart
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)