node-red-contrib-periph-gas 1.5.4 → 1.6.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 +12 -2
- package/examples/ccs811/demo.json +136 -0
- package/examples/rrh46410/demo.json +136 -0
- package/examples/rrh62000/demo.json +194 -0
- package/examples/scd30/demo.json +194 -0
- package/examples/scd40/demo.json +195 -0
- package/nodes/ccs811/ccs811.html +105 -0
- package/nodes/ccs811/ccs811.js +59 -0
- package/nodes/rrh46410/rrh46410.html +108 -0
- package/nodes/rrh46410/rrh46410.js +61 -0
- package/nodes/rrh62000/rrh62000.html +104 -0
- package/nodes/rrh62000/rrh62000.js +60 -0
- package/nodes/scd30/scd30.html +95 -0
- package/nodes/scd30/scd30.js +65 -0
- package/nodes/scd40/scd40.html +106 -0
- package/nodes/scd40/scd40.js +67 -0
- package/package.json +14 -4
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "scd40-tab",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "SCD40 CO2 monitor",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "Room CO2 monitor with a Sensirion SCD40. An inject node fires every 5 s and asks for the next sample (the sensor measures every 5 s in periodic mode). A function node classifies the CO2 level (good below 1000 ppm, moderate up to 1500 ppm, poor above) and feeds dashboard gauges for CO2, temperature and humidity; the debug node shows the whole sample with the rating. Choose periodic or low-power mode, the temperature offset and the altitude in the device configuration; offset and altitude are written to the sensor RAM at deploy when they differ."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "scd40-inject",
|
|
11
|
+
"type": "inject",
|
|
12
|
+
"z": "scd40-tab",
|
|
13
|
+
"name": "every 5 s",
|
|
14
|
+
"props": [
|
|
15
|
+
{
|
|
16
|
+
"p": "payload"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"repeat": "5",
|
|
20
|
+
"crontab": "",
|
|
21
|
+
"once": true,
|
|
22
|
+
"onceDelay": 2,
|
|
23
|
+
"topic": "",
|
|
24
|
+
"payloadType": "date",
|
|
25
|
+
"x": 150,
|
|
26
|
+
"y": 160,
|
|
27
|
+
"wires": [
|
|
28
|
+
[
|
|
29
|
+
"scd40-node"
|
|
30
|
+
]
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "scd40-device-1",
|
|
35
|
+
"type": "scd40-device",
|
|
36
|
+
"name": "SCD40",
|
|
37
|
+
"bus": "1",
|
|
38
|
+
"altitude": "0",
|
|
39
|
+
"mode": "periodic",
|
|
40
|
+
"offset": "4"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"id": "scd40-node",
|
|
44
|
+
"type": "scd40",
|
|
45
|
+
"z": "scd40-tab",
|
|
46
|
+
"name": "SCD40",
|
|
47
|
+
"device": "scd40-device-1",
|
|
48
|
+
"x": 340,
|
|
49
|
+
"y": 160,
|
|
50
|
+
"wires": [
|
|
51
|
+
[
|
|
52
|
+
"scd40-label"
|
|
53
|
+
]
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
"id": "scd40-label",
|
|
58
|
+
"type": "function",
|
|
59
|
+
"z": "scd40-tab",
|
|
60
|
+
"name": "CO2 rating",
|
|
61
|
+
"func": "const p = msg.payload;\np.rating = p.co2_ppm < 1000 ? 'good' : p.co2_ppm <= 1500 ? 'moderate' : 'poor';\nreturn [msg, { payload: Math.round(p.co2_ppm) }, { payload: p.temperature_c.toFixed(1) }, { payload: p.humidity_rh.toFixed(0) }];",
|
|
62
|
+
"outputs": 4,
|
|
63
|
+
"noerr": 0,
|
|
64
|
+
"initialize": "",
|
|
65
|
+
"finalize": "",
|
|
66
|
+
"libs": [],
|
|
67
|
+
"x": 540,
|
|
68
|
+
"y": 160,
|
|
69
|
+
"wires": [
|
|
70
|
+
[
|
|
71
|
+
"scd40-debug"
|
|
72
|
+
],
|
|
73
|
+
[
|
|
74
|
+
"scd40-gauge-co2"
|
|
75
|
+
],
|
|
76
|
+
[
|
|
77
|
+
"scd40-gauge-t"
|
|
78
|
+
],
|
|
79
|
+
[
|
|
80
|
+
"scd40-gauge-rh"
|
|
81
|
+
]
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"id": "scd40-debug",
|
|
86
|
+
"type": "debug",
|
|
87
|
+
"z": "scd40-tab",
|
|
88
|
+
"name": "Sample",
|
|
89
|
+
"active": true,
|
|
90
|
+
"tosidebar": true,
|
|
91
|
+
"console": false,
|
|
92
|
+
"tostatus": false,
|
|
93
|
+
"complete": "payload",
|
|
94
|
+
"targetType": "msg",
|
|
95
|
+
"statusVal": "",
|
|
96
|
+
"statusType": "auto",
|
|
97
|
+
"x": 760,
|
|
98
|
+
"y": 80,
|
|
99
|
+
"wires": []
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"id": "scd40-gauge-co2",
|
|
103
|
+
"type": "ui_gauge",
|
|
104
|
+
"z": "scd40-tab",
|
|
105
|
+
"name": "CO2 gauge",
|
|
106
|
+
"group": "scd40-group-1",
|
|
107
|
+
"order": 1,
|
|
108
|
+
"width": 6,
|
|
109
|
+
"height": 4,
|
|
110
|
+
"gtype": "gage",
|
|
111
|
+
"title": "CO2",
|
|
112
|
+
"label": "ppm",
|
|
113
|
+
"format": "{{value}}",
|
|
114
|
+
"min": 400,
|
|
115
|
+
"max": 3000,
|
|
116
|
+
"colors": [
|
|
117
|
+
"#00b500",
|
|
118
|
+
"#e6e600",
|
|
119
|
+
"#ca3838"
|
|
120
|
+
],
|
|
121
|
+
"seg1": "1000",
|
|
122
|
+
"seg2": "1500",
|
|
123
|
+
"x": 760,
|
|
124
|
+
"y": 140,
|
|
125
|
+
"wires": []
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"id": "scd40-gauge-t",
|
|
129
|
+
"type": "ui_gauge",
|
|
130
|
+
"z": "scd40-tab",
|
|
131
|
+
"name": "Temperature gauge",
|
|
132
|
+
"group": "scd40-group-1",
|
|
133
|
+
"order": 2,
|
|
134
|
+
"width": 6,
|
|
135
|
+
"height": 4,
|
|
136
|
+
"gtype": "gage",
|
|
137
|
+
"title": "Temperature",
|
|
138
|
+
"label": "C",
|
|
139
|
+
"format": "{{value}}",
|
|
140
|
+
"min": 0,
|
|
141
|
+
"max": 40,
|
|
142
|
+
"colors": [
|
|
143
|
+
"#2e86de",
|
|
144
|
+
"#00b500",
|
|
145
|
+
"#ca3838"
|
|
146
|
+
],
|
|
147
|
+
"seg1": "26",
|
|
148
|
+
"seg2": "30",
|
|
149
|
+
"x": 760,
|
|
150
|
+
"y": 200,
|
|
151
|
+
"wires": []
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"id": "scd40-gauge-rh",
|
|
155
|
+
"type": "ui_gauge",
|
|
156
|
+
"z": "scd40-tab",
|
|
157
|
+
"name": "Humidity gauge",
|
|
158
|
+
"group": "scd40-group-1",
|
|
159
|
+
"order": 3,
|
|
160
|
+
"width": 6,
|
|
161
|
+
"height": 4,
|
|
162
|
+
"gtype": "gage",
|
|
163
|
+
"title": "Humidity",
|
|
164
|
+
"label": "%RH",
|
|
165
|
+
"format": "{{value}}",
|
|
166
|
+
"min": 0,
|
|
167
|
+
"max": 100,
|
|
168
|
+
"colors": [
|
|
169
|
+
"#e6e600",
|
|
170
|
+
"#00b500",
|
|
171
|
+
"#2e86de"
|
|
172
|
+
],
|
|
173
|
+
"seg1": "30",
|
|
174
|
+
"seg2": "60",
|
|
175
|
+
"x": 760,
|
|
176
|
+
"y": 260,
|
|
177
|
+
"wires": []
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
"id": "scd40-group-1",
|
|
181
|
+
"type": "ui_group",
|
|
182
|
+
"name": "SCD40 CO2",
|
|
183
|
+
"tab": "scd40-ui-tab-1",
|
|
184
|
+
"order": 1,
|
|
185
|
+
"disp": true,
|
|
186
|
+
"width": 6
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"id": "scd40-ui-tab-1",
|
|
190
|
+
"type": "ui_tab",
|
|
191
|
+
"name": "SCD40 Demo",
|
|
192
|
+
"icon": "dashboard",
|
|
193
|
+
"order": 1
|
|
194
|
+
}
|
|
195
|
+
]
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
<!-- Config node: one instance per physical device -->
|
|
2
|
+
<script type="text/javascript">
|
|
3
|
+
RED.nodes.registerType('ccs811-device', {
|
|
4
|
+
category: 'config',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
|
+
address: { value: '0x5A' },
|
|
9
|
+
mode: { value: '1' }
|
|
10
|
+
},
|
|
11
|
+
label: function() {
|
|
12
|
+
return this.name || ('CCS811 @ ' + this.address + ' (bus ' + this.bus + ')');
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script type="text/html" data-template-name="ccs811-device">
|
|
18
|
+
<div class="form-row">
|
|
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="CCS811">
|
|
21
|
+
</div>
|
|
22
|
+
<div class="form-row">
|
|
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)
|
|
25
|
+
</div>
|
|
26
|
+
<div class="form-row">
|
|
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:120px">
|
|
29
|
+
<option value="0x5A" selected>0x5A (ADDR low)</option>
|
|
30
|
+
<option value="0x5B">0x5B (ADDR high)</option>
|
|
31
|
+
</select>
|
|
32
|
+
</div>
|
|
33
|
+
<div class="form-row">
|
|
34
|
+
<label for="node-config-input-mode"><i class="fa fa-cog"></i> Drive mode</label>
|
|
35
|
+
<select id="node-config-input-mode" style="width:220px">
|
|
36
|
+
<option value="1" selected>1: every 1 s (constant power)</option>
|
|
37
|
+
<option value="2">2: every 10 s (pulse heating)</option>
|
|
38
|
+
<option value="3">3: every 60 s (low-power pulse)</option>
|
|
39
|
+
</select>
|
|
40
|
+
</div>
|
|
41
|
+
</script>
|
|
42
|
+
|
|
43
|
+
<!-- Read node -->
|
|
44
|
+
<script type="text/javascript">
|
|
45
|
+
RED.nodes.registerType('ccs811', {
|
|
46
|
+
category: 'Peripheral',
|
|
47
|
+
color: '#C084FC',
|
|
48
|
+
defaults: {
|
|
49
|
+
name: { value: '' },
|
|
50
|
+
device: { value: '', type: 'ccs811-device', required: true }
|
|
51
|
+
},
|
|
52
|
+
inputs: 1,
|
|
53
|
+
outputs: 1,
|
|
54
|
+
icon: 'bridge.svg',
|
|
55
|
+
label: function() { return this.name || 'CCS811'; },
|
|
56
|
+
paletteLabel: 'CCS811'
|
|
57
|
+
});
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<script type="text/html" data-template-name="ccs811">
|
|
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="CCS811">
|
|
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="ccs811">
|
|
72
|
+
<p>Reads equivalent CO₂ (eCO₂) and total VOC (TVOC) from a ScioSense CCS811 over I²C
|
|
73
|
+
(address 0x5A or 0x5B), one sample per message.</p>
|
|
74
|
+
<h3>Inputs</h3>
|
|
75
|
+
<dl class="message-properties">
|
|
76
|
+
<dt>payload <span class="property-type">any</span></dt>
|
|
77
|
+
<dd>Any incoming message returns the next sample; if none is ready yet, the node waits for it.</dd>
|
|
78
|
+
<dt class="optional">humidity <span class="property-type">number</span></dt>
|
|
79
|
+
<dd>Relative humidity in % (0–100). With <code>msg.temperature</code>, written as environment data
|
|
80
|
+
before the read to improve the compensation.</dd>
|
|
81
|
+
<dt class="optional">temperature <span class="property-type">number</span></dt>
|
|
82
|
+
<dd>Ambient temperature in °C (-25 to 102), used together with <code>msg.humidity</code>.</dd>
|
|
83
|
+
</dl>
|
|
84
|
+
<h3>Outputs</h3>
|
|
85
|
+
<dl class="message-properties">
|
|
86
|
+
<dt>payload.eco2_ppm <span class="property-type">number</span></dt>
|
|
87
|
+
<dd>Equivalent CO₂ in ppm (400–8192), estimated from the VOC level.</dd>
|
|
88
|
+
<dt>payload.tvoc_ppb <span class="property-type">number</span></dt>
|
|
89
|
+
<dd>Total volatile organic compounds in ppb (0–1187).</dd>
|
|
90
|
+
</dl>
|
|
91
|
+
<h3>Configuration</h3>
|
|
92
|
+
<dl class="message-properties">
|
|
93
|
+
<dt>I²C bus <span class="property-type">number</span></dt>
|
|
94
|
+
<dd>Linux bus number N of <code>/dev/i2c-N</code>. The chip stretches the clock; lower the bus
|
|
95
|
+
speed if the host does not support clock stretching.</dd>
|
|
96
|
+
<dt>I²C address <span class="property-type">0x5A | 0x5B</span></dt>
|
|
97
|
+
<dd>0x5A with ADDR low (default), 0x5B with ADDR high.</dd>
|
|
98
|
+
<dt>Drive mode <span class="property-type">1 | 2 | 3</span></dt>
|
|
99
|
+
<dd>Sample interval: 1 s, 10 s or 60 s. Slower modes use less power; with mode 2 or 3 a message
|
|
100
|
+
can wait up to one interval for its sample.</dd>
|
|
101
|
+
</dl>
|
|
102
|
+
<h3>Details</h3>
|
|
103
|
+
<p>The node starts the chip's application firmware at deploy. Tie nWAKE low. Values settle about
|
|
104
|
+
20 minutes after power-up; a new sensor needs a 48 h burn-in.</p>
|
|
105
|
+
</script>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function(RED) {
|
|
4
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
|
+
const { CCS811Full } = require('periph/src/chips/gas/ccs811');
|
|
6
|
+
|
|
7
|
+
function CCS811DeviceNode(config) {
|
|
8
|
+
RED.nodes.createNode(this, config);
|
|
9
|
+
const node = this;
|
|
10
|
+
try {
|
|
11
|
+
const address = parseInt(config.address, 16) || 0x5A;
|
|
12
|
+
const connection = new I2CConnection(parseInt(config.bus), address);
|
|
13
|
+
node.connection = connection;
|
|
14
|
+
node.driver = new CCS811Full(connection);
|
|
15
|
+
node.ready = (async () => {
|
|
16
|
+
await node.driver.init();
|
|
17
|
+
const mode = parseInt(config.mode);
|
|
18
|
+
if (!isNaN(mode) && mode !== 1) await node.driver.setMode(mode);
|
|
19
|
+
})();
|
|
20
|
+
node.ready.catch((e) => {
|
|
21
|
+
node.error('CCS811 init failed: ' + e.message);
|
|
22
|
+
});
|
|
23
|
+
} catch (e) {
|
|
24
|
+
node.error('CCS811 init failed: ' + e.message);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
node.on('close', function() {
|
|
28
|
+
if (node.connection) node.connection.close();
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
RED.nodes.registerType('ccs811-device', CCS811DeviceNode);
|
|
32
|
+
|
|
33
|
+
function CCS811ReadNode(config) {
|
|
34
|
+
RED.nodes.createNode(this, config);
|
|
35
|
+
const node = this;
|
|
36
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
37
|
+
|
|
38
|
+
node.on('input', async function(msg, send, done) {
|
|
39
|
+
if (!deviceNode.driver) {
|
|
40
|
+
node.error('CCS811 not initialised', msg);
|
|
41
|
+
done();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
await deviceNode.ready;
|
|
46
|
+
if (typeof msg.humidity === 'number' && typeof msg.temperature === 'number') {
|
|
47
|
+
await deviceNode.driver.setEnvironment(msg.humidity, msg.temperature);
|
|
48
|
+
}
|
|
49
|
+
const { eco2_ppm, tvoc_ppb } = await deviceNode.driver.read();
|
|
50
|
+
msg.payload = { eco2_ppm, tvoc_ppb };
|
|
51
|
+
send(msg);
|
|
52
|
+
done();
|
|
53
|
+
} catch (e) {
|
|
54
|
+
done(e);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
RED.nodes.registerType('ccs811', CCS811ReadNode);
|
|
59
|
+
};
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
<!-- Config node: one instance per physical device -->
|
|
2
|
+
<script type="text/javascript">
|
|
3
|
+
RED.nodes.registerType('rrh46410-device', {
|
|
4
|
+
category: 'config',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
|
+
mode: { value: '1' },
|
|
9
|
+
humidity: { value: '50', validate: RED.validators.number() }
|
|
10
|
+
},
|
|
11
|
+
label: function() {
|
|
12
|
+
return this.name || ('RRH46410 @ 0x38 (bus ' + this.bus + ')');
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script type="text/html" data-template-name="rrh46410-device">
|
|
18
|
+
<div class="form-row">
|
|
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="RRH46410">
|
|
21
|
+
</div>
|
|
22
|
+
<div class="form-row">
|
|
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, address 0x38)
|
|
25
|
+
</div>
|
|
26
|
+
<div class="form-row">
|
|
27
|
+
<label for="node-config-input-mode"><i class="fa fa-cog"></i> Operation mode</label>
|
|
28
|
+
<select id="node-config-input-mode" style="width:260px">
|
|
29
|
+
<option value="1" selected>IAQ 2nd Gen (every 3 s)</option>
|
|
30
|
+
<option value="2">ULP (every 90 s)</option>
|
|
31
|
+
<option value="5">PBAQ (every 5 s, TVOC and ethanol)</option>
|
|
32
|
+
</select>
|
|
33
|
+
</div>
|
|
34
|
+
<div class="form-row">
|
|
35
|
+
<label for="node-config-input-humidity"><i class="fa fa-tint"></i> Humidity (%RH)</label>
|
|
36
|
+
<input type="number" id="node-config-input-humidity" min="0" max="100" style="width:80px">
|
|
37
|
+
</div>
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<!-- Read node -->
|
|
41
|
+
<script type="text/javascript">
|
|
42
|
+
RED.nodes.registerType('rrh46410', {
|
|
43
|
+
category: 'Peripheral',
|
|
44
|
+
color: '#C084FC',
|
|
45
|
+
defaults: {
|
|
46
|
+
name: { value: '' },
|
|
47
|
+
device: { value: '', type: 'rrh46410-device', required: true }
|
|
48
|
+
},
|
|
49
|
+
inputs: 1,
|
|
50
|
+
outputs: 1,
|
|
51
|
+
icon: 'bridge.svg',
|
|
52
|
+
label: function() { return this.name || 'RRH46410'; },
|
|
53
|
+
paletteLabel: 'RRH46410'
|
|
54
|
+
});
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<script type="text/html" data-template-name="rrh46410">
|
|
58
|
+
<div class="form-row">
|
|
59
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
60
|
+
<input type="text" id="node-input-name" placeholder="RRH46410">
|
|
61
|
+
</div>
|
|
62
|
+
<div class="form-row">
|
|
63
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
64
|
+
<input type="text" id="node-input-device">
|
|
65
|
+
</div>
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<script type="text/html" data-help-name="rrh46410">
|
|
69
|
+
<p>Reads the indoor air quality (IAQ index, TVOC, ethanol equivalent, eCO₂ and relative IAQ) from a
|
|
70
|
+
Renesas RRH46410 gas sensor module over I²C (address 0x38), one result per message.</p>
|
|
71
|
+
<h3>Inputs</h3>
|
|
72
|
+
<dl class="message-properties">
|
|
73
|
+
<dt>payload <span class="property-type">any</span></dt>
|
|
74
|
+
<dd>Any incoming message returns the latest sample; before the first sample of the mode the node
|
|
75
|
+
waits for it.</dd>
|
|
76
|
+
<dt class="optional">humidity <span class="property-type">number</span></dt>
|
|
77
|
+
<dd>Ambient relative humidity in % (0–100), sent to the module for compensation before the read.</dd>
|
|
78
|
+
</dl>
|
|
79
|
+
<h3>Outputs</h3>
|
|
80
|
+
<dl class="message-properties">
|
|
81
|
+
<dt>payload.iaq <span class="property-type">number</span></dt>
|
|
82
|
+
<dd>IAQ index, UBA level 1.0 (very good) to 5.0 (bad). Absent in PBAQ mode.</dd>
|
|
83
|
+
<dt>payload.tvoc_mg_m3 <span class="property-type">number</span></dt>
|
|
84
|
+
<dd>Total volatile organic compounds in mg/m³.</dd>
|
|
85
|
+
<dt>payload.etoh_ppm <span class="property-type">number</span></dt>
|
|
86
|
+
<dd>Ethanol equivalent in ppm.</dd>
|
|
87
|
+
<dt>payload.eco2_ppm <span class="property-type">number</span></dt>
|
|
88
|
+
<dd>Estimated CO₂ in ppm. Absent in PBAQ mode.</dd>
|
|
89
|
+
<dt>payload.relative_iaq <span class="property-type">number</span></dt>
|
|
90
|
+
<dd>Relative IAQ. Absent in PBAQ mode.</dd>
|
|
91
|
+
<dt>payload.warmed_up <span class="property-type">boolean</span></dt>
|
|
92
|
+
<dd>False during the warm-up (100 samples ≈ 5 min in IAQ 2nd Gen mode), while the values stay fixed.</dd>
|
|
93
|
+
</dl>
|
|
94
|
+
<h3>Configuration</h3>
|
|
95
|
+
<dl class="message-properties">
|
|
96
|
+
<dt>I²C bus <span class="property-type">number</span></dt>
|
|
97
|
+
<dd>Linux bus number N of <code>/dev/i2c-N</code>. The address is fixed at 0x38. The module stretches
|
|
98
|
+
the clock; lower the bus speed if the host does not support clock stretching.</dd>
|
|
99
|
+
<dt>Operation mode <span class="property-type">1 | 2 | 5</span></dt>
|
|
100
|
+
<dd>IAQ 2nd Gen (sample every 3 s), ULP (every 90 s, 0.23 mW) or PBAQ (every 5 s, TVOC and ethanol
|
|
101
|
+
only).</dd>
|
|
102
|
+
<dt>Humidity <span class="property-type">number</span></dt>
|
|
103
|
+
<dd>Ambient relative humidity in % written at deploy (the module assumes 50 %RH).</dd>
|
|
104
|
+
</dl>
|
|
105
|
+
<h3>Details</h3>
|
|
106
|
+
<p>The node verifies the product ID (0x2310) and starts the selected mode at deploy. Each mode needs a
|
|
107
|
+
warm-up before its results are valid; 48 hours of continuous operation give the best stability.</p>
|
|
108
|
+
</script>
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function(RED) {
|
|
4
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
|
+
const { RRH46410Full } = require('periph/src/chips/gas/rrh46410');
|
|
6
|
+
|
|
7
|
+
function RRH46410DeviceNode(config) {
|
|
8
|
+
RED.nodes.createNode(this, config);
|
|
9
|
+
const node = this;
|
|
10
|
+
try {
|
|
11
|
+
const connection = new I2CConnection(parseInt(config.bus), 0x38);
|
|
12
|
+
node.connection = connection;
|
|
13
|
+
node.driver = new RRH46410Full(connection);
|
|
14
|
+
node.ready = (async () => {
|
|
15
|
+
await node.driver.init();
|
|
16
|
+
const humidity = parseFloat(config.humidity);
|
|
17
|
+
if (!isNaN(humidity) && humidity !== 50) await node.driver.setHumidity(humidity);
|
|
18
|
+
const mode = parseInt(config.mode);
|
|
19
|
+
if (!isNaN(mode) && mode !== RRH46410Full.MODE_IAQ_2ND_GEN) await node.driver.setMode(mode);
|
|
20
|
+
})();
|
|
21
|
+
node.ready.catch((e) => {
|
|
22
|
+
node.error('RRH46410 init failed: ' + e.message);
|
|
23
|
+
});
|
|
24
|
+
} catch (e) {
|
|
25
|
+
node.error('RRH46410 init failed: ' + e.message);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
node.on('close', function() {
|
|
29
|
+
if (node.connection) node.connection.close();
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
RED.nodes.registerType('rrh46410-device', RRH46410DeviceNode);
|
|
33
|
+
|
|
34
|
+
function RRH46410ReadNode(config) {
|
|
35
|
+
RED.nodes.createNode(this, config);
|
|
36
|
+
const node = this;
|
|
37
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
38
|
+
|
|
39
|
+
node.on('input', async function(msg, send, done) {
|
|
40
|
+
if (!deviceNode.driver) {
|
|
41
|
+
node.error('RRH46410 not initialised', msg);
|
|
42
|
+
done();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
try {
|
|
46
|
+
await deviceNode.ready;
|
|
47
|
+
const driver = deviceNode.driver;
|
|
48
|
+
if (typeof msg.humidity === 'number') await driver.setHumidity(msg.humidity);
|
|
49
|
+
let r = await driver.readResults();
|
|
50
|
+
if (r === null) r = await driver.read();
|
|
51
|
+
const { iaq, tvoc_mg_m3, etoh_ppm, eco2_ppm, relative_iaq, warmed_up } = r;
|
|
52
|
+
msg.payload = { iaq, tvoc_mg_m3, etoh_ppm, eco2_ppm, relative_iaq, warmed_up };
|
|
53
|
+
send(msg);
|
|
54
|
+
done();
|
|
55
|
+
} catch (e) {
|
|
56
|
+
done(e);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
RED.nodes.registerType('rrh46410', RRH46410ReadNode);
|
|
61
|
+
};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<!-- Config node: one instance per physical device -->
|
|
2
|
+
<script type="text/javascript">
|
|
3
|
+
RED.nodes.registerType('rrh62000-device', {
|
|
4
|
+
category: 'config',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
|
+
movingAverage: { value: '10', validate: RED.validators.number() },
|
|
9
|
+
fanSpeed: { value: '86', validate: RED.validators.number() }
|
|
10
|
+
},
|
|
11
|
+
label: function() {
|
|
12
|
+
return this.name || ('RRH62000 @ 0x69 (bus ' + this.bus + ')');
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script type="text/html" data-template-name="rrh62000-device">
|
|
18
|
+
<div class="form-row">
|
|
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="RRH62000">
|
|
21
|
+
</div>
|
|
22
|
+
<div class="form-row">
|
|
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, address 0x69)
|
|
25
|
+
</div>
|
|
26
|
+
<div class="form-row">
|
|
27
|
+
<label for="node-config-input-movingAverage"><i class="fa fa-line-chart"></i> Moving average</label>
|
|
28
|
+
<input type="number" id="node-config-input-movingAverage" min="1" max="60" style="width:80px"> samples (1–60)
|
|
29
|
+
</div>
|
|
30
|
+
<div class="form-row">
|
|
31
|
+
<label for="node-config-input-fanSpeed"><i class="fa fa-refresh"></i> Fan speed</label>
|
|
32
|
+
<input type="number" id="node-config-input-fanSpeed" min="60" max="100" style="width:80px"> % (60–100)
|
|
33
|
+
</div>
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<!-- Read node -->
|
|
37
|
+
<script type="text/javascript">
|
|
38
|
+
RED.nodes.registerType('rrh62000', {
|
|
39
|
+
category: 'Peripheral',
|
|
40
|
+
color: '#C084FC',
|
|
41
|
+
defaults: {
|
|
42
|
+
name: { value: '' },
|
|
43
|
+
device: { value: '', type: 'rrh62000-device', required: true }
|
|
44
|
+
},
|
|
45
|
+
inputs: 1,
|
|
46
|
+
outputs: 1,
|
|
47
|
+
icon: 'bridge.svg',
|
|
48
|
+
label: function() { return this.name || 'RRH62000'; },
|
|
49
|
+
paletteLabel: 'RRH62000'
|
|
50
|
+
});
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<script type="text/html" data-template-name="rrh62000">
|
|
54
|
+
<div class="form-row">
|
|
55
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
56
|
+
<input type="text" id="node-input-name" placeholder="RRH62000">
|
|
57
|
+
</div>
|
|
58
|
+
<div class="form-row">
|
|
59
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
60
|
+
<input type="text" id="node-input-device">
|
|
61
|
+
</div>
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<script type="text/html" data-help-name="rrh62000">
|
|
65
|
+
<p>Reads particulate matter, temperature, humidity, TVOC, estimated CO₂ and the IAQ index from a Renesas
|
|
66
|
+
RRH62000 air-quality module over I²C (address 0x69), one sample per message.</p>
|
|
67
|
+
<h3>Inputs</h3>
|
|
68
|
+
<dl class="message-properties">
|
|
69
|
+
<dt>payload <span class="property-type">any</span></dt>
|
|
70
|
+
<dd>Any incoming message waits for the next sample (one every 3 s) and returns it.</dd>
|
|
71
|
+
</dl>
|
|
72
|
+
<h3>Outputs</h3>
|
|
73
|
+
<dl class="message-properties">
|
|
74
|
+
<dt>payload.pm1_ug_m3 <span class="property-type">number</span></dt>
|
|
75
|
+
<dd>PM1 mass concentration in µg/m³ (KCl reference).</dd>
|
|
76
|
+
<dt>payload.pm2_5_ug_m3 <span class="property-type">number</span></dt>
|
|
77
|
+
<dd>PM2.5 mass concentration in µg/m³ (KCl reference).</dd>
|
|
78
|
+
<dt>payload.pm10_ug_m3 <span class="property-type">number</span></dt>
|
|
79
|
+
<dd>PM10 mass concentration in µg/m³ (KCl reference).</dd>
|
|
80
|
+
<dt>payload.temperature_c <span class="property-type">number</span></dt>
|
|
81
|
+
<dd>Temperature in °C.</dd>
|
|
82
|
+
<dt>payload.humidity_rh <span class="property-type">number</span></dt>
|
|
83
|
+
<dd>Relative humidity in %RH.</dd>
|
|
84
|
+
<dt>payload.tvoc <span class="property-type">number</span></dt>
|
|
85
|
+
<dd>Total volatile organic compounds in µg/m³ (resolution 10 µg/m³).</dd>
|
|
86
|
+
<dt>payload.eco2_ppm <span class="property-type">number</span></dt>
|
|
87
|
+
<dd>Estimated CO₂ in ppm (400–5000).</dd>
|
|
88
|
+
<dt>payload.iaq <span class="property-type">number</span></dt>
|
|
89
|
+
<dd>UBA indoor air quality index, 1.00 (very good) to 5.00 (bad).</dd>
|
|
90
|
+
</dl>
|
|
91
|
+
<h3>Configuration</h3>
|
|
92
|
+
<dl class="message-properties">
|
|
93
|
+
<dt>I²C bus <span class="property-type">number</span></dt>
|
|
94
|
+
<dd>Linux bus number N of <code>/dev/i2c-N</code>. The address is fixed at 0x69; the SEL pin must be at GND.</dd>
|
|
95
|
+
<dt>Moving average <span class="property-type">number</span></dt>
|
|
96
|
+
<dd>Number of moving averages, 1–60 (module default 10); written at deploy when it differs.</dd>
|
|
97
|
+
<dt>Fan speed <span class="property-type">number</span></dt>
|
|
98
|
+
<dd>Fan speed in %, 60–100 (module default 86); written at deploy when it differs.</dd>
|
|
99
|
+
</dl>
|
|
100
|
+
<h3>Details</h3>
|
|
101
|
+
<p>The module may be accessed at most once per second; the node waits as needed and handles overlapping
|
|
102
|
+
messages one after another. A read polls the new-data flag and then reads the 37-byte block, so it takes about
|
|
103
|
+
2 s. Allow up to 48 hours of conditioning on first use before trusting TVOC and eCO₂.</p>
|
|
104
|
+
</script>
|