node-red-contrib-periph-humidity 1.4.0 → 1.5.1
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 +7 -0
- package/examples/hdc1008/demo.json +85 -0
- package/examples/hdc1080/demo.json +85 -0
- package/examples/hs30xx/demo.json +84 -0
- package/examples/hs40xx/demo.json +84 -0
- package/examples/htu21df/demo.json +86 -0
- package/examples/sht31/demo.json +85 -0
- package/examples/si7021/demo.json +86 -0
- package/nodes/hdc1008/hdc1008.html +63 -0
- package/nodes/hdc1008/hdc1008.js +51 -0
- package/nodes/hdc1080/hdc1080.html +63 -0
- package/nodes/hdc1080/hdc1080.js +51 -0
- package/nodes/hs30xx/hs30xx.html +53 -0
- package/nodes/hs30xx/hs30xx.js +39 -0
- package/nodes/hs40xx/hs40xx.html +65 -0
- package/nodes/hs40xx/hs40xx.js +44 -0
- package/nodes/htu21df/htu21df.html +67 -0
- package/nodes/htu21df/htu21df.js +52 -0
- package/nodes/sht31/sht31.html +64 -0
- package/nodes/sht31/sht31.js +48 -0
- package/nodes/si7021/si7021.html +68 -0
- package/nodes/si7021/si7021.js +51 -0
- package/package.json +9 -2
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType('periph-si7021', {
|
|
3
|
+
category: 'Peripheral',
|
|
4
|
+
color: '#C084FC',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
|
+
address: { value: '0x40' },
|
|
9
|
+
resolution: { value: '12/14' },
|
|
10
|
+
heater: { value: false }
|
|
11
|
+
},
|
|
12
|
+
inputs: 1,
|
|
13
|
+
outputs: 1,
|
|
14
|
+
icon: 'bridge.svg',
|
|
15
|
+
label: function() {
|
|
16
|
+
return this.name || ('Si7021 @ ' + this.address + ' (bus ' + this.bus + ')');
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<script type="text/html" data-template-name="periph-si7021">
|
|
22
|
+
<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="Si7021">
|
|
25
|
+
</div>
|
|
26
|
+
<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)
|
|
29
|
+
</div>
|
|
30
|
+
<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)
|
|
33
|
+
</div>
|
|
34
|
+
<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">
|
|
37
|
+
<option value="12/14" selected>RH 12 bit / T 14 bit</option>
|
|
38
|
+
<option value="10/13">RH 10 bit / T 13 bit</option>
|
|
39
|
+
<option value="11/11">RH 11 bit / T 11 bit</option>
|
|
40
|
+
<option value="8/12">RH 8 bit / T 12 bit</option>
|
|
41
|
+
</select>
|
|
42
|
+
</div>
|
|
43
|
+
<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)
|
|
46
|
+
</div>
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<script type="text/html" data-help-name="periph-si7021">
|
|
50
|
+
<p>Reads relative humidity and temperature from a Silicon Labs Si7021 over I²C (fixed address 0x40) with one
|
|
51
|
+
relative-humidity measurement per message; the temperature comes from the same conversion. The CRC of the
|
|
52
|
+
humidity result is verified.</p>
|
|
53
|
+
<h3>Inputs</h3>
|
|
54
|
+
<dl class="message-properties">
|
|
55
|
+
<dt>payload <span class="property-type">any</span></dt>
|
|
56
|
+
<dd>Any incoming message triggers one measurement.</dd>
|
|
57
|
+
</dl>
|
|
58
|
+
<h3>Outputs</h3>
|
|
59
|
+
<dl class="message-properties">
|
|
60
|
+
<dt>payload.temperature_c <span class="property-type">number</span></dt>
|
|
61
|
+
<dd>Temperature in °C.</dd>
|
|
62
|
+
<dt>payload.humidity_pct <span class="property-type">number</span></dt>
|
|
63
|
+
<dd>Relative humidity in %RH (0–100).</dd>
|
|
64
|
+
</dl>
|
|
65
|
+
<h3>Configuration</h3>
|
|
66
|
+
<p>I²C bus number, I²C address (0x40), measurement resolution (RH / temperature bits) and the on-chip heater.
|
|
67
|
+
With the heater on, readings drift upwards; use it only to drive off condensation.</p>
|
|
68
|
+
</script>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function(RED) {
|
|
4
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
|
+
const { Si7021Full } = require('periph/src/chips/humidity/si7021');
|
|
6
|
+
|
|
7
|
+
const RESOLUTIONS = { '12/14': [12, 14], '8/12': [8, 12], '10/13': [10, 13], '11/11': [11, 11] };
|
|
8
|
+
|
|
9
|
+
function Si7021Node(config) {
|
|
10
|
+
RED.nodes.createNode(this, config);
|
|
11
|
+
const node = this;
|
|
12
|
+
try {
|
|
13
|
+
const address = parseInt(config.address, 16) || 0x40;
|
|
14
|
+
const connection = new I2CConnection(parseInt(config.bus), address);
|
|
15
|
+
node.connection = connection;
|
|
16
|
+
node.driver = new Si7021Full(connection);
|
|
17
|
+
node.ready = (async () => {
|
|
18
|
+
const res = RESOLUTIONS[config.resolution] || RESOLUTIONS['12/14'];
|
|
19
|
+
await node.driver.setResolution(res[0], res[1]);
|
|
20
|
+
await node.driver.setHeater(config.heater === true || config.heater === 'true');
|
|
21
|
+
})();
|
|
22
|
+
node.ready.catch((e) => {
|
|
23
|
+
node.error('Si7021 init failed: ' + e.message);
|
|
24
|
+
});
|
|
25
|
+
} catch (e) {
|
|
26
|
+
node.error('Si7021 init failed: ' + e.message);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
node.on('input', async function(msg, send, done) {
|
|
30
|
+
if (!node.driver) {
|
|
31
|
+
node.error('Si7021 not initialised', msg);
|
|
32
|
+
done();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
await node.ready;
|
|
37
|
+
const [temperature_c, humidity_pct] = await node.driver.read();
|
|
38
|
+
msg.payload = { temperature_c, humidity_pct };
|
|
39
|
+
send(msg);
|
|
40
|
+
done();
|
|
41
|
+
} catch (e) {
|
|
42
|
+
done(e);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
node.on('close', function() {
|
|
47
|
+
if (node.connection) node.connection.close();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
RED.nodes.registerType('periph-si7021', Si7021Node);
|
|
51
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-periph-humidity",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "Node-RED nodes for humidity sensor chips",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node-red",
|
|
@@ -12,7 +12,14 @@
|
|
|
12
12
|
],
|
|
13
13
|
"node-red": {
|
|
14
14
|
"nodes": {
|
|
15
|
-
"dht11": "nodes/dht11/dht11.js"
|
|
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",
|
|
20
|
+
"htu21df": "nodes/htu21df/htu21df.js",
|
|
21
|
+
"sht31": "nodes/sht31/sht31.js",
|
|
22
|
+
"si7021": "nodes/si7021/si7021.js"
|
|
16
23
|
}
|
|
17
24
|
},
|
|
18
25
|
"dependencies": {
|