0.6.4 • Published 3 years ago

easybotics-ina219 v0.6.4

Weekly downloads
32
License
MIT
Repository
github
Last release
3 years ago

node-ina219

Node.js Driver for Adafruit INA219

Install

$ npm install easybotics-ina219

##Usage

  var ina219 = require('easybotics-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 );
      });	
    });
  });

Classes

new Ina219()

Ina219 is the main class exported from the Node module

ina219.init(address, device)

Called to initilize the INA219 board, you should calibrate it after this.

Kind: instance method of Ina219

ParamTypeDescription
addressstringAddress you want to use. Defaults to INA219_ADDRESS
devicestringDevice to connect to. Defaults to "/dev/i2c-1"

ina219.enableLogging(enable)

Enabled debug logging to console.log

Kind: instance method of Ina219

ParamTypeDescription
enableboolTrue to enable, False to disable

ina219.writeRegister(register, value, callback)

Reads a 16 bit value over I2C

Kind: instance method of Ina219

ParamTypeDescription
registerintegerRegister to read from (One of INA219REG*)
valueintegerValue to be written
callbackwriteRegisterCallbackCallback to be invoked when complete

ina219.readRegister(register, callback)

Reads a 16 bit value over I2C

Kind: instance method of Ina219

ParamTypeDescription
registerintegerRegister to read from (One of INA219REG*)
callbackonHaveValueCallbackCallback to be invoked when complete

ina219.calibrate32V1A(callback)

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

ParamTypeDescription
callbackonCompleteCallbackCallback to be invoked when complete

ina219.log(s)

Logs a string to the console if logging enabled

Kind: instance method of Ina219

ParamTypeDescription
sstringString to log

ina219.getBusVoltage_raw(callback)

Reads the raw bus voltage

Kind: instance method of Ina219

ParamTypeDescription
callbackonHaveValueCallbackCallback to be invoked when complete.

ina219.getShuntVoltage_raw(callback)

Reads the raw shunt voltage

Kind: instance method of Ina219

ParamTypeDescription
callbackonHaveValueCallbackCallback to be invoked when complete.

ina219.getCurrent_raw(callback)

Reads the raw current value

Kind: instance method of Ina219

ParamTypeDescription
callbackonHaveValueCallbackCallback to be invoked when complete.

ina219.getBusVoltage_V(callback)

Gets the bus voltage in volts

Kind: instance method of Ina219

ParamTypeDescription
callbackonHaveValueCallbackCallback to be invoked when complete.

ina219.getShuntVoltage_mV(callback)

Gets the shunt voltage in mV (so +-327mV)

Kind: instance method of Ina219

ParamTypeDescription
callbackonHaveValueCallbackCallback to be invoked when complete.

ina219.getCurrent_mA(callback)

Gets the current value in mA, taking into account the config settings and current LSB

Kind: instance method of Ina219

ParamTypeDescription
callbackonHaveValueCallbackCallback to be invoked when complete.

onCompleteCallback : function

Callback for standard oncomplete

Kind: global typedef

onHaveValueCallback : function

Callback for returning a single value

Kind: global typedef

ParamTypeDescription
valueintvalue returned by async operation