-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
56 lines (47 loc) · 1.07 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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
*/