Node.js Driver for Adafruit INA219.
This is a direct port to NodeJS from the C code created by Adafuit and posted at https://github.com/adafruit/Adafruit_INA219 quite some time ago. Looks like the Adafruit code has changed a lot since then, and this hasn't been maintained / reported.
$ npm install ina219
##Usage
var ina219 = require('ina219');
ina219.init();
ina219.enableLogging(true);
ina219.calibrate32V1A(function () {
ina219.getBusVoltage_V(function (volts) {
console.log("Voltage: " + volts);
ina219.getCurrent_mA(function (current){
console.log("Current (mA): " + current );
});
});
});
- onCompleteCallback :
function
Callback for standard oncomplete
- onHaveValueCallback :
function
Callback for returning a single value
- Ina219
- new Ina219()
- .init(address, device)
- .enableLogging(enable)
- .writeRegister(register, value, callback)
- .readRegister(register, callback)
- .calibrate32V1A(callback)
- .log(s)
- .getBusVoltage_raw(callback)
- .getShuntVoltage_raw(callback)
- .getCurrent_raw(callback)
- .getBusVoltage_V(callback)
- .getShuntVoltage_mV(callback)
- .getCurrent_mA(callback)
Ina219 is the main class exported from the Node module
Called to initilize the INA219 board, you should calibrate it after this.
Kind: instance method of Ina219
Param | Type | Description |
---|---|---|
address | string |
Address you want to use. Defaults to INA219_ADDRESS |
device | string |
Device to connect to. Defaults to "/dev/i2c-1" |
Enabled debug logging to console.log
Kind: instance method of Ina219
Param | Type | Description |
---|---|---|
enable | bool |
True to enable, False to disable |
Reads a 16 bit value over I2C
Kind: instance method of Ina219
Param | Type | Description |
---|---|---|
register | integer |
Register to read from (One of INA219_REG_*) |
value | integer |
Value to be written |
callback | writeRegisterCallback |
Callback to be invoked when complete |
Reads a 16 bit value over I2C
Kind: instance method of Ina219
Param | Type | Description |
---|---|---|
register | integer |
Register to read from (One of INA219_REG_*) |
callback | onHaveValueCallback |
Callback to be invoked when complete |
Configures to INA219 to be able to measure up to 32V and 1A of current. Each unit of current corresponds to 40uA, and each unit of power corresponds to 800mW. Counter overflow occurs at 1.3A. Note: These calculations assume a 0.1 ohm resistor is present
Kind: instance method of Ina219
Param | Type | Description |
---|---|---|
callback | onCompleteCallback |
Callback to be invoked when complete |
Logs a string to the console if logging enabled
Kind: instance method of Ina219
Param | Type | Description |
---|---|---|
s | string |
String to log |
Reads the raw bus voltage
Kind: instance method of Ina219
Param | Type | Description |
---|---|---|
callback | onHaveValueCallback |
Callback to be invoked when complete. |
Reads the raw shunt voltage
Kind: instance method of Ina219
Param | Type | Description |
---|---|---|
callback | onHaveValueCallback |
Callback to be invoked when complete. |
Reads the raw current value
Kind: instance method of Ina219
Param | Type | Description |
---|---|---|
callback | onHaveValueCallback |
Callback to be invoked when complete. |
Gets the bus voltage in volts
Kind: instance method of Ina219
Param | Type | Description |
---|---|---|
callback | onHaveValueCallback |
Callback to be invoked when complete. |
Gets the shunt voltage in mV (so +-327mV)
Kind: instance method of Ina219
Param | Type | Description |
---|---|---|
callback | onHaveValueCallback |
Callback to be invoked when complete. |
Gets the current value in mA, taking into account the config settings and current LSB
Kind: instance method of Ina219
Param | Type | Description |
---|---|---|
callback | onHaveValueCallback |
Callback to be invoked when complete. |
Callback for standard oncomplete
Callback for returning a single value
Kind: global typedef
Param | Type | Description |
---|---|---|
value | int |
value returned by async operation |