node-ina219:适用于Adafruit INA219的Node.js驱动程序

  • x5_521518
    了解作者
  • 8.5KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • VIP专享
    资源类型
  • 0
    下载次数
  • 2022-04-17 12:41
    上传日期
节点-ina219 Adafruit INA219的Node.js驱动程序。 这是从Adafuit创建的C代码到NodeJS的直接端口,并在相当一段时间前发布在。 此后看来,Adafruit代码已发生了很大变化,并且尚未得到维护/报告。 安装 $ npm install ina219 ##用法 var ina219 = require ( 'ina219' ) ; ina219 . init ( ) ; ina219 . enableLogging ( true ) ; ina219 . calibrate32V1A ( function ( ) { ina219 . getBusVoltage_V ( function ( volts ) { console . log ( "Voltage: " + volts ) ;
node-ina219-master.zip
  • node-ina219-master
  • .gitattributes
    378B
  • README.md
    6.7KB
  • ina219.js
    16.6KB
  • docs.md
    6KB
  • .gitignore
    589B
  • package.json
    530B
内容介绍
# node-ina219 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. # Install ````bash $ npm install ina219 ```` ##Usage ```javascript 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 ); }); }); }); ``` ## Classes <dl> <dt><a href="#Ina219" rel='nofollow' onclick='return false;'>Ina219</a></dt> <dd></dd> </dl> ## Typedefs <dl> <dt><a href="#onCompleteCallback" rel='nofollow' onclick='return false;'>onCompleteCallback</a> : <code>function</code></dt> <dd><p>Callback for standard oncomplete</p> </dd> <dt><a href="#onHaveValueCallback" rel='nofollow' onclick='return false;'>onHaveValueCallback</a> : <code>function</code></dt> <dd><p>Callback for returning a single value</p> </dd> </dl> <a name="Ina219" rel='nofollow' onclick='return false;'></a> ## Ina219 **Kind**: global class * [Ina219](#Ina219) * [new Ina219()](#new_Ina219_new) * [.init(address, device)](#Ina219+init) * [.enableLogging(enable)](#Ina219+enableLogging) * [.writeRegister(register, value, callback)](#Ina219+writeRegister) * [.readRegister(register, callback)](#Ina219+readRegister) * [.calibrate32V1A(callback)](#Ina219+calibrate32V1A) * [.log(s)](#Ina219+log) * [.getBusVoltage_raw(callback)](#Ina219+getBusVoltage_raw) * [.getShuntVoltage_raw(callback)](#Ina219+getShuntVoltage_raw) * [.getCurrent_raw(callback)](#Ina219+getCurrent_raw) * [.getBusVoltage_V(callback)](#Ina219+getBusVoltage_V) * [.getShuntVoltage_mV(callback)](#Ina219+getShuntVoltage_mV) * [.getCurrent_mA(callback)](#Ina219+getCurrent_mA) <a name="new_Ina219_new" rel='nofollow' onclick='return false;'></a> ### new Ina219() Ina219 is the main class exported from the Node module <a name="Ina219+init" rel='nofollow' onclick='return false;'></a> ### ina219.init(address, device) Called to initilize the INA219 board, you should calibrate it after this. **Kind**: instance method of <code>[Ina219](#Ina219)</code> | Param | Type | Description | | --- | --- | --- | | address | <code>string</code> | Address you want to use. Defaults to INA219_ADDRESS | | device | <code>string</code> | Device to connect to. Defaults to "/dev/i2c-1" | <a name="Ina219+enableLogging" rel='nofollow' onclick='return false;'></a> ### ina219.enableLogging(enable) Enabled debug logging to console.log **Kind**: instance method of <code>[Ina219](#Ina219)</code> | Param | Type | Description | | --- | --- | --- | | enable | <code>bool</code> | True to enable, False to disable | <a name="Ina219+writeRegister" rel='nofollow' onclick='return false;'></a> ### ina219.writeRegister(register, value, callback) Reads a 16 bit value over I2C **Kind**: instance method of <code>[Ina219](#Ina219)</code> | Param | Type | Description | | --- | --- | --- | | register | <code>integer</code> | Register to read from (One of INA219_REG_*) | | value | <code>integer</code> | Value to be written | | callback | <code>writeRegisterCallback</code> | Callback to be invoked when complete | <a name="Ina219+readRegister" rel='nofollow' onclick='return false;'></a> ### ina219.readRegister(register, callback) Reads a 16 bit value over I2C **Kind**: instance method of <code>[Ina219](#Ina219)</code> | Param | Type | Description | | --- | --- | --- | | register | <code>integer</code> | Register to read from (One of INA219_REG_*) | | callback | <code>[onHaveValueCallback](#onHaveValueCallback)</code> | Callback to be invoked when complete | <a name="Ina219+calibrate32V1A" rel='nofollow' onclick='return false;'></a> ### 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 <code>[Ina219](#Ina219)</code> | Param | Type | Description | | --- | --- | --- | | callback | <code>[onCompleteCallback](#onCompleteCallback)</code> | Callback to be invoked when complete | <a name="Ina219+log" rel='nofollow' onclick='return false;'></a> ### ina219.log(s) Logs a string to the console if logging enabled **Kind**: instance method of <code>[Ina219](#Ina219)</code> | Param | Type | Description | | --- | --- | --- | | s | <code>string</code> | String to log | <a name="Ina219+getBusVoltage_raw" rel='nofollow' onclick='return false;'></a> ### ina219.getBusVoltage_raw(callback) Reads the raw bus voltage **Kind**: instance method of <code>[Ina219](#Ina219)</code> | Param | Type | Description | | --- | --- | --- | | callback | <code>[onHaveValueCallback](#onHaveValueCallback)</code> | Callback to be invoked when complete. | <a name="Ina219+getShuntVoltage_raw" rel='nofollow' onclick='return false;'></a> ### ina219.getShuntVoltage_raw(callback) Reads the raw shunt voltage **Kind**: instance method of <code>[Ina219](#Ina219)</code> | Param | Type | Description | | --- | --- | --- | | callback | <code>[onHaveValueCallback](#onHaveValueCallback)</code> | Callback to be invoked when complete. | <a name="Ina219+getCurrent_raw" rel='nofollow' onclick='return false;'></a> ### ina219.getCurrent_raw(callback) Reads the raw current value **Kind**: instance method of <code>[Ina219](#Ina219)</code> | Param | Type | Description | | --- | --- | --- | | callback | <code>[onHaveValueCallback](#onHaveValueCallback)</code> | Callback to be invoked when complete. | <a name="Ina219+getBusVoltage_V" rel='nofollow' onclick='return false;'></a> ### ina219.getBusVoltage_V(callback) Gets the bus voltage in volts **Kind**: instance method of <code>[Ina219](#Ina219)</code> | Param | Type | Description | | --- | --- | --- | | callback | <code>[onHaveValueCallback](#onHaveValueCallback)</code> | Callback to be invoked when complete. | <a name="Ina219+getShuntVoltage_mV" rel='nofollow' onclick='return false;'></a> ### ina219.getShuntVoltage_mV(callback) Gets the shunt voltage in mV (so +-327mV) **Kind**: instance method of <code>[Ina219](#Ina219)</code> | Param | Type | Description | | --- | --- | --- | | callback | <code>[onHaveValueCallback](#onHaveValueCallback)</code> | Callback to be invoked when complete. | <a name="Ina219+getCurrent_mA" rel='nofollow' onclick='return false;'></a> ### ina219.getCurrent_mA(callback) Gets the current value in mA, taking into account the config settings and current LSB **Kind**: instance method of <code>[Ina219](#Ina219)</code> | Param | Type | Description | | --- | --- | --- | | callback | <code>[onHaveValueCallback](#onHaveValueCallback)</code> | Callback to be invoked when complete. | <a name="onCompleteCallback" rel='nofollow' onclick='return false;'></a> ## onCompleteCallback : <code>function</code> Callback for standard oncomplete **Kind**: global typedef <a name="onHaveValueCallback" rel='nofollow' onclick='return false;'></a> ## onHaveValueCallback : <code>function</code> Callback for returning a single value **Kind**: global typedef | Param | Type | Description | | --- | --- | --- | | value | <code>int</code> | value returned by async operation |
评论
    相关推荐