node-red-contrib-periph-gas 1.6.0 → 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 CHANGED
@@ -1,8 +1,8 @@
1
1
  # node-red-contrib-periph-gas
2
2
 
3
- Node-RED nodes for gas sensor chips: CCS811, ENS160, RRH46410 — part of the [Periph](https://github.com/tuhde/Periph) library.
3
+ Node-RED nodes for gas sensor chips: CCS811, ENS160, RRH46410, RRH62000, SCD30, SCD40 — part of the [Periph](https://github.com/tuhde/Periph) library.
4
4
 
5
- **Supported chips (3):** CCS811, ENS160, RRH46410.
5
+ **Supported chips (6):** CCS811, ENS160, RRH46410, RRH62000, SCD30, SCD40.
6
6
 
7
7
  Each chip has a sensor/actuator node plus a shared `-device` config node that holds the bus settings. Importable example flows are in [`examples/`](https://github.com/tuhde/Periph/tree/main/nodejs/packages/node-red-contrib-periph-gas/examples).
8
8
 
@@ -26,6 +26,12 @@ npm install node-red-contrib-periph-gas
26
26
  | `ens160` | input | Reads air quality (AQI, TVOC, eCO2) from an ENS160 digital multi-gas sensor. |
27
27
  | `rrh46410-device` | config | Bus configuration for a RRH46410 |
28
28
  | `rrh46410` | input | Reads the indoor air quality (IAQ index, TVOC, ethanol equivalent, eCO₂ and relative IAQ) from a Renesas RRH46410 gas sensor module over I²C (address 0x38), one result per message. |
29
+ | `rrh62000-device` | config | Bus configuration for a RRH62000 |
30
+ | `rrh62000` | input | Reads particulate matter, temperature, humidity, TVOC, estimated CO₂ and the IAQ index from a Renesas RRH62000 air-quality module over I²C (address 0x69), one sample per message. |
31
+ | `scd30-device` | config | Bus configuration for a SCD30 |
32
+ | `scd30` | input | Reads CO₂, temperature and humidity from a Sensirion SCD30 NDIR CO₂ sensor module over I²C (address 0x61), one sample per message. |
33
+ | `scd40-device` | config | Bus configuration for a SCD40 |
34
+ | `scd40` | input | Reads CO₂, temperature and humidity from a Sensirion SCD40 photoacoustic CO₂ sensor over I²C (address 0x62), one sample per message. |
29
35
 
30
36
  ## Links
31
37
 
@@ -0,0 +1,194 @@
1
+ [
2
+ {
3
+ "id": "rrh62000-tab",
4
+ "type": "tab",
5
+ "label": "RRH62000 air quality",
6
+ "disabled": false,
7
+ "info": "Room air-quality station with a Renesas RRH62000. An inject node fires every 5 s and asks for the next sample (the module produces one every 3 s and allows one I2C access per second, so a read takes about 2 s). A function node maps the IAQ index to the UBA rating (very good below 2.0, good, medium, poor, bad from 5.0) and feeds dashboard gauges for PM2.5, IAQ and eCO2; the debug node shows the whole sample with the rating. Change the moving average or the fan speed in the device configuration; allow up to 48 h of conditioning on first use before trusting TVOC and eCO2."
8
+ },
9
+ {
10
+ "id": "rrh62000-inject",
11
+ "type": "inject",
12
+ "z": "rrh62000-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
+ "rrh62000-node"
30
+ ]
31
+ ]
32
+ },
33
+ {
34
+ "id": "rrh62000-device-1",
35
+ "type": "rrh62000-device",
36
+ "name": "RRH62000",
37
+ "bus": "1",
38
+ "movingAverage": "10",
39
+ "fanSpeed": "86"
40
+ },
41
+ {
42
+ "id": "rrh62000-node",
43
+ "type": "rrh62000",
44
+ "z": "rrh62000-tab",
45
+ "name": "RRH62000",
46
+ "device": "rrh62000-device-1",
47
+ "x": 340,
48
+ "y": 160,
49
+ "wires": [
50
+ [
51
+ "rrh62000-label"
52
+ ]
53
+ ]
54
+ },
55
+ {
56
+ "id": "rrh62000-label",
57
+ "type": "function",
58
+ "z": "rrh62000-tab",
59
+ "name": "IAQ rating",
60
+ "func": "const p = msg.payload;\np.rating = p.iaq < 2 ? 'very good' : p.iaq < 3 ? 'good' : p.iaq < 4 ? 'medium' : p.iaq < 5 ? 'poor' : 'bad';\nreturn [msg, { payload: p.pm2_5_ug_m3 }, { payload: p.iaq }, { payload: p.eco2_ppm }];",
61
+ "outputs": 4,
62
+ "noerr": 0,
63
+ "initialize": "",
64
+ "finalize": "",
65
+ "libs": [],
66
+ "x": 540,
67
+ "y": 160,
68
+ "wires": [
69
+ [
70
+ "rrh62000-debug"
71
+ ],
72
+ [
73
+ "rrh62000-gauge-pm"
74
+ ],
75
+ [
76
+ "rrh62000-gauge-iaq"
77
+ ],
78
+ [
79
+ "rrh62000-gauge-co2"
80
+ ]
81
+ ]
82
+ },
83
+ {
84
+ "id": "rrh62000-debug",
85
+ "type": "debug",
86
+ "z": "rrh62000-tab",
87
+ "name": "Sample",
88
+ "active": true,
89
+ "tosidebar": true,
90
+ "console": false,
91
+ "tostatus": false,
92
+ "complete": "payload",
93
+ "targetType": "msg",
94
+ "statusVal": "",
95
+ "statusType": "auto",
96
+ "x": 760,
97
+ "y": 80,
98
+ "wires": []
99
+ },
100
+ {
101
+ "id": "rrh62000-gauge-pm",
102
+ "type": "ui_gauge",
103
+ "z": "rrh62000-tab",
104
+ "name": "PM2.5 gauge",
105
+ "group": "rrh62000-group-1",
106
+ "order": 1,
107
+ "width": 6,
108
+ "height": 4,
109
+ "gtype": "gage",
110
+ "title": "PM2.5",
111
+ "label": "ug/m3",
112
+ "format": "{{value}}",
113
+ "min": 0,
114
+ "max": 100,
115
+ "colors": [
116
+ "#00b500",
117
+ "#e6e600",
118
+ "#ca3838"
119
+ ],
120
+ "seg1": "15",
121
+ "seg2": "35",
122
+ "x": 760,
123
+ "y": 140,
124
+ "wires": []
125
+ },
126
+ {
127
+ "id": "rrh62000-gauge-iaq",
128
+ "type": "ui_gauge",
129
+ "z": "rrh62000-tab",
130
+ "name": "IAQ gauge",
131
+ "group": "rrh62000-group-1",
132
+ "order": 2,
133
+ "width": 6,
134
+ "height": 4,
135
+ "gtype": "gage",
136
+ "title": "IAQ",
137
+ "label": "UBA level",
138
+ "format": "{{value}}",
139
+ "min": 1,
140
+ "max": 5,
141
+ "colors": [
142
+ "#00b500",
143
+ "#e6e600",
144
+ "#ca3838"
145
+ ],
146
+ "seg1": "3",
147
+ "seg2": "4",
148
+ "x": 760,
149
+ "y": 200,
150
+ "wires": []
151
+ },
152
+ {
153
+ "id": "rrh62000-gauge-co2",
154
+ "type": "ui_gauge",
155
+ "z": "rrh62000-tab",
156
+ "name": "eCO2 gauge",
157
+ "group": "rrh62000-group-1",
158
+ "order": 3,
159
+ "width": 6,
160
+ "height": 4,
161
+ "gtype": "gage",
162
+ "title": "eCO2",
163
+ "label": "ppm",
164
+ "format": "{{value}}",
165
+ "min": 400,
166
+ "max": 5000,
167
+ "colors": [
168
+ "#00b500",
169
+ "#e6e600",
170
+ "#ca3838"
171
+ ],
172
+ "seg1": "1000",
173
+ "seg2": "2000",
174
+ "x": 760,
175
+ "y": 260,
176
+ "wires": []
177
+ },
178
+ {
179
+ "id": "rrh62000-group-1",
180
+ "type": "ui_group",
181
+ "name": "RRH62000 Air Quality",
182
+ "tab": "rrh62000-ui-tab-1",
183
+ "order": 1,
184
+ "disp": true,
185
+ "width": 6
186
+ },
187
+ {
188
+ "id": "rrh62000-ui-tab-1",
189
+ "type": "ui_tab",
190
+ "name": "RRH62000 Demo",
191
+ "icon": "dashboard",
192
+ "order": 1
193
+ }
194
+ ]
@@ -0,0 +1,194 @@
1
+ [
2
+ {
3
+ "id": "scd30-tab",
4
+ "type": "tab",
5
+ "label": "SCD30 CO2 monitor",
6
+ "disabled": false,
7
+ "info": "Room CO2 monitor with a Sensirion SCD30. An inject node fires every 5 s and asks for the next sample (the module measures every 2 s by default). 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. Set the measurement interval and the altitude in the device configuration; both are stored in the module and only written when they change."
8
+ },
9
+ {
10
+ "id": "scd30-inject",
11
+ "type": "inject",
12
+ "z": "scd30-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
+ "scd30-node"
30
+ ]
31
+ ]
32
+ },
33
+ {
34
+ "id": "scd30-device-1",
35
+ "type": "scd30-device",
36
+ "name": "SCD30",
37
+ "bus": "1",
38
+ "interval": "2",
39
+ "altitude": "0"
40
+ },
41
+ {
42
+ "id": "scd30-node",
43
+ "type": "scd30",
44
+ "z": "scd30-tab",
45
+ "name": "SCD30",
46
+ "device": "scd30-device-1",
47
+ "x": 340,
48
+ "y": 160,
49
+ "wires": [
50
+ [
51
+ "scd30-label"
52
+ ]
53
+ ]
54
+ },
55
+ {
56
+ "id": "scd30-label",
57
+ "type": "function",
58
+ "z": "scd30-tab",
59
+ "name": "CO2 rating",
60
+ "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) }];",
61
+ "outputs": 4,
62
+ "noerr": 0,
63
+ "initialize": "",
64
+ "finalize": "",
65
+ "libs": [],
66
+ "x": 540,
67
+ "y": 160,
68
+ "wires": [
69
+ [
70
+ "scd30-debug"
71
+ ],
72
+ [
73
+ "scd30-gauge-co2"
74
+ ],
75
+ [
76
+ "scd30-gauge-t"
77
+ ],
78
+ [
79
+ "scd30-gauge-rh"
80
+ ]
81
+ ]
82
+ },
83
+ {
84
+ "id": "scd30-debug",
85
+ "type": "debug",
86
+ "z": "scd30-tab",
87
+ "name": "Sample",
88
+ "active": true,
89
+ "tosidebar": true,
90
+ "console": false,
91
+ "tostatus": false,
92
+ "complete": "payload",
93
+ "targetType": "msg",
94
+ "statusVal": "",
95
+ "statusType": "auto",
96
+ "x": 760,
97
+ "y": 80,
98
+ "wires": []
99
+ },
100
+ {
101
+ "id": "scd30-gauge-co2",
102
+ "type": "ui_gauge",
103
+ "z": "scd30-tab",
104
+ "name": "CO2 gauge",
105
+ "group": "scd30-group-1",
106
+ "order": 1,
107
+ "width": 6,
108
+ "height": 4,
109
+ "gtype": "gage",
110
+ "title": "CO2",
111
+ "label": "ppm",
112
+ "format": "{{value}}",
113
+ "min": 400,
114
+ "max": 3000,
115
+ "colors": [
116
+ "#00b500",
117
+ "#e6e600",
118
+ "#ca3838"
119
+ ],
120
+ "seg1": "1000",
121
+ "seg2": "1500",
122
+ "x": 760,
123
+ "y": 140,
124
+ "wires": []
125
+ },
126
+ {
127
+ "id": "scd30-gauge-t",
128
+ "type": "ui_gauge",
129
+ "z": "scd30-tab",
130
+ "name": "Temperature gauge",
131
+ "group": "scd30-group-1",
132
+ "order": 2,
133
+ "width": 6,
134
+ "height": 4,
135
+ "gtype": "gage",
136
+ "title": "Temperature",
137
+ "label": "C",
138
+ "format": "{{value}}",
139
+ "min": 0,
140
+ "max": 40,
141
+ "colors": [
142
+ "#2e86de",
143
+ "#00b500",
144
+ "#ca3838"
145
+ ],
146
+ "seg1": "26",
147
+ "seg2": "30",
148
+ "x": 760,
149
+ "y": 200,
150
+ "wires": []
151
+ },
152
+ {
153
+ "id": "scd30-gauge-rh",
154
+ "type": "ui_gauge",
155
+ "z": "scd30-tab",
156
+ "name": "Humidity gauge",
157
+ "group": "scd30-group-1",
158
+ "order": 3,
159
+ "width": 6,
160
+ "height": 4,
161
+ "gtype": "gage",
162
+ "title": "Humidity",
163
+ "label": "%RH",
164
+ "format": "{{value}}",
165
+ "min": 0,
166
+ "max": 100,
167
+ "colors": [
168
+ "#e6e600",
169
+ "#00b500",
170
+ "#2e86de"
171
+ ],
172
+ "seg1": "30",
173
+ "seg2": "60",
174
+ "x": 760,
175
+ "y": 260,
176
+ "wires": []
177
+ },
178
+ {
179
+ "id": "scd30-group-1",
180
+ "type": "ui_group",
181
+ "name": "SCD30 CO2",
182
+ "tab": "scd30-ui-tab-1",
183
+ "order": 1,
184
+ "disp": true,
185
+ "width": 6
186
+ },
187
+ {
188
+ "id": "scd30-ui-tab-1",
189
+ "type": "ui_tab",
190
+ "name": "SCD30 Demo",
191
+ "icon": "dashboard",
192
+ "order": 1
193
+ }
194
+ ]
@@ -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,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"> &nbsp;(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"> &nbsp;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"> &nbsp;% (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>
@@ -0,0 +1,60 @@
1
+ 'use strict';
2
+
3
+ module.exports = function(RED) {
4
+ const { I2CConnection } = require('periph/src/connection/i2c');
5
+ const { RRH62000Full } = require('periph/src/chips/gas/rrh62000');
6
+
7
+ function RRH62000DeviceNode(config) {
8
+ RED.nodes.createNode(this, config);
9
+ const node = this;
10
+ try {
11
+ const connection = new I2CConnection(parseInt(config.bus), 0x69);
12
+ node.connection = connection;
13
+ node.driver = new RRH62000Full(connection);
14
+ node.ready = (async () => {
15
+ await node.driver.init();
16
+ const average = parseInt(config.movingAverage);
17
+ if (!isNaN(average) && average !== 10) await node.driver.setMovingAverage(average);
18
+ const fan = parseInt(config.fanSpeed);
19
+ if (!isNaN(fan) && fan !== 86) await node.driver.setFanSpeed(fan);
20
+ })();
21
+ node.ready.catch((e) => {
22
+ node.error('RRH62000 init failed: ' + e.message);
23
+ });
24
+ } catch (e) {
25
+ node.error('RRH62000 init failed: ' + e.message);
26
+ }
27
+
28
+ node.on('close', function() {
29
+ if (node.connection) node.connection.close();
30
+ });
31
+ }
32
+ RED.nodes.registerType('rrh62000-device', RRH62000DeviceNode);
33
+
34
+ function RRH62000ReadNode(config) {
35
+ RED.nodes.createNode(this, config);
36
+ const node = this;
37
+ const deviceNode = RED.nodes.getNode(config.device) || {};
38
+ let busy = Promise.resolve();
39
+
40
+ node.on('input', function(msg, send, done) {
41
+ if (!deviceNode.driver) {
42
+ node.error('RRH62000 not initialised', msg);
43
+ done();
44
+ return;
45
+ }
46
+ // The module allows one access per second; serialise overlapping messages.
47
+ busy = busy.then(async () => {
48
+ try {
49
+ await deviceNode.ready;
50
+ msg.payload = await deviceNode.driver.read();
51
+ send(msg);
52
+ done();
53
+ } catch (e) {
54
+ done(e);
55
+ }
56
+ });
57
+ });
58
+ }
59
+ RED.nodes.registerType('rrh62000', RRH62000ReadNode);
60
+ };
@@ -0,0 +1,95 @@
1
+ <!-- Config node: one instance per physical device -->
2
+ <script type="text/javascript">
3
+ RED.nodes.registerType('scd30-device', {
4
+ category: 'config',
5
+ defaults: {
6
+ name: { value: '' },
7
+ bus: { value: '1', required: true, validate: RED.validators.number() },
8
+ interval: { value: '2', validate: RED.validators.number() },
9
+ altitude: { value: '0', validate: RED.validators.number() }
10
+ },
11
+ label: function() {
12
+ return this.name || ('SCD30 @ 0x61 (bus ' + this.bus + ')');
13
+ }
14
+ });
15
+ </script>
16
+
17
+ <script type="text/html" data-template-name="scd30-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="SCD30">
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"> &nbsp;(Linux /dev/i2c-N, address 0x61)
25
+ </div>
26
+ <div class="form-row">
27
+ <label for="node-config-input-interval"><i class="fa fa-clock-o"></i> Interval</label>
28
+ <input type="number" id="node-config-input-interval" min="2" max="1800" style="width:80px"> &nbsp;s (2–1800)
29
+ </div>
30
+ <div class="form-row">
31
+ <label for="node-config-input-altitude"><i class="fa fa-area-chart"></i> Altitude</label>
32
+ <input type="number" id="node-config-input-altitude" min="0" max="65535" style="width:80px"> &nbsp;m above sea level
33
+ </div>
34
+ </script>
35
+
36
+ <!-- Read node -->
37
+ <script type="text/javascript">
38
+ RED.nodes.registerType('scd30', {
39
+ category: 'Peripheral',
40
+ color: '#C084FC',
41
+ defaults: {
42
+ name: { value: '' },
43
+ device: { value: '', type: 'scd30-device', required: true }
44
+ },
45
+ inputs: 1,
46
+ outputs: 1,
47
+ icon: 'bridge.svg',
48
+ label: function() { return this.name || 'SCD30'; },
49
+ paletteLabel: 'SCD30'
50
+ });
51
+ </script>
52
+
53
+ <script type="text/html" data-template-name="scd30">
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="SCD30">
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="scd30">
65
+ <p>Reads CO₂, temperature and humidity from a Sensirion SCD30 NDIR CO₂ sensor module over I²C (address 0x61),
66
+ 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 per measurement interval) and returns it.</dd>
71
+ </dl>
72
+ <h3>Outputs</h3>
73
+ <dl class="message-properties">
74
+ <dt>payload.co2_ppm <span class="property-type">number</span></dt>
75
+ <dd>CO₂ concentration in ppm (0–40 000).</dd>
76
+ <dt>payload.temperature_c <span class="property-type">number</span></dt>
77
+ <dd>Temperature in °C (temperature offset applied).</dd>
78
+ <dt>payload.humidity_rh <span class="property-type">number</span></dt>
79
+ <dd>Relative humidity in %RH.</dd>
80
+ </dl>
81
+ <h3>Configuration</h3>
82
+ <dl class="message-properties">
83
+ <dt>I²C bus <span class="property-type">number</span></dt>
84
+ <dd>Linux bus number N of <code>/dev/i2c-N</code>. The address is fixed at 0x61.</dd>
85
+ <dt>Interval <span class="property-type">number</span></dt>
86
+ <dd>Measurement interval in s, 2–1800 (module default 2); written at deploy when it differs.</dd>
87
+ <dt>Altitude <span class="property-type">number</span></dt>
88
+ <dd>Altitude above sea level in m for the pressure compensation (default 0); written at deploy when it differs.</dd>
89
+ </dl>
90
+ <h3>Details</h3>
91
+ <p>The module stretches the I²C clock for up to about 150 ms; on a Raspberry Pi lower the bus to 50 kHz or use a
92
+ bit-banged bus if reads fail. Interval and altitude are stored in the module's non-volatile memory. A read polls
93
+ the data-ready status and waits at most the interval plus 1 s. Automatic self-calibration stays as it is (module
94
+ default off).</p>
95
+ </script>
@@ -0,0 +1,65 @@
1
+ 'use strict';
2
+
3
+ module.exports = function(RED) {
4
+ const { I2CConnection } = require('periph/src/connection/i2c');
5
+ const { SCD30Full } = require('periph/src/chips/gas/scd30');
6
+
7
+ function SCD30DeviceNode(config) {
8
+ RED.nodes.createNode(this, config);
9
+ const node = this;
10
+ try {
11
+ const connection = new I2CConnection(parseInt(config.bus), 0x61);
12
+ node.connection = connection;
13
+ node.driver = new SCD30Full(connection);
14
+ node.ready = (async () => {
15
+ await node.driver.init();
16
+ // Interval and altitude live in non-volatile memory: write them only when they differ.
17
+ const interval = parseInt(config.interval);
18
+ if (!isNaN(interval) && interval !== await node.driver.getInterval()) {
19
+ await node.driver.setInterval(interval);
20
+ }
21
+ const altitude = parseInt(config.altitude);
22
+ if (!isNaN(altitude) && altitude !== await node.driver.getAltitude()) {
23
+ await node.driver.setAltitude(altitude);
24
+ }
25
+ })();
26
+ node.ready.catch((e) => {
27
+ node.error('SCD30 init failed: ' + e.message);
28
+ });
29
+ } catch (e) {
30
+ node.error('SCD30 init failed: ' + e.message);
31
+ }
32
+
33
+ node.on('close', function() {
34
+ if (node.connection) node.connection.close();
35
+ });
36
+ }
37
+ RED.nodes.registerType('scd30-device', SCD30DeviceNode);
38
+
39
+ function SCD30ReadNode(config) {
40
+ RED.nodes.createNode(this, config);
41
+ const node = this;
42
+ const deviceNode = RED.nodes.getNode(config.device) || {};
43
+ let busy = Promise.resolve();
44
+
45
+ node.on('input', function(msg, send, done) {
46
+ if (!deviceNode.driver) {
47
+ node.error('SCD30 not initialised', msg);
48
+ done();
49
+ return;
50
+ }
51
+ // One command/response exchange at a time; serialise overlapping messages.
52
+ busy = busy.then(async () => {
53
+ try {
54
+ await deviceNode.ready;
55
+ msg.payload = await deviceNode.driver.read();
56
+ send(msg);
57
+ done();
58
+ } catch (e) {
59
+ done(e);
60
+ }
61
+ });
62
+ });
63
+ }
64
+ RED.nodes.registerType('scd30', SCD30ReadNode);
65
+ };
@@ -0,0 +1,106 @@
1
+ <!-- Config node: one instance per physical device -->
2
+ <script type="text/javascript">
3
+ RED.nodes.registerType('scd40-device', {
4
+ category: 'config',
5
+ defaults: {
6
+ name: { value: '' },
7
+ bus: { value: '1', required: true, validate: RED.validators.number() },
8
+ mode: { value: 'periodic' },
9
+ offset: { value: '4', validate: RED.validators.number() },
10
+ altitude: { value: '0', validate: RED.validators.number() }
11
+ },
12
+ label: function() {
13
+ return this.name || ('SCD40 @ 0x62 (bus ' + this.bus + ')');
14
+ }
15
+ });
16
+ </script>
17
+
18
+ <script type="text/html" data-template-name="scd40-device">
19
+ <div class="form-row">
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="SCD40">
22
+ </div>
23
+ <div class="form-row">
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"> &nbsp;(Linux /dev/i2c-N, address 0x62)
26
+ </div>
27
+ <div class="form-row">
28
+ <label for="node-config-input-mode"><i class="fa fa-clock-o"></i> Mode</label>
29
+ <select id="node-config-input-mode">
30
+ <option value="periodic">Periodic (every 5 s)</option>
31
+ <option value="lowpower">Low power (about every 30 s)</option>
32
+ </select>
33
+ </div>
34
+ <div class="form-row">
35
+ <label for="node-config-input-offset"><i class="fa fa-thermometer-half"></i> Temp. offset</label>
36
+ <input type="number" id="node-config-input-offset" min="0" max="174" step="0.1" style="width:80px"> &nbsp;K (chip default 4)
37
+ </div>
38
+ <div class="form-row">
39
+ <label for="node-config-input-altitude"><i class="fa fa-area-chart"></i> Altitude</label>
40
+ <input type="number" id="node-config-input-altitude" min="0" max="65535" style="width:80px"> &nbsp;m above sea level
41
+ </div>
42
+ </script>
43
+
44
+ <!-- Read node -->
45
+ <script type="text/javascript">
46
+ RED.nodes.registerType('scd40', {
47
+ category: 'Peripheral',
48
+ color: '#C084FC',
49
+ defaults: {
50
+ name: { value: '' },
51
+ device: { value: '', type: 'scd40-device', required: true }
52
+ },
53
+ inputs: 1,
54
+ outputs: 1,
55
+ icon: 'bridge.svg',
56
+ label: function() { return this.name || 'SCD40'; },
57
+ paletteLabel: 'SCD40'
58
+ });
59
+ </script>
60
+
61
+ <script type="text/html" data-template-name="scd40">
62
+ <div class="form-row">
63
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
64
+ <input type="text" id="node-input-name" placeholder="SCD40">
65
+ </div>
66
+ <div class="form-row">
67
+ <label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
68
+ <input type="text" id="node-input-device">
69
+ </div>
70
+ </script>
71
+
72
+ <script type="text/html" data-help-name="scd40">
73
+ <p>Reads CO₂, temperature and humidity from a Sensirion SCD40 photoacoustic CO₂ sensor over I²C (address 0x62),
74
+ one sample per message.</p>
75
+ <h3>Inputs</h3>
76
+ <dl class="message-properties">
77
+ <dt>payload <span class="property-type">any</span></dt>
78
+ <dd>Any incoming message waits for the next sample (every 5 s, or about every 30 s in low-power mode) and
79
+ returns it.</dd>
80
+ </dl>
81
+ <h3>Outputs</h3>
82
+ <dl class="message-properties">
83
+ <dt>payload.co2_ppm <span class="property-type">number</span></dt>
84
+ <dd>CO₂ concentration in ppm (specified 400–2000, output 0–40 000).</dd>
85
+ <dt>payload.temperature_c <span class="property-type">number</span></dt>
86
+ <dd>Temperature in °C (temperature offset applied).</dd>
87
+ <dt>payload.humidity_rh <span class="property-type">number</span></dt>
88
+ <dd>Relative humidity in %RH.</dd>
89
+ </dl>
90
+ <h3>Configuration</h3>
91
+ <dl class="message-properties">
92
+ <dt>I²C bus <span class="property-type">number</span></dt>
93
+ <dd>Linux bus number N of <code>/dev/i2c-N</code>. The address is fixed at 0x62.</dd>
94
+ <dt>Mode <span class="property-type">string</span></dt>
95
+ <dd>Periodic measurement (a sample every 5 s) or low-power periodic measurement (about every 30 s).</dd>
96
+ <dt>Temp. offset <span class="property-type">number</span></dt>
97
+ <dd>Temperature offset in K for self-heating (chip default 4); written at deploy when it differs.</dd>
98
+ <dt>Altitude <span class="property-type">number</span></dt>
99
+ <dd>Altitude above sea level in m for the pressure compensation (default 0); written at deploy when it differs.</dd>
100
+ </dl>
101
+ <h3>Details</h3>
102
+ <p>Offset and altitude are written to the sensor's RAM only (not persisted to the EEPROM), so they are reapplied
103
+ at every deploy. Changing a setting stops and restarts the measurement (500 ms). A read polls the data-ready
104
+ status and waits at most 6 s (35 s in low-power mode). Automatic self-calibration stays as it is (chip default
105
+ on; it needs fresh air at least once a week).</p>
106
+ </script>
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+
3
+ module.exports = function(RED) {
4
+ const { I2CConnection } = require('periph/src/connection/i2c');
5
+ const { SCD40Full } = require('periph/src/chips/gas/scd40');
6
+
7
+ function SCD40DeviceNode(config) {
8
+ RED.nodes.createNode(this, config);
9
+ const node = this;
10
+ try {
11
+ const connection = new I2CConnection(parseInt(config.bus), 0x62);
12
+ node.connection = connection;
13
+ node.driver = new SCD40Full(connection);
14
+ node.ready = (async () => {
15
+ await node.driver.init();
16
+ // Offset and altitude live in RAM (no EEPROM write); each change costs one
17
+ // stop/restart (500 ms), so write them only when they differ.
18
+ const offset = parseFloat(config.offset);
19
+ if (!isNaN(offset) && Math.abs(offset - await node.driver.getTemperatureOffset()) > 0.01) {
20
+ await node.driver.setTemperatureOffset(offset);
21
+ }
22
+ const altitude = parseInt(config.altitude);
23
+ if (!isNaN(altitude) && altitude !== await node.driver.getAltitude()) {
24
+ await node.driver.setAltitude(altitude);
25
+ }
26
+ if (config.mode === 'lowpower') await node.driver.startLowPowerPeriodic();
27
+ })();
28
+ node.ready.catch((e) => {
29
+ node.error('SCD40 init failed: ' + e.message);
30
+ });
31
+ } catch (e) {
32
+ node.error('SCD40 init failed: ' + e.message);
33
+ }
34
+
35
+ node.on('close', function() {
36
+ if (node.connection) node.connection.close();
37
+ });
38
+ }
39
+ RED.nodes.registerType('scd40-device', SCD40DeviceNode);
40
+
41
+ function SCD40ReadNode(config) {
42
+ RED.nodes.createNode(this, config);
43
+ const node = this;
44
+ const deviceNode = RED.nodes.getNode(config.device) || {};
45
+ let busy = Promise.resolve();
46
+
47
+ node.on('input', function(msg, send, done) {
48
+ if (!deviceNode.driver) {
49
+ node.error('SCD40 not initialised', msg);
50
+ done();
51
+ return;
52
+ }
53
+ // One command/response exchange at a time; serialise overlapping messages.
54
+ busy = busy.then(async () => {
55
+ try {
56
+ await deviceNode.ready;
57
+ msg.payload = await deviceNode.driver.read();
58
+ send(msg);
59
+ done();
60
+ } catch (e) {
61
+ done(e);
62
+ }
63
+ });
64
+ });
65
+ }
66
+ RED.nodes.registerType('scd40', SCD40ReadNode);
67
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "node-red-contrib-periph-gas",
3
- "version": "1.6.0",
4
- "description": "Node-RED nodes for gas sensor chips: CCS811, ENS160, RRH46410",
3
+ "version": "1.6.1",
4
+ "description": "Node-RED nodes for gas sensor chips: CCS811, ENS160, RRH46410, RRH62000, SCD30, SCD40",
5
5
  "keywords": [
6
6
  "node-red",
7
7
  "gas",
@@ -12,14 +12,20 @@
12
12
  "node-red-contrib",
13
13
  "ccs811",
14
14
  "ens160",
15
- "rrh46410"
15
+ "rrh46410",
16
+ "rrh62000",
17
+ "scd30",
18
+ "scd40"
16
19
  ],
17
20
  "node-red": {
18
21
  "version": ">=3.0.0",
19
22
  "nodes": {
20
23
  "ccs811": "nodes/ccs811/ccs811.js",
21
24
  "ens160": "nodes/ens160/ens160.js",
22
- "rrh46410": "nodes/rrh46410/rrh46410.js"
25
+ "rrh46410": "nodes/rrh46410/rrh46410.js",
26
+ "rrh62000": "nodes/rrh62000/rrh62000.js",
27
+ "scd30": "nodes/scd30/scd30.js",
28
+ "scd40": "nodes/scd40/scd40.js"
23
29
  }
24
30
  },
25
31
  "dependencies": {