ncd-red-ads7828
Version:
This library provides a class for the ADS7828, it relies on the ncd-red-comm library for communication, and includes a node-red node for the ADS7828. The ADS7828 is an 8-channel, 12-bit, I2C compatible, analog-to-digital converter. [Ncd.io](https://ncd.io
57 lines (47 loc) • 1.1 kB
JavaScript
var comms = require('ncd-red-comm');
var ADS7828 = require('./index.js');
/*
* Allows use of a USB to I2C converter form ncd.io
*/
var port = '/dev/tty.usbserial-DN03Q7F9';
var serial = new comms.NcdSerial('/dev/tty.usbserial-DN03Q7F9', 115200);
var comm = new comms.NcdSerialI2C(serial, 0);
/*
* Use the I2C port on a Raspberry Pi instead of the USB converter
*/
//comm = new comms.NcdI2C(1);
/*
* Use the native I2C port on the Raspberry Pi
*/
//var comm = new comms.NcdI2C(1);
var config = {
powerDown: 3
};
var sensor = new ADS7828(74, comm, config);
/*
* Test continuous conversion mode
*/
// sensor.writeConfig(4).then((res) => {
//
// }).catch(console.log);
// setInterval(() => {
// sensor.get().then().catch().then((res) => {
// console.log(res);
// console.log(res * 0.000628);
// });
// }, 1000);
/*
* End continuous conversion test
*/
/*
* Test power down single shot mode
*/
setInterval(() => {
sensor.get(8).then().catch().then((res) => {
console.log(res);
//console.log(res * 0.000628);
});
}, 1000);
/*
* End power down single shot test
*/