forked from bbx10/node-htu21d
-
Notifications
You must be signed in to change notification settings - Fork 1
/
htutest.js
31 lines (27 loc) · 1.2 KB
/
htutest.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
var i2c_htu21d = require('./index.js');
// If using a Raspberry Pi, do not specify the i2c device name.
// The correct name will be used based on the board revision.
// Older boards use /dev/i2c-0, newer ones use /dev/i2c-1.
// If using any other board, specify the device name.
// For example: i2c_htu21d({device: '/dev/i2c-1/'});
var htu21df = new i2c_htu21d();
htu21df.readTemperature(function (err, temp) {
console.log('Temperature, C:', temp);
htu21df.readHumidity(function (err, humidity) {
console.log('Humidity, RH %:', humidity);
console.log('new i2c_htu21d({});');
var htu21df_1 = new i2c_htu21d({});
console.log("new i2c_htu21d({device: ''});");
var htu21df_2 = new i2c_htu21d({device: ''});
console.log("new i2c_htu21d({device: '/dev/i2c-1'});");
var htu21df_3 = new i2c_htu21d({device: '/dev/i2c-1'});
console.log("new i2c_htu21d({otherops: 'nada'});");
var htu21df_4 = new i2c_htu21d({otherops: 'nada'});
console.log("new i2c_htu21d({device: '/dev/i2c-9'});");
try {
var htu21df_5 = new i2c_htu21d({device: '/dev/i2c-9'});
} catch (e) {
console.log('i2c fail');
}
});
});