ncd-red-mcp3425
Version:
This library provides a class for the MCP3425, it relies on the ncd-red-comm library for communication, and includes a node-red node for MCP3425. The MCP3425 is a 1-Channel Analog to Digital Converter with 16-Bit resolution, ideally suited for low-speed h
31 lines (25 loc) • 607 B
JavaScript
var comms = require('ncd-red-comm');
var MCP3425 = require('./index.js');
/*
* Allows use of a USB to I2C converter form ncd.io
*/
var port = '/dev/tty.usbserial-DN04EUP8';
var serial = new comms.NcdSerial(port, 115200);
var comm = new comms.NcdSerialI2C(serial, 0);
/*
* Use the native I2C port on the Raspberry Pi
*/
//var comm = new comms.NcdI2C(1);
var config = {
resolution: 16,
gain: 1,
mode: 1 // continuous conversion
};
var adc = new MCP3425(comm, config);
function testGet(){
adc.get().then((r) => {
console.log(r);
setTimeout(testGet, 1000);
}).catch(console.log);
}
testGet();