node-red-contrib-periph-humidity 1.5.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -3
- package/examples/dht11/demo.json +68 -6
- package/examples/hdc1008/demo.json +91 -0
- package/examples/hdc1080/demo.json +91 -0
- package/examples/hs30xx/demo.json +90 -0
- package/examples/hs40xx/demo.json +90 -0
- package/examples/htu21df/demo.json +11 -5
- package/examples/sht31/demo.json +11 -5
- package/examples/si7021/demo.json +11 -5
- package/nodes/hdc1008/hdc1008.html +88 -0
- package/nodes/hdc1008/hdc1008.js +58 -0
- package/nodes/hdc1080/hdc1080.html +88 -0
- package/nodes/hdc1080/hdc1080.js +58 -0
- package/nodes/hs30xx/hs30xx.html +78 -0
- package/nodes/hs30xx/hs30xx.js +46 -0
- package/nodes/hs40xx/hs40xx.html +90 -0
- package/nodes/hs40xx/hs40xx.js +51 -0
- package/nodes/htu21df/htu21df.html +44 -19
- package/nodes/htu21df/htu21df.js +16 -9
- package/nodes/sht31/sht31.html +41 -16
- package/nodes/sht31/sht31.js +16 -9
- package/nodes/si7021/si7021.html +44 -19
- package/nodes/si7021/si7021.js +16 -9
- package/package.json +5 -1
- package/index.js +0 -11
package/nodes/sht31/sht31.html
CHANGED
|
@@ -1,41 +1,38 @@
|
|
|
1
|
+
<!-- Config node: one instance per physical device -->
|
|
1
2
|
<script type="text/javascript">
|
|
2
|
-
RED.nodes.registerType('
|
|
3
|
-
category:
|
|
4
|
-
color: '#C084FC',
|
|
3
|
+
RED.nodes.registerType('sht31-device', {
|
|
4
|
+
category: 'config',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: { value: '' },
|
|
7
7
|
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
8
|
address: { value: '0x44' },
|
|
9
9
|
repeatability: { value: 'high' }
|
|
10
10
|
},
|
|
11
|
-
inputs: 1,
|
|
12
|
-
outputs: 1,
|
|
13
|
-
icon: 'bridge.svg',
|
|
14
11
|
label: function() {
|
|
15
12
|
return this.name || ('SHT31 @ ' + this.address + ' (bus ' + this.bus + ')');
|
|
16
13
|
}
|
|
17
14
|
});
|
|
18
15
|
</script>
|
|
19
16
|
|
|
20
|
-
<script type="text/html" data-template-name="
|
|
17
|
+
<script type="text/html" data-template-name="sht31-device">
|
|
21
18
|
<div class="form-row">
|
|
22
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
23
|
-
<input type="text" id="node-input-name" placeholder="SHT31">
|
|
19
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
20
|
+
<input type="text" id="node-config-input-name" placeholder="SHT31">
|
|
24
21
|
</div>
|
|
25
22
|
<div class="form-row">
|
|
26
|
-
<label for="node-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
27
|
-
<input type="number" id="node-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N)
|
|
23
|
+
<label for="node-config-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
24
|
+
<input type="number" id="node-config-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N)
|
|
28
25
|
</div>
|
|
29
26
|
<div class="form-row">
|
|
30
|
-
<label for="node-input-address"><i class="fa fa-microchip"></i> I²C address</label>
|
|
31
|
-
<select id="node-input-address" style="width:160px">
|
|
27
|
+
<label for="node-config-input-address"><i class="fa fa-microchip"></i> I²C address</label>
|
|
28
|
+
<select id="node-config-input-address" style="width:160px">
|
|
32
29
|
<option value="0x44" selected>0x44 (ADDR = low)</option>
|
|
33
30
|
<option value="0x45">0x45 (ADDR = high)</option>
|
|
34
31
|
</select>
|
|
35
32
|
</div>
|
|
36
33
|
<div class="form-row">
|
|
37
|
-
<label for="node-input-repeatability"><i class="fa fa-cog"></i> Repeatability</label>
|
|
38
|
-
<select id="node-input-repeatability" style="width:160px">
|
|
34
|
+
<label for="node-config-input-repeatability"><i class="fa fa-cog"></i> Repeatability</label>
|
|
35
|
+
<select id="node-config-input-repeatability" style="width:160px">
|
|
39
36
|
<option value="high" selected>High (15 ms)</option>
|
|
40
37
|
<option value="medium">Medium (6 ms)</option>
|
|
41
38
|
<option value="low">Low (4 ms)</option>
|
|
@@ -43,7 +40,35 @@
|
|
|
43
40
|
</div>
|
|
44
41
|
</script>
|
|
45
42
|
|
|
46
|
-
|
|
43
|
+
<!-- Read node -->
|
|
44
|
+
<script type="text/javascript">
|
|
45
|
+
RED.nodes.registerType('sht31', {
|
|
46
|
+
category: 'Peripheral',
|
|
47
|
+
color: '#C084FC',
|
|
48
|
+
defaults: {
|
|
49
|
+
name: { value: '' },
|
|
50
|
+
device: { value: '', type: 'sht31-device', required: true }
|
|
51
|
+
},
|
|
52
|
+
inputs: 1,
|
|
53
|
+
outputs: 1,
|
|
54
|
+
icon: 'bridge.svg',
|
|
55
|
+
label: function() { return this.name || 'SHT31'; },
|
|
56
|
+
paletteLabel: 'SHT31'
|
|
57
|
+
});
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<script type="text/html" data-template-name="sht31">
|
|
61
|
+
<div class="form-row">
|
|
62
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
63
|
+
<input type="text" id="node-input-name" placeholder="SHT31">
|
|
64
|
+
</div>
|
|
65
|
+
<div class="form-row">
|
|
66
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
67
|
+
<input type="text" id="node-input-device">
|
|
68
|
+
</div>
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
<script type="text/html" data-help-name="sht31">
|
|
47
72
|
<p>Reads temperature and relative humidity from a Sensirion SHT31 over I²C (0x44 with ADDR low, 0x45 with
|
|
48
73
|
ADDR high) with one single-shot measurement per message. Both CRC bytes are verified.</p>
|
|
49
74
|
<h3>Inputs</h3>
|
package/nodes/sht31/sht31.js
CHANGED
|
@@ -4,7 +4,7 @@ module.exports = function(RED) {
|
|
|
4
4
|
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
5
|
const { SHT31Full } = require('periph/src/chips/humidity/sht31');
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function SHT31DeviceNode(config) {
|
|
8
8
|
RED.nodes.createNode(this, config);
|
|
9
9
|
const node = this;
|
|
10
10
|
try {
|
|
@@ -23,15 +23,26 @@ module.exports = function(RED) {
|
|
|
23
23
|
node.error('SHT31 init failed: ' + e.message);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
node.on('close', function() {
|
|
27
|
+
if (node.connection) node.connection.close();
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
RED.nodes.registerType('sht31-device', SHT31DeviceNode);
|
|
31
|
+
|
|
32
|
+
function SHT31ReadNode(config) {
|
|
33
|
+
RED.nodes.createNode(this, config);
|
|
34
|
+
const node = this;
|
|
35
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
36
|
+
|
|
26
37
|
node.on('input', async function(msg, send, done) {
|
|
27
|
-
if (!
|
|
38
|
+
if (!deviceNode.driver) {
|
|
28
39
|
node.error('SHT31 not initialised', msg);
|
|
29
40
|
done();
|
|
30
41
|
return;
|
|
31
42
|
}
|
|
32
43
|
try {
|
|
33
|
-
await
|
|
34
|
-
const [temperature, humidity] = await
|
|
44
|
+
await deviceNode.ready;
|
|
45
|
+
const [temperature, humidity] = await deviceNode.driver.read();
|
|
35
46
|
msg.payload = { temperature, humidity };
|
|
36
47
|
send(msg);
|
|
37
48
|
done();
|
|
@@ -39,10 +50,6 @@ module.exports = function(RED) {
|
|
|
39
50
|
done(e);
|
|
40
51
|
}
|
|
41
52
|
});
|
|
42
|
-
|
|
43
|
-
node.on('close', function() {
|
|
44
|
-
if (node.connection) node.connection.close();
|
|
45
|
-
});
|
|
46
53
|
}
|
|
47
|
-
RED.nodes.registerType('
|
|
54
|
+
RED.nodes.registerType('sht31', SHT31ReadNode);
|
|
48
55
|
};
|
package/nodes/si7021/si7021.html
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
<!-- Config node: one instance per physical device -->
|
|
1
2
|
<script type="text/javascript">
|
|
2
|
-
RED.nodes.registerType('
|
|
3
|
-
category:
|
|
4
|
-
color: '#C084FC',
|
|
3
|
+
RED.nodes.registerType('si7021-device', {
|
|
4
|
+
category: 'config',
|
|
5
5
|
defaults: {
|
|
6
6
|
name: { value: '' },
|
|
7
7
|
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
@@ -9,31 +9,28 @@
|
|
|
9
9
|
resolution: { value: '12/14' },
|
|
10
10
|
heater: { value: false }
|
|
11
11
|
},
|
|
12
|
-
inputs: 1,
|
|
13
|
-
outputs: 1,
|
|
14
|
-
icon: 'bridge.svg',
|
|
15
12
|
label: function() {
|
|
16
|
-
return this.name || ('
|
|
13
|
+
return this.name || ('SI7021 @ ' + this.address + ' (bus ' + this.bus + ')');
|
|
17
14
|
}
|
|
18
15
|
});
|
|
19
16
|
</script>
|
|
20
17
|
|
|
21
|
-
<script type="text/html" data-template-name="
|
|
18
|
+
<script type="text/html" data-template-name="si7021-device">
|
|
22
19
|
<div class="form-row">
|
|
23
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
24
|
-
<input type="text" id="node-input-name" placeholder="
|
|
20
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
21
|
+
<input type="text" id="node-config-input-name" placeholder="SI7021">
|
|
25
22
|
</div>
|
|
26
23
|
<div class="form-row">
|
|
27
|
-
<label for="node-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
28
|
-
<input type="number" id="node-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N)
|
|
24
|
+
<label for="node-config-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
25
|
+
<input type="number" id="node-config-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N)
|
|
29
26
|
</div>
|
|
30
27
|
<div class="form-row">
|
|
31
|
-
<label for="node-input-address"><i class="fa fa-microchip"></i> I²C address</label>
|
|
32
|
-
<input type="text" id="node-input-address" style="width:80px" placeholder="0x40"> (fixed, 0x40)
|
|
28
|
+
<label for="node-config-input-address"><i class="fa fa-microchip"></i> I²C address</label>
|
|
29
|
+
<input type="text" id="node-config-input-address" style="width:80px" placeholder="0x40"> (fixed, 0x40)
|
|
33
30
|
</div>
|
|
34
31
|
<div class="form-row">
|
|
35
|
-
<label for="node-input-resolution"><i class="fa fa-cog"></i> Resolution</label>
|
|
36
|
-
<select id="node-input-resolution" style="width:200px">
|
|
32
|
+
<label for="node-config-input-resolution"><i class="fa fa-cog"></i> Resolution</label>
|
|
33
|
+
<select id="node-config-input-resolution" style="width:200px">
|
|
37
34
|
<option value="12/14" selected>RH 12 bit / T 14 bit</option>
|
|
38
35
|
<option value="10/13">RH 10 bit / T 13 bit</option>
|
|
39
36
|
<option value="11/11">RH 11 bit / T 11 bit</option>
|
|
@@ -41,12 +38,40 @@
|
|
|
41
38
|
</select>
|
|
42
39
|
</div>
|
|
43
40
|
<div class="form-row">
|
|
44
|
-
<label for="node-input-heater"><i class="fa fa-fire"></i> Heater</label>
|
|
45
|
-
<input type="checkbox" id="node-input-heater" style="width:auto"> on-chip heater (3.1 mA)
|
|
41
|
+
<label for="node-config-input-heater"><i class="fa fa-fire"></i> Heater</label>
|
|
42
|
+
<input type="checkbox" id="node-config-input-heater" style="width:auto"> on-chip heater (3.1 mA)
|
|
43
|
+
</div>
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<!-- Read node -->
|
|
47
|
+
<script type="text/javascript">
|
|
48
|
+
RED.nodes.registerType('si7021', {
|
|
49
|
+
category: 'Peripheral',
|
|
50
|
+
color: '#C084FC',
|
|
51
|
+
defaults: {
|
|
52
|
+
name: { value: '' },
|
|
53
|
+
device: { value: '', type: 'si7021-device', required: true }
|
|
54
|
+
},
|
|
55
|
+
inputs: 1,
|
|
56
|
+
outputs: 1,
|
|
57
|
+
icon: 'bridge.svg',
|
|
58
|
+
label: function() { return this.name || 'SI7021'; },
|
|
59
|
+
paletteLabel: 'SI7021'
|
|
60
|
+
});
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<script type="text/html" data-template-name="si7021">
|
|
64
|
+
<div class="form-row">
|
|
65
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
66
|
+
<input type="text" id="node-input-name" placeholder="SI7021">
|
|
67
|
+
</div>
|
|
68
|
+
<div class="form-row">
|
|
69
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
70
|
+
<input type="text" id="node-input-device">
|
|
46
71
|
</div>
|
|
47
72
|
</script>
|
|
48
73
|
|
|
49
|
-
<script type="text/html" data-help-name="
|
|
74
|
+
<script type="text/html" data-help-name="si7021">
|
|
50
75
|
<p>Reads relative humidity and temperature from a Silicon Labs Si7021 over I²C (fixed address 0x40) with one
|
|
51
76
|
relative-humidity measurement per message; the temperature comes from the same conversion. The CRC of the
|
|
52
77
|
humidity result is verified.</p>
|
package/nodes/si7021/si7021.js
CHANGED
|
@@ -6,7 +6,7 @@ module.exports = function(RED) {
|
|
|
6
6
|
|
|
7
7
|
const RESOLUTIONS = { '12/14': [12, 14], '8/12': [8, 12], '10/13': [10, 13], '11/11': [11, 11] };
|
|
8
8
|
|
|
9
|
-
function
|
|
9
|
+
function Si7021DeviceNode(config) {
|
|
10
10
|
RED.nodes.createNode(this, config);
|
|
11
11
|
const node = this;
|
|
12
12
|
try {
|
|
@@ -26,15 +26,26 @@ module.exports = function(RED) {
|
|
|
26
26
|
node.error('Si7021 init failed: ' + e.message);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
node.on('close', function() {
|
|
30
|
+
if (node.connection) node.connection.close();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
RED.nodes.registerType('si7021-device', Si7021DeviceNode);
|
|
34
|
+
|
|
35
|
+
function Si7021ReadNode(config) {
|
|
36
|
+
RED.nodes.createNode(this, config);
|
|
37
|
+
const node = this;
|
|
38
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
39
|
+
|
|
29
40
|
node.on('input', async function(msg, send, done) {
|
|
30
|
-
if (!
|
|
41
|
+
if (!deviceNode.driver) {
|
|
31
42
|
node.error('Si7021 not initialised', msg);
|
|
32
43
|
done();
|
|
33
44
|
return;
|
|
34
45
|
}
|
|
35
46
|
try {
|
|
36
|
-
await
|
|
37
|
-
const [temperature_c, humidity_pct] = await
|
|
47
|
+
await deviceNode.ready;
|
|
48
|
+
const [temperature_c, humidity_pct] = await deviceNode.driver.read();
|
|
38
49
|
msg.payload = { temperature_c, humidity_pct };
|
|
39
50
|
send(msg);
|
|
40
51
|
done();
|
|
@@ -42,10 +53,6 @@ module.exports = function(RED) {
|
|
|
42
53
|
done(e);
|
|
43
54
|
}
|
|
44
55
|
});
|
|
45
|
-
|
|
46
|
-
node.on('close', function() {
|
|
47
|
-
if (node.connection) node.connection.close();
|
|
48
|
-
});
|
|
49
56
|
}
|
|
50
|
-
RED.nodes.registerType('
|
|
57
|
+
RED.nodes.registerType('si7021', Si7021ReadNode);
|
|
51
58
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-periph-humidity",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "Node-RED nodes for humidity sensor chips",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node-red",
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
"node-red": {
|
|
14
14
|
"nodes": {
|
|
15
15
|
"dht11": "nodes/dht11/dht11.js",
|
|
16
|
+
"hdc1008": "nodes/hdc1008/hdc1008.js",
|
|
17
|
+
"hdc1080": "nodes/hdc1080/hdc1080.js",
|
|
18
|
+
"hs30xx": "nodes/hs30xx/hs30xx.js",
|
|
19
|
+
"hs40xx": "nodes/hs40xx/hs40xx.js",
|
|
16
20
|
"htu21df": "nodes/htu21df/htu21df.js",
|
|
17
21
|
"sht31": "nodes/sht31/sht31.js",
|
|
18
22
|
"si7021": "nodes/si7021/si7021.js"
|
package/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
module.exports = function(RED) {
|
|
5
|
-
const nodesDir = path.join(__dirname, 'nodes');
|
|
6
|
-
if (!fs.existsSync(nodesDir)) return;
|
|
7
|
-
fs.readdirSync(nodesDir).forEach(function(chip) {
|
|
8
|
-
const nodeFile = path.join(nodesDir, chip, chip + '.js');
|
|
9
|
-
if (fs.existsSync(nodeFile)) require(nodeFile)(RED);
|
|
10
|
-
});
|
|
11
|
-
};
|