mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-09-19 16:46:11 -04:00
0.5.4 INA226
This commit is contained in:
parent
501009165a
commit
8fcd95e523
@ -1,4 +1,3 @@
|
||||
---
|
||||
|
||||
name: Arduino CI
|
||||
|
||||
|
@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
|
||||
## [0.5.4] - 2024-04-04
|
||||
- add multi device and array example
|
||||
- add address table to readme.md
|
||||
- minor edits
|
||||
|
||||
## [0.5.3] - 2024-03-25
|
||||
- add enum **ina226_average_enum** (Thanks to Henk Holdijk)
|
||||
- add enum **ina226_timing_enum** for BVCT SVCT conversion timing
|
||||
@ -15,7 +20,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
- update unit test
|
||||
- minor edits
|
||||
|
||||
|
||||
## [0.5.2] - 2024-01-06
|
||||
- Thanks to Henk Holdijk for his improvements.
|
||||
- fix #35, add **bool isConversionReady()**
|
||||
|
@ -1,6 +1,6 @@
|
||||
// FILE: INA226.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.5.3
|
||||
// VERSION: 0.5.4
|
||||
// DATE: 2021-05-18
|
||||
// PURPOSE: Arduino library for INA226 power sensor
|
||||
// URL: https://github.com/RobTillaart/INA226
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
// FILE: INA226.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.5.3
|
||||
// VERSION: 0.5.4
|
||||
// DATE: 2021-05-18
|
||||
// PURPOSE: Arduino library for INA226 power sensor
|
||||
// URL: https://github.com/RobTillaart/INA226
|
||||
@ -13,7 +13,7 @@
|
||||
#include "Wire.h"
|
||||
|
||||
|
||||
#define INA226_LIB_VERSION "0.5.3"
|
||||
#define INA226_LIB_VERSION "0.5.4"
|
||||
|
||||
|
||||
// set by setAlertRegister
|
||||
|
@ -65,7 +65,26 @@ The sensor can have 16 different I2C addresses,
|
||||
which depends on how the A0 and A1 address lines
|
||||
are connected to the SCL, SDA, GND and VCC pins.
|
||||
|
||||
See datasheet - table 2 - datasheet.
|
||||
See table - from datasheet table 2, page18.
|
||||
|
||||
| A1 | A0 | ADDRESS |
|
||||
|:-----:|:-----:|:----------:|
|
||||
| GND | GND | 1000000 |
|
||||
| GND | VS | 1000001 |
|
||||
| GND | SDA | 1000010 |
|
||||
| GND | SCL | 1000011 |
|
||||
| VS | GND | 1000100 |
|
||||
| VS | VS | 1000101 |
|
||||
| VS | SDA | 1000110 |
|
||||
| VS | SCL | 1000111 |
|
||||
| SDA | GND | 1001000 |
|
||||
| SDA | VS | 1001001 |
|
||||
| SDA | SDA | 1001010 |
|
||||
| SDA | SCL | 1001011 |
|
||||
| SCL | GND | 1001100 |
|
||||
| SCL | VS | 1001101 |
|
||||
| SCL | SDA | 1001110 |
|
||||
| SCL | SCL | 1001111 |
|
||||
|
||||
|
||||
#### Performance
|
||||
|
74
libraries/INA226/examples/INA226_array/INA226_array.ino
Normal file
74
libraries/INA226/examples/INA226_array/INA226_array.ino
Normal file
@ -0,0 +1,74 @@
|
||||
//
|
||||
// FILE: INA226_array.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo four INA226's, adjust to your sensor count
|
||||
// URL: https://github.com/RobTillaart/INA226
|
||||
//
|
||||
// not tested with HW yet
|
||||
|
||||
|
||||
#include "INA226.h"
|
||||
|
||||
|
||||
#define INA_COUNT 4
|
||||
|
||||
INA226 INA[INA_COUNT] =
|
||||
{
|
||||
INA226(0x40),
|
||||
INA226(0x41),
|
||||
INA226(0x42),
|
||||
INA226(0x43)
|
||||
};
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("INA226_LIB_VERSION: ");
|
||||
Serial.println(INA226_LIB_VERSION);
|
||||
|
||||
Wire.begin();
|
||||
bool failed = false;
|
||||
for (int ID = 0; ID < INA_COUNT; ID++)
|
||||
{
|
||||
if (!INA[ID].begin() )
|
||||
{
|
||||
failed = true;
|
||||
Serial.println(ID);
|
||||
}
|
||||
INA[ID].setMaxCurrentShunt(1, 0.002);
|
||||
}
|
||||
if (failed)
|
||||
{
|
||||
Serial.println("One or more INA could not connect. Fix and Reboot");
|
||||
while (1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
Serial.println("\nID\tBUS\tSHUNT\tCURRENT\tPOWER");
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
for (int ID = 0; ID < 4; ID++)
|
||||
{
|
||||
Serial.print(ID);
|
||||
Serial.print("\t");
|
||||
Serial.print(INA[ID].getBusVoltage(), 3);
|
||||
Serial.print("\t");
|
||||
Serial.print(INA[ID].getShuntVoltage_mV(), 3);
|
||||
Serial.print("\t");
|
||||
Serial.print(INA[ID].getCurrent_mA(), 3);
|
||||
Serial.print("\t");
|
||||
Serial.print(INA[ID].getPower_mW(), 3);
|
||||
Serial.println();
|
||||
delay(1000);
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
@ -0,0 +1,65 @@
|
||||
//
|
||||
// FILE: INA226_multi_device.ino
|
||||
// AUTHOR: Rob Tillaart
|
||||
// PURPOSE: demo two INA226's
|
||||
// URL: https://github.com/RobTillaart/INA226
|
||||
//
|
||||
// not tested with HW yet
|
||||
|
||||
#include "INA226.h"
|
||||
|
||||
|
||||
INA226 INA0(0x40);
|
||||
INA226 INA1(0x41);
|
||||
|
||||
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
Serial.println(__FILE__);
|
||||
Serial.print("INA226_LIB_VERSION: ");
|
||||
Serial.println(INA226_LIB_VERSION);
|
||||
|
||||
Wire.begin();
|
||||
if (!INA0.begin() )
|
||||
{
|
||||
Serial.println("INA0 could not connect. Fix and Reboot");
|
||||
}
|
||||
if (!INA1.begin() )
|
||||
{
|
||||
Serial.println("INA1 could not connect. Fix and Reboot");
|
||||
}
|
||||
|
||||
INA0.setMaxCurrentShunt(1, 0.002);
|
||||
INA1.setMaxCurrentShunt(1, 0.002);
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
Serial.println("\nBUS\tSHUNT\tCURRENT\tPOWER\t\tBUS\tSHUNT\tCURRENT\tPOWER");
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
Serial.print(INA0.getBusVoltage(), 3);
|
||||
Serial.print("\t");
|
||||
Serial.print(INA0.getShuntVoltage_mV(), 3);
|
||||
Serial.print("\t");
|
||||
Serial.print(INA0.getCurrent_mA(), 3);
|
||||
Serial.print("\t");
|
||||
Serial.print(INA0.getPower_mW(), 3);
|
||||
Serial.print("\t");
|
||||
Serial.print("\t");
|
||||
Serial.print(INA1.getBusVoltage(), 3);
|
||||
Serial.print("\t");
|
||||
Serial.print(INA1.getShuntVoltage_mV(), 3);
|
||||
Serial.print("\t");
|
||||
Serial.print(INA1.getCurrent_mA(), 3);
|
||||
Serial.print("\t");
|
||||
Serial.print(INA1.getPower_mW(), 3);
|
||||
Serial.println();
|
||||
delay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -- END OF FILE --
|
@ -15,7 +15,7 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/INA226.git"
|
||||
},
|
||||
"version": "0.5.3",
|
||||
"version": "0.5.4",
|
||||
"license": "MIT",
|
||||
"frameworks": "*",
|
||||
"platforms": "*",
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=INA226
|
||||
version=0.5.3
|
||||
version=0.5.4
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for INA226 power sensor
|
||||
|
Loading…
Reference in New Issue
Block a user