npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

easybotics-ina219

v0.6.4

Published

Node.js INA219 driver for Adafruit INA219 High Side DC Current Sensor

Downloads

49

Readme

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

| 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" |

ina219.enableLogging(enable)

Enabled debug logging to console.log

Kind: instance method of Ina219

| Param | Type | Description | | --- | --- | --- | | enable | bool | True to enable, False to disable |

ina219.writeRegister(register, value, callback)

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 |

ina219.readRegister(register, callback)

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 |

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

| Param | Type | Description | | --- | --- | --- | | callback | onCompleteCallback | Callback to be invoked when complete |

ina219.log(s)

Logs a string to the console if logging enabled

Kind: instance method of Ina219

| Param | Type | Description | | --- | --- | --- | | s | string | String to log |

ina219.getBusVoltage_raw(callback)

Reads the raw bus voltage

Kind: instance method of Ina219

| Param | Type | Description | | --- | --- | --- | | callback | onHaveValueCallback | Callback to be invoked when complete. |

ina219.getShuntVoltage_raw(callback)

Reads the raw shunt voltage

Kind: instance method of Ina219

| Param | Type | Description | | --- | --- | --- | | callback | onHaveValueCallback | Callback to be invoked when complete. |

ina219.getCurrent_raw(callback)

Reads the raw current value

Kind: instance method of Ina219

| Param | Type | Description | | --- | --- | --- | | callback | onHaveValueCallback | Callback to be invoked when complete. |

ina219.getBusVoltage_V(callback)

Gets the bus voltage in volts

Kind: instance method of Ina219

| Param | Type | Description | | --- | --- | --- | | callback | onHaveValueCallback | Callback to be invoked when complete. |

ina219.getShuntVoltage_mV(callback)

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

Kind: instance method of Ina219

| Param | Type | Description | | --- | --- | --- | | callback | onHaveValueCallback | Callback 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

| Param | Type | Description | | --- | --- | --- | | callback | onHaveValueCallback | Callback 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

| Param | Type | Description | | --- | --- | --- | | value | int | value returned by async operation |