node-red-contrib-periph-environmental 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 +10 -3
- package/examples/aht10/demo.json +121 -0
- package/examples/aht20/demo.json +121 -0
- package/examples/am2315/demo.json +10 -4
- package/examples/am2320/demo.json +90 -0
- package/examples/bme280/demo.json +2 -2
- package/examples/bme680/demo.json +2 -2
- package/nodes/aht10/aht10.html +75 -0
- package/nodes/aht10/aht10.js +49 -0
- package/nodes/aht20/aht20.html +75 -0
- package/nodes/aht20/aht20.js +49 -0
- package/nodes/am2315/am2315.html +39 -14
- package/nodes/am2315/am2315.js +15 -8
- package/nodes/am2320/am2320.html +78 -0
- package/nodes/am2320/am2320.js +50 -0
- package/nodes/bme280/bme280.html +3 -3
- package/nodes/bme280/bme280.js +1 -1
- package/nodes/bme680/bme680.html +3 -3
- package/nodes/bme680/bme680.js +1 -1
- package/package.json +4 -2
- package/index.js +0 -11
package/README.md
CHANGED
|
@@ -16,13 +16,20 @@ npm install node-red-contrib-periph-environmental
|
|
|
16
16
|
|
|
17
17
|
| Node | Kind | Description |
|
|
18
18
|
|------|------|-------------|
|
|
19
|
+
| `aht10-device` | config | I²C bus and address for an AHT10 |
|
|
20
|
+
| `aht10` | input | Reads temperature and humidity from an AHT10 environmental sensor over I²C. |
|
|
21
|
+
| `aht20-device` | config | I²C bus and address for an AHT20 |
|
|
22
|
+
| `aht20` | input | Reads temperature and humidity from an AHT20 environmental sensor over I²C. |
|
|
19
23
|
| `aht21-device` | config | I²C bus and address for an AHT21 |
|
|
20
24
|
| `aht21` | input | Reads temperature and humidity from an AHT21 environmental sensor over I²C. |
|
|
21
|
-
| `
|
|
25
|
+
| `am2315-device` | config | I²C bus and address for an AM2315 |
|
|
26
|
+
| `am2315` | input | Reads temperature and relative humidity from an Aosong AM2315 over I²C (fixed address 0x5C). The sensor sleeps between transactions and returns the result of the previous measurement; the node keeps transactions at least 2 s apart, so a message arriving earlier is answered after the remaining delay. Every response is CRC-16 checked. |
|
|
27
|
+
| `am2320-device` | config | I²C bus and address for an AM2320 |
|
|
28
|
+
| `am2320` | input | Reads temperature and relative humidity from an Aosong AM2320 over I²C (fixed address 0x5C). The sensor sleeps between transactions and returns the result of the previous measurement; the node keeps transactions at least 2 s apart, so a message arriving earlier is answered after the remaining delay. Every response is CRC-16 checked. |
|
|
22
29
|
| `bme280-device` | config | Bus configuration for a BME280 |
|
|
23
|
-
| `
|
|
30
|
+
| `bme280` | input | Reads temperature, pressure, humidity, altitude, and dew point from a BME280 combined humidity + pressure + temperature sensor. |
|
|
24
31
|
| `bme680-device` | config | Bus configuration for a BME680 |
|
|
25
|
-
| `
|
|
32
|
+
| `bme680` | input | Reads temperature, pressure, humidity, gas resistance, altitude, and dew point from a BME680 4-in-1 environmental sensor. |
|
|
26
33
|
|
|
27
34
|
## Links
|
|
28
35
|
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "tab-aht10-demo",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "AHT10 Weather Station",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "Reads temperature and humidity from an AHT10 every 5 seconds and displays a formatted string in the debug panel. A second branch feeds two Gauge dashboard widgets for live visual monitoring of temperature and humidity."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "cfg-aht10",
|
|
11
|
+
"type": "aht10-device",
|
|
12
|
+
"name": "AHT10",
|
|
13
|
+
"bus": "1",
|
|
14
|
+
"address": "38"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": "inj-tick",
|
|
18
|
+
"type": "inject",
|
|
19
|
+
"name": "every 5 s",
|
|
20
|
+
"repeat": "5",
|
|
21
|
+
"crontab": "",
|
|
22
|
+
"once": true,
|
|
23
|
+
"onceDelay": 0.1,
|
|
24
|
+
"topic": "",
|
|
25
|
+
"payload": "",
|
|
26
|
+
"payloadType": "date",
|
|
27
|
+
"z": "tab-aht10-demo",
|
|
28
|
+
"x": 120,
|
|
29
|
+
"y": 160,
|
|
30
|
+
"wires": [["read-aht10"]]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": "read-aht10",
|
|
34
|
+
"type": "aht10",
|
|
35
|
+
"name": "AHT10",
|
|
36
|
+
"device": "cfg-aht10",
|
|
37
|
+
"z": "tab-aht10-demo",
|
|
38
|
+
"x": 300,
|
|
39
|
+
"y": 160,
|
|
40
|
+
"wires": [["fmt-readings", "gauge-temp", "gauge-hum"]]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"id": "fmt-readings",
|
|
44
|
+
"type": "function",
|
|
45
|
+
"name": "format",
|
|
46
|
+
"func": "const p = msg.payload;\nmsg.payload = p.temperature_c.toFixed(1) + ' °C / ' + p.humidity_pct.toFixed(1) + ' %RH';\nreturn msg;",
|
|
47
|
+
"outputs": 1,
|
|
48
|
+
"noerr": 0,
|
|
49
|
+
"initialize": "",
|
|
50
|
+
"finalize": "",
|
|
51
|
+
"libs": [],
|
|
52
|
+
"z": "tab-aht10-demo",
|
|
53
|
+
"x": 480,
|
|
54
|
+
"y": 160,
|
|
55
|
+
"wires": [["dbg-readings"]]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"id": "dbg-readings",
|
|
59
|
+
"type": "debug",
|
|
60
|
+
"name": "",
|
|
61
|
+
"active": true,
|
|
62
|
+
"tosidebar": true,
|
|
63
|
+
"console": false,
|
|
64
|
+
"tostatus": true,
|
|
65
|
+
"complete": "payload",
|
|
66
|
+
"targetType": "msg",
|
|
67
|
+
"statusVal": "payload",
|
|
68
|
+
"statusType": "auto",
|
|
69
|
+
"z": "tab-aht10-demo",
|
|
70
|
+
"x": 650,
|
|
71
|
+
"y": 160,
|
|
72
|
+
"wires": []
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"id": "gauge-temp",
|
|
76
|
+
"type": "ui_gauge",
|
|
77
|
+
"name": "Temperature",
|
|
78
|
+
"group": "grp-aht10",
|
|
79
|
+
"order": 1,
|
|
80
|
+
"width": 6,
|
|
81
|
+
"height": 4,
|
|
82
|
+
"gtype": "gage",
|
|
83
|
+
"title": "Temperature",
|
|
84
|
+
"label": "°C",
|
|
85
|
+
"format": "{{value | number:1}}",
|
|
86
|
+
"min": -10,
|
|
87
|
+
"max": 50,
|
|
88
|
+
"z": "tab-aht10-demo",
|
|
89
|
+
"x": 490,
|
|
90
|
+
"y": 220,
|
|
91
|
+
"wires": []
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"id": "gauge-hum",
|
|
95
|
+
"type": "ui_gauge",
|
|
96
|
+
"name": "Humidity",
|
|
97
|
+
"group": "grp-aht10",
|
|
98
|
+
"order": 2,
|
|
99
|
+
"width": 6,
|
|
100
|
+
"height": 4,
|
|
101
|
+
"gtype": "gage",
|
|
102
|
+
"title": "Humidity",
|
|
103
|
+
"label": "%RH",
|
|
104
|
+
"format": "{{value | number:1}}",
|
|
105
|
+
"min": 0,
|
|
106
|
+
"max": 100,
|
|
107
|
+
"z": "tab-aht10-demo",
|
|
108
|
+
"x": 480,
|
|
109
|
+
"y": 280,
|
|
110
|
+
"wires": []
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"id": "grp-aht10",
|
|
114
|
+
"type": "ui_group",
|
|
115
|
+
"name": "AHT10",
|
|
116
|
+
"tab": "tab-aht10-demo",
|
|
117
|
+
"order": 1,
|
|
118
|
+
"disp": true,
|
|
119
|
+
"width": 12
|
|
120
|
+
}
|
|
121
|
+
]
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "tab-aht20-demo",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "AHT20 Weather Station",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "Reads temperature and humidity from an AHT20 every 5 seconds and displays a formatted string in the debug panel. A second branch feeds two Gauge dashboard widgets for live visual monitoring of temperature and humidity."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "cfg-aht20",
|
|
11
|
+
"type": "aht20-device",
|
|
12
|
+
"name": "AHT20",
|
|
13
|
+
"bus": "1",
|
|
14
|
+
"address": "38"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": "inj-tick",
|
|
18
|
+
"type": "inject",
|
|
19
|
+
"name": "every 5 s",
|
|
20
|
+
"repeat": "5",
|
|
21
|
+
"crontab": "",
|
|
22
|
+
"once": true,
|
|
23
|
+
"onceDelay": 0.1,
|
|
24
|
+
"topic": "",
|
|
25
|
+
"payload": "",
|
|
26
|
+
"payloadType": "date",
|
|
27
|
+
"z": "tab-aht20-demo",
|
|
28
|
+
"x": 120,
|
|
29
|
+
"y": 160,
|
|
30
|
+
"wires": [["read-aht20"]]
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": "read-aht20",
|
|
34
|
+
"type": "aht20",
|
|
35
|
+
"name": "AHT20",
|
|
36
|
+
"device": "cfg-aht20",
|
|
37
|
+
"z": "tab-aht20-demo",
|
|
38
|
+
"x": 300,
|
|
39
|
+
"y": 160,
|
|
40
|
+
"wires": [["fmt-readings", "gauge-temp", "gauge-hum"]]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"id": "fmt-readings",
|
|
44
|
+
"type": "function",
|
|
45
|
+
"name": "format",
|
|
46
|
+
"func": "const p = msg.payload;\nmsg.payload = p.temperature_c.toFixed(1) + ' °C / ' + p.humidity_pct.toFixed(1) + ' %RH';\nreturn msg;",
|
|
47
|
+
"outputs": 1,
|
|
48
|
+
"noerr": 0,
|
|
49
|
+
"initialize": "",
|
|
50
|
+
"finalize": "",
|
|
51
|
+
"libs": [],
|
|
52
|
+
"z": "tab-aht20-demo",
|
|
53
|
+
"x": 480,
|
|
54
|
+
"y": 160,
|
|
55
|
+
"wires": [["dbg-readings"]]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"id": "dbg-readings",
|
|
59
|
+
"type": "debug",
|
|
60
|
+
"name": "",
|
|
61
|
+
"active": true,
|
|
62
|
+
"tosidebar": true,
|
|
63
|
+
"console": false,
|
|
64
|
+
"tostatus": true,
|
|
65
|
+
"complete": "payload",
|
|
66
|
+
"targetType": "msg",
|
|
67
|
+
"statusVal": "payload",
|
|
68
|
+
"statusType": "auto",
|
|
69
|
+
"z": "tab-aht20-demo",
|
|
70
|
+
"x": 650,
|
|
71
|
+
"y": 160,
|
|
72
|
+
"wires": []
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"id": "gauge-temp",
|
|
76
|
+
"type": "ui_gauge",
|
|
77
|
+
"name": "Temperature",
|
|
78
|
+
"group": "grp-aht20",
|
|
79
|
+
"order": 1,
|
|
80
|
+
"width": 6,
|
|
81
|
+
"height": 4,
|
|
82
|
+
"gtype": "gage",
|
|
83
|
+
"title": "Temperature",
|
|
84
|
+
"label": "°C",
|
|
85
|
+
"format": "{{value | number:1}}",
|
|
86
|
+
"min": -10,
|
|
87
|
+
"max": 50,
|
|
88
|
+
"z": "tab-aht20-demo",
|
|
89
|
+
"x": 490,
|
|
90
|
+
"y": 220,
|
|
91
|
+
"wires": []
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"id": "gauge-hum",
|
|
95
|
+
"type": "ui_gauge",
|
|
96
|
+
"name": "Humidity",
|
|
97
|
+
"group": "grp-aht20",
|
|
98
|
+
"order": 2,
|
|
99
|
+
"width": 6,
|
|
100
|
+
"height": 4,
|
|
101
|
+
"gtype": "gage",
|
|
102
|
+
"title": "Humidity",
|
|
103
|
+
"label": "%RH",
|
|
104
|
+
"format": "{{value | number:1}}",
|
|
105
|
+
"min": 0,
|
|
106
|
+
"max": 100,
|
|
107
|
+
"z": "tab-aht20-demo",
|
|
108
|
+
"x": 480,
|
|
109
|
+
"y": 280,
|
|
110
|
+
"wires": []
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"id": "grp-aht20",
|
|
114
|
+
"type": "ui_group",
|
|
115
|
+
"name": "AHT20",
|
|
116
|
+
"tab": "tab-aht20-demo",
|
|
117
|
+
"order": 1,
|
|
118
|
+
"disp": true,
|
|
119
|
+
"width": 12
|
|
120
|
+
}
|
|
121
|
+
]
|
|
@@ -30,20 +30,26 @@
|
|
|
30
30
|
]
|
|
31
31
|
]
|
|
32
32
|
},
|
|
33
|
+
{
|
|
34
|
+
"id": "am2315-device-1",
|
|
35
|
+
"type": "am2315-device",
|
|
36
|
+
"name": "AM2315",
|
|
37
|
+
"address": "0x5C",
|
|
38
|
+
"bus": "1"
|
|
39
|
+
},
|
|
33
40
|
{
|
|
34
41
|
"id": "am2315-node",
|
|
35
|
-
"type": "
|
|
42
|
+
"type": "am2315",
|
|
36
43
|
"z": "am2315-tab",
|
|
37
44
|
"name": "AM2315",
|
|
38
|
-
"bus": "1",
|
|
39
|
-
"address": "0x5C",
|
|
40
45
|
"x": 380,
|
|
41
46
|
"y": 160,
|
|
42
47
|
"wires": [
|
|
43
48
|
[
|
|
44
49
|
"am2315-format"
|
|
45
50
|
]
|
|
46
|
-
]
|
|
51
|
+
],
|
|
52
|
+
"device": "am2315-device-1"
|
|
47
53
|
},
|
|
48
54
|
{
|
|
49
55
|
"id": "am2315-format",
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "am2320-tab",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "AM2320 humidity logger",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "Reads temperature and relative humidity from an AM2320 every 5 s and formats them. The sensor returns the previous measurement on every read and needs at least 2 s between transactions; each response is CRC-16 checked."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "am2320-inject",
|
|
11
|
+
"type": "inject",
|
|
12
|
+
"z": "am2320-tab",
|
|
13
|
+
"name": "5 s timer",
|
|
14
|
+
"props": [
|
|
15
|
+
{
|
|
16
|
+
"p": "payload"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"repeat": "5",
|
|
20
|
+
"crontab": "",
|
|
21
|
+
"once": false,
|
|
22
|
+
"onceDelay": 0.1,
|
|
23
|
+
"topic": "",
|
|
24
|
+
"payloadType": "date",
|
|
25
|
+
"x": 160,
|
|
26
|
+
"y": 160,
|
|
27
|
+
"wires": [
|
|
28
|
+
[
|
|
29
|
+
"am2320-node"
|
|
30
|
+
]
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "am2320-device-1",
|
|
35
|
+
"type": "am2320-device",
|
|
36
|
+
"name": "AM2320",
|
|
37
|
+
"address": "0x5C",
|
|
38
|
+
"bus": "1"
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
"id": "am2320-node",
|
|
42
|
+
"type": "am2320",
|
|
43
|
+
"z": "am2320-tab",
|
|
44
|
+
"name": "AM2320",
|
|
45
|
+
"x": 380,
|
|
46
|
+
"y": 160,
|
|
47
|
+
"wires": [
|
|
48
|
+
[
|
|
49
|
+
"am2320-format"
|
|
50
|
+
]
|
|
51
|
+
],
|
|
52
|
+
"device": "am2320-device-1"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"id": "am2320-format",
|
|
56
|
+
"type": "function",
|
|
57
|
+
"z": "am2320-tab",
|
|
58
|
+
"name": "Format",
|
|
59
|
+
"func": "msg.payload = msg.payload.temperature_c.toFixed(1) + ' °C / ' + msg.payload.humidity_pct.toFixed(1) + ' %RH';\nreturn msg;",
|
|
60
|
+
"outputs": 1,
|
|
61
|
+
"noerr": 0,
|
|
62
|
+
"initialize": "",
|
|
63
|
+
"finalize": "",
|
|
64
|
+
"libs": [],
|
|
65
|
+
"x": 600,
|
|
66
|
+
"y": 160,
|
|
67
|
+
"wires": [
|
|
68
|
+
[
|
|
69
|
+
"am2320-debug"
|
|
70
|
+
]
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"id": "am2320-debug",
|
|
75
|
+
"type": "debug",
|
|
76
|
+
"z": "am2320-tab",
|
|
77
|
+
"name": "Reading",
|
|
78
|
+
"active": true,
|
|
79
|
+
"tosidebar": true,
|
|
80
|
+
"console": false,
|
|
81
|
+
"tostatus": false,
|
|
82
|
+
"complete": "payload",
|
|
83
|
+
"targetType": "msg",
|
|
84
|
+
"statusVal": "",
|
|
85
|
+
"statusType": "auto",
|
|
86
|
+
"x": 800,
|
|
87
|
+
"y": 160,
|
|
88
|
+
"wires": []
|
|
89
|
+
}
|
|
90
|
+
]
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
"id": "bme280-read-1",
|
|
17
|
-
"type": "
|
|
17
|
+
"type": "bme280",
|
|
18
18
|
"name": "BME280 Indoor",
|
|
19
19
|
"device": "bme280-device-1",
|
|
20
20
|
"seaLevelHpa": "1013.25",
|
|
@@ -156,6 +156,6 @@
|
|
|
156
156
|
"name": "BME280 Demo",
|
|
157
157
|
"icon": "dashboard",
|
|
158
158
|
"order": 1,
|
|
159
|
-
"info": "This flow demonstrates the BME280 combined humidity + pressure + temperature sensor.\n\nAn inject node fires every 10 seconds into the
|
|
159
|
+
"info": "This flow demonstrates the BME280 combined humidity + pressure + temperature sensor.\n\nAn inject node fires every 10 seconds into the bme280 node. The output goes to a debug node and five ui_chart nodes showing temperature, pressure, humidity, altitude, and dew point over time.\n\nA condensation-alert function node watches the dew-point trace and emits a 'Condensation likely' alert when temperature minus dew point falls below 2 °C — useful for HVAC, greenhouse, and crawl-space monitoring where surface condensation can damage equipment or promote mould.\n\nThe BME280 combines three sensors (BMP280 pressure/temperature plus a humidity front-end) in one package, making it ideal for indoor air quality, weather stations, and HVAC applications where a separate humidity sensor would otherwise be needed."
|
|
160
160
|
}
|
|
161
161
|
]
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
"id": "bme680-read-1",
|
|
17
|
-
"type": "
|
|
17
|
+
"type": "bme680",
|
|
18
18
|
"name": "BME680 Air Quality",
|
|
19
19
|
"device": "bme680-device-1",
|
|
20
20
|
"seaLevelHpa": "1013.25",
|
|
@@ -170,6 +170,6 @@
|
|
|
170
170
|
"name": "BME680 Demo",
|
|
171
171
|
"icon": "dashboard",
|
|
172
172
|
"order": 1,
|
|
173
|
-
"info": "This flow demonstrates the BME680 4-in-1 environmental sensor (temperature, pressure, humidity, gas resistance).\n\nAn inject node fires every 10 seconds into the
|
|
173
|
+
"info": "This flow demonstrates the BME680 4-in-1 environmental sensor (temperature, pressure, humidity, gas resistance).\n\nAn inject node fires every 10 seconds into the bme680 node. The output goes to a debug node and six ui_chart nodes showing temperature, pressure, humidity, gas resistance, altitude, and dew point.\n\nA VOC alert function node watches the gas-resistance trace — a sustained drop below 80% of the running 24-hour median triggers a \"VOC concentration rising\" alert. This demonstrates that even the raw uncalibrated gas reading is useful as a relative VOC indicator without the closed-source BSEC library.\n\nGas resistance drops when VOCs (isopropyl alcohol, marker pen fumes, cooking) are present near the sensor and recovers as the air clears."
|
|
174
174
|
}
|
|
175
175
|
]
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<!-- Config node: one instance per physical device -->
|
|
2
|
+
<script type="text/javascript">
|
|
3
|
+
RED.nodes.registerType('aht10-device', {
|
|
4
|
+
category: 'config',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
|
+
address: { value: '38', required: true }
|
|
9
|
+
},
|
|
10
|
+
label: function() {
|
|
11
|
+
return this.name || ('AHT10 @ 0x' + this.address + ' (bus ' + this.bus + ')');
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<script type="text/html" data-template-name="aht10-device">
|
|
17
|
+
<div class="form-row">
|
|
18
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
19
|
+
<input type="text" id="node-config-input-name" placeholder="AHT10">
|
|
20
|
+
</div>
|
|
21
|
+
<div class="form-row">
|
|
22
|
+
<label for="node-config-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
23
|
+
<input type="number" id="node-config-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N)
|
|
24
|
+
</div>
|
|
25
|
+
<div class="form-row">
|
|
26
|
+
<label for="node-config-input-address">Address (hex)</label>
|
|
27
|
+
<input type="text" id="node-config-input-address" placeholder="38" style="width:80px"> default: 38 (0x38)
|
|
28
|
+
</div>
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<!-- Read node: trigger → measurements -->
|
|
32
|
+
<script type="text/javascript">
|
|
33
|
+
RED.nodes.registerType('aht10', {
|
|
34
|
+
category: 'Peripheral',
|
|
35
|
+
color: '#C084FC',
|
|
36
|
+
defaults: {
|
|
37
|
+
name: { value: '' },
|
|
38
|
+
device: { value: '', type: 'aht10-device', required: true }
|
|
39
|
+
},
|
|
40
|
+
inputs: 1,
|
|
41
|
+
outputs: 1,
|
|
42
|
+
icon: 'font-awesome/fa-thermometer-half',
|
|
43
|
+
label: function() { return this.name || 'AHT10'; },
|
|
44
|
+
paletteLabel: 'AHT10'
|
|
45
|
+
});
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<script type="text/html" data-template-name="aht10">
|
|
49
|
+
<div class="form-row">
|
|
50
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
51
|
+
<input type="text" id="node-input-device">
|
|
52
|
+
</div>
|
|
53
|
+
<div class="form-row">
|
|
54
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
55
|
+
<input type="text" id="node-input-name" placeholder="AHT10">
|
|
56
|
+
</div>
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<script type="text/html" data-help-name="aht10">
|
|
60
|
+
<p>Reads temperature and humidity from an AHT10 environmental sensor over I²C.</p>
|
|
61
|
+
<p>Any input message triggers a measurement. The device is configured via an <b>aht10-device</b> config node.</p>
|
|
62
|
+
|
|
63
|
+
<h3>Output</h3>
|
|
64
|
+
<dl class="message-properties">
|
|
65
|
+
<dt>payload.temperature_c <span class="property-type">number</span></dt>
|
|
66
|
+
<dd>Temperature in degrees Celsius.</dd>
|
|
67
|
+
<dt>payload.humidity_pct <span class="property-type">number</span></dt>
|
|
68
|
+
<dd>Relative humidity in percent.</dd>
|
|
69
|
+
</dl>
|
|
70
|
+
|
|
71
|
+
<h3>Details</h3>
|
|
72
|
+
<p>Configure the I²C bus number and the chip's fixed address (default <code>0x38</code>)
|
|
73
|
+
in the device config node. Only one AHT10
|
|
74
|
+
can be on a single I²C bus.</p>
|
|
75
|
+
</script>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function(RED) {
|
|
4
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
|
+
const { AHT10Full } = require('periph/src/chips/environmental/aht10');
|
|
6
|
+
|
|
7
|
+
function AHT10DeviceNode(config) {
|
|
8
|
+
RED.nodes.createNode(this, config);
|
|
9
|
+
const node = this;
|
|
10
|
+
try {
|
|
11
|
+
const connection = new I2CConnection(parseInt(config.bus), parseInt(config.address, 16));
|
|
12
|
+
node.driver = new AHT10Full(connection);
|
|
13
|
+
node.connection = connection;
|
|
14
|
+
} catch (e) {
|
|
15
|
+
node.error('AHT10 init failed: ' + e.message);
|
|
16
|
+
}
|
|
17
|
+
node.on('close', function() {
|
|
18
|
+
if (node.connection) node.connection.close();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
RED.nodes.registerType('aht10-device', AHT10DeviceNode);
|
|
22
|
+
|
|
23
|
+
function AHT10ReadNode(config) {
|
|
24
|
+
RED.nodes.createNode(this, config);
|
|
25
|
+
const node = this;
|
|
26
|
+
node.device = RED.nodes.getNode(config.device);
|
|
27
|
+
|
|
28
|
+
node.on('input', async function(msg, send, done) {
|
|
29
|
+
if (!node.device || !node.device.driver) {
|
|
30
|
+
node.error('No AHT10 device configured', msg);
|
|
31
|
+
done();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const d = node.device.driver;
|
|
36
|
+
const r = await d.read();
|
|
37
|
+
msg.payload = {
|
|
38
|
+
temperature_c: r.temperature_c,
|
|
39
|
+
humidity_pct: r.humidity_pct
|
|
40
|
+
};
|
|
41
|
+
send(msg);
|
|
42
|
+
done();
|
|
43
|
+
} catch (e) {
|
|
44
|
+
done(e);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
RED.nodes.registerType('aht10', AHT10ReadNode);
|
|
49
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<!-- Config node: one instance per physical device -->
|
|
2
|
+
<script type="text/javascript">
|
|
3
|
+
RED.nodes.registerType('aht20-device', {
|
|
4
|
+
category: 'config',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
|
+
address: { value: '38', required: true }
|
|
9
|
+
},
|
|
10
|
+
label: function() {
|
|
11
|
+
return this.name || ('AHT20 @ 0x' + this.address + ' (bus ' + this.bus + ')');
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<script type="text/html" data-template-name="aht20-device">
|
|
17
|
+
<div class="form-row">
|
|
18
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
19
|
+
<input type="text" id="node-config-input-name" placeholder="AHT20">
|
|
20
|
+
</div>
|
|
21
|
+
<div class="form-row">
|
|
22
|
+
<label for="node-config-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
23
|
+
<input type="number" id="node-config-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N)
|
|
24
|
+
</div>
|
|
25
|
+
<div class="form-row">
|
|
26
|
+
<label for="node-config-input-address">Address (hex)</label>
|
|
27
|
+
<input type="text" id="node-config-input-address" placeholder="38" style="width:80px"> default: 38 (0x38)
|
|
28
|
+
</div>
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<!-- Read node: trigger → measurements -->
|
|
32
|
+
<script type="text/javascript">
|
|
33
|
+
RED.nodes.registerType('aht20', {
|
|
34
|
+
category: 'Peripheral',
|
|
35
|
+
color: '#C084FC',
|
|
36
|
+
defaults: {
|
|
37
|
+
name: { value: '' },
|
|
38
|
+
device: { value: '', type: 'aht20-device', required: true }
|
|
39
|
+
},
|
|
40
|
+
inputs: 1,
|
|
41
|
+
outputs: 1,
|
|
42
|
+
icon: 'font-awesome/fa-thermometer-half',
|
|
43
|
+
label: function() { return this.name || 'AHT20'; },
|
|
44
|
+
paletteLabel: 'AHT20'
|
|
45
|
+
});
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<script type="text/html" data-template-name="aht20">
|
|
49
|
+
<div class="form-row">
|
|
50
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
51
|
+
<input type="text" id="node-input-device">
|
|
52
|
+
</div>
|
|
53
|
+
<div class="form-row">
|
|
54
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
55
|
+
<input type="text" id="node-input-name" placeholder="AHT20">
|
|
56
|
+
</div>
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<script type="text/html" data-help-name="aht20">
|
|
60
|
+
<p>Reads temperature and humidity from an AHT20 environmental sensor over I²C.</p>
|
|
61
|
+
<p>Any input message triggers a measurement. The device is configured via an <b>aht20-device</b> config node.</p>
|
|
62
|
+
|
|
63
|
+
<h3>Output</h3>
|
|
64
|
+
<dl class="message-properties">
|
|
65
|
+
<dt>payload.temperature_c <span class="property-type">number</span></dt>
|
|
66
|
+
<dd>Temperature in degrees Celsius.</dd>
|
|
67
|
+
<dt>payload.humidity_pct <span class="property-type">number</span></dt>
|
|
68
|
+
<dd>Relative humidity in percent.</dd>
|
|
69
|
+
</dl>
|
|
70
|
+
|
|
71
|
+
<h3>Details</h3>
|
|
72
|
+
<p>Configure the I²C bus number and the chip's fixed address (default <code>0x38</code>)
|
|
73
|
+
in the device config node. Only one AHT20
|
|
74
|
+
can be on a single I²C bus.</p>
|
|
75
|
+
</script>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function(RED) {
|
|
4
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
|
+
const { AHT20Full } = require('periph/src/chips/environmental/aht20');
|
|
6
|
+
|
|
7
|
+
function AHT20DeviceNode(config) {
|
|
8
|
+
RED.nodes.createNode(this, config);
|
|
9
|
+
const node = this;
|
|
10
|
+
try {
|
|
11
|
+
const connection = new I2CConnection(parseInt(config.bus), parseInt(config.address, 16));
|
|
12
|
+
node.driver = new AHT20Full(connection);
|
|
13
|
+
node.connection = connection;
|
|
14
|
+
} catch (e) {
|
|
15
|
+
node.error('AHT20 init failed: ' + e.message);
|
|
16
|
+
}
|
|
17
|
+
node.on('close', function() {
|
|
18
|
+
if (node.connection) node.connection.close();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
RED.nodes.registerType('aht20-device', AHT20DeviceNode);
|
|
22
|
+
|
|
23
|
+
function AHT20ReadNode(config) {
|
|
24
|
+
RED.nodes.createNode(this, config);
|
|
25
|
+
const node = this;
|
|
26
|
+
node.device = RED.nodes.getNode(config.device);
|
|
27
|
+
|
|
28
|
+
node.on('input', async function(msg, send, done) {
|
|
29
|
+
if (!node.device || !node.device.driver) {
|
|
30
|
+
node.error('No AHT20 device configured', msg);
|
|
31
|
+
done();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const d = node.device.driver;
|
|
36
|
+
const r = await d.read();
|
|
37
|
+
msg.payload = {
|
|
38
|
+
temperature_c: r.temperature_c,
|
|
39
|
+
humidity_pct: r.humidity_pct
|
|
40
|
+
};
|
|
41
|
+
send(msg);
|
|
42
|
+
done();
|
|
43
|
+
} catch (e) {
|
|
44
|
+
done(e);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
RED.nodes.registerType('aht20', AHT20ReadNode);
|
|
49
|
+
};
|
package/nodes/am2315/am2315.html
CHANGED
|
@@ -1,37 +1,62 @@
|
|
|
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('am2315-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: '0x5C' }
|
|
9
9
|
},
|
|
10
|
-
inputs: 1,
|
|
11
|
-
outputs: 1,
|
|
12
|
-
icon: 'bridge.svg',
|
|
13
10
|
label: function() {
|
|
14
11
|
return this.name || ('AM2315 @ ' + this.address + ' (bus ' + this.bus + ')');
|
|
15
12
|
}
|
|
16
13
|
});
|
|
17
14
|
</script>
|
|
18
15
|
|
|
19
|
-
<script type="text/html" data-template-name="
|
|
16
|
+
<script type="text/html" data-template-name="am2315-device">
|
|
20
17
|
<div class="form-row">
|
|
21
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
22
|
-
<input type="text" id="node-input-name" placeholder="AM2315">
|
|
18
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
19
|
+
<input type="text" id="node-config-input-name" placeholder="AM2315">
|
|
23
20
|
</div>
|
|
24
21
|
<div class="form-row">
|
|
25
|
-
<label for="node-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
26
|
-
<input type="number" id="node-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N, standard mode)
|
|
22
|
+
<label for="node-config-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
23
|
+
<input type="number" id="node-config-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N, standard mode)
|
|
24
|
+
</div>
|
|
25
|
+
<div class="form-row">
|
|
26
|
+
<label for="node-config-input-address"><i class="fa fa-microchip"></i> I²C address</label>
|
|
27
|
+
<input type="text" id="node-config-input-address" style="width:80px" placeholder="0x5C"> (fixed, 0x5C)
|
|
28
|
+
</div>
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<!-- Read node -->
|
|
32
|
+
<script type="text/javascript">
|
|
33
|
+
RED.nodes.registerType('am2315', {
|
|
34
|
+
category: 'Peripheral',
|
|
35
|
+
color: '#C084FC',
|
|
36
|
+
defaults: {
|
|
37
|
+
name: { value: '' },
|
|
38
|
+
device: { value: '', type: 'am2315-device', required: true }
|
|
39
|
+
},
|
|
40
|
+
inputs: 1,
|
|
41
|
+
outputs: 1,
|
|
42
|
+
icon: 'bridge.svg',
|
|
43
|
+
label: function() { return this.name || 'AM2315'; },
|
|
44
|
+
paletteLabel: 'AM2315'
|
|
45
|
+
});
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<script type="text/html" data-template-name="am2315">
|
|
49
|
+
<div class="form-row">
|
|
50
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
51
|
+
<input type="text" id="node-input-name" placeholder="AM2315">
|
|
27
52
|
</div>
|
|
28
53
|
<div class="form-row">
|
|
29
|
-
<label for="node-input-
|
|
30
|
-
<input type="text" id="node-input-
|
|
54
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
55
|
+
<input type="text" id="node-input-device">
|
|
31
56
|
</div>
|
|
32
57
|
</script>
|
|
33
58
|
|
|
34
|
-
<script type="text/html" data-help-name="
|
|
59
|
+
<script type="text/html" data-help-name="am2315">
|
|
35
60
|
<p>Reads temperature and relative humidity from an Aosong AM2315 over I²C (fixed address 0x5C). The sensor
|
|
36
61
|
sleeps between transactions and returns the result of the <em>previous</em> measurement; the node keeps
|
|
37
62
|
transactions at least 2 s apart, so a message arriving earlier is answered after the remaining delay.
|
package/nodes/am2315/am2315.js
CHANGED
|
@@ -4,7 +4,7 @@ module.exports = function(RED) {
|
|
|
4
4
|
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
5
|
const { AM2315Full } = require('periph/src/chips/environmental/am2315');
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function AM2315DeviceNode(config) {
|
|
8
8
|
RED.nodes.createNode(this, config);
|
|
9
9
|
const node = this;
|
|
10
10
|
try {
|
|
@@ -16,17 +16,28 @@ module.exports = function(RED) {
|
|
|
16
16
|
node.error('AM2315 init failed: ' + e.message);
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
node.on('close', function() {
|
|
20
|
+
if (node.connection) node.connection.close();
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
RED.nodes.registerType('am2315-device', AM2315DeviceNode);
|
|
24
|
+
|
|
25
|
+
function AM2315ReadNode(config) {
|
|
26
|
+
RED.nodes.createNode(this, config);
|
|
27
|
+
const node = this;
|
|
28
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
29
|
+
|
|
19
30
|
// Messages are handled one at a time; the driver itself waits the >= 2 s between transactions.
|
|
20
31
|
let queue = Promise.resolve();
|
|
21
32
|
node.on('input', function(msg, send, done) {
|
|
22
|
-
if (!
|
|
33
|
+
if (!deviceNode.driver) {
|
|
23
34
|
node.error('AM2315 not initialised', msg);
|
|
24
35
|
done();
|
|
25
36
|
return;
|
|
26
37
|
}
|
|
27
38
|
queue = queue.then(async () => {
|
|
28
39
|
try {
|
|
29
|
-
msg.payload = await
|
|
40
|
+
msg.payload = await deviceNode.driver.read();
|
|
30
41
|
send(msg);
|
|
31
42
|
done();
|
|
32
43
|
} catch (e) {
|
|
@@ -34,10 +45,6 @@ module.exports = function(RED) {
|
|
|
34
45
|
}
|
|
35
46
|
});
|
|
36
47
|
});
|
|
37
|
-
|
|
38
|
-
node.on('close', function() {
|
|
39
|
-
if (node.connection) node.connection.close();
|
|
40
|
-
});
|
|
41
48
|
}
|
|
42
|
-
RED.nodes.registerType('
|
|
49
|
+
RED.nodes.registerType('am2315', AM2315ReadNode);
|
|
43
50
|
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<!-- Config node: one instance per physical device -->
|
|
2
|
+
<script type="text/javascript">
|
|
3
|
+
RED.nodes.registerType('am2320-device', {
|
|
4
|
+
category: 'config',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
|
+
address: { value: '0x5C' }
|
|
9
|
+
},
|
|
10
|
+
label: function() {
|
|
11
|
+
return this.name || ('AM2320 @ ' + this.address + ' (bus ' + this.bus + ')');
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<script type="text/html" data-template-name="am2320-device">
|
|
17
|
+
<div class="form-row">
|
|
18
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
19
|
+
<input type="text" id="node-config-input-name" placeholder="AM2320">
|
|
20
|
+
</div>
|
|
21
|
+
<div class="form-row">
|
|
22
|
+
<label for="node-config-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
23
|
+
<input type="number" id="node-config-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N, standard mode)
|
|
24
|
+
</div>
|
|
25
|
+
<div class="form-row">
|
|
26
|
+
<label for="node-config-input-address"><i class="fa fa-microchip"></i> I²C address</label>
|
|
27
|
+
<input type="text" id="node-config-input-address" style="width:80px" placeholder="0x5C"> (fixed, 0x5C)
|
|
28
|
+
</div>
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<!-- Read node -->
|
|
32
|
+
<script type="text/javascript">
|
|
33
|
+
RED.nodes.registerType('am2320', {
|
|
34
|
+
category: 'Peripheral',
|
|
35
|
+
color: '#C084FC',
|
|
36
|
+
defaults: {
|
|
37
|
+
name: { value: '' },
|
|
38
|
+
device: { value: '', type: 'am2320-device', required: true }
|
|
39
|
+
},
|
|
40
|
+
inputs: 1,
|
|
41
|
+
outputs: 1,
|
|
42
|
+
icon: 'bridge.svg',
|
|
43
|
+
label: function() { return this.name || 'AM2320'; },
|
|
44
|
+
paletteLabel: 'AM2320'
|
|
45
|
+
});
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<script type="text/html" data-template-name="am2320">
|
|
49
|
+
<div class="form-row">
|
|
50
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
51
|
+
<input type="text" id="node-input-name" placeholder="AM2320">
|
|
52
|
+
</div>
|
|
53
|
+
<div class="form-row">
|
|
54
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
55
|
+
<input type="text" id="node-input-device">
|
|
56
|
+
</div>
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<script type="text/html" data-help-name="am2320">
|
|
60
|
+
<p>Reads temperature and relative humidity from an Aosong AM2320 over I²C (fixed address 0x5C). The sensor
|
|
61
|
+
sleeps between transactions and returns the result of the <em>previous</em> measurement; the node keeps
|
|
62
|
+
transactions at least 2 s apart, so a message arriving earlier is answered after the remaining delay.
|
|
63
|
+
Every response is CRC-16 checked.</p>
|
|
64
|
+
<h3>Inputs</h3>
|
|
65
|
+
<dl class="message-properties">
|
|
66
|
+
<dt>payload <span class="property-type">any</span></dt>
|
|
67
|
+
<dd>Any incoming message triggers one reading.</dd>
|
|
68
|
+
</dl>
|
|
69
|
+
<h3>Outputs</h3>
|
|
70
|
+
<dl class="message-properties">
|
|
71
|
+
<dt>payload.temperature_c <span class="property-type">number</span></dt>
|
|
72
|
+
<dd>Temperature in °C (−40 to 125).</dd>
|
|
73
|
+
<dt>payload.humidity_pct <span class="property-type">number</span></dt>
|
|
74
|
+
<dd>Relative humidity in %RH (0 to 99.9).</dd>
|
|
75
|
+
</dl>
|
|
76
|
+
<h3>Configuration</h3>
|
|
77
|
+
<p>I²C bus number and I²C address (0x5C). The bus must run at 100 kHz or less.</p>
|
|
78
|
+
</script>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function(RED) {
|
|
4
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
|
+
const { AM2320Full } = require('periph/src/chips/environmental/am2320');
|
|
6
|
+
|
|
7
|
+
function AM2320DeviceNode(config) {
|
|
8
|
+
RED.nodes.createNode(this, config);
|
|
9
|
+
const node = this;
|
|
10
|
+
try {
|
|
11
|
+
const address = parseInt(config.address, 16) || 0x5C;
|
|
12
|
+
const connection = new I2CConnection(parseInt(config.bus), address);
|
|
13
|
+
node.connection = connection;
|
|
14
|
+
node.driver = new AM2320Full(connection);
|
|
15
|
+
} catch (e) {
|
|
16
|
+
node.error('AM2320 init failed: ' + e.message);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
node.on('close', function() {
|
|
20
|
+
if (node.connection) node.connection.close();
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
RED.nodes.registerType('am2320-device', AM2320DeviceNode);
|
|
24
|
+
|
|
25
|
+
function AM2320ReadNode(config) {
|
|
26
|
+
RED.nodes.createNode(this, config);
|
|
27
|
+
const node = this;
|
|
28
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
29
|
+
|
|
30
|
+
// Messages are handled one at a time; the driver itself waits the >= 2 s between transactions.
|
|
31
|
+
let queue = Promise.resolve();
|
|
32
|
+
node.on('input', function(msg, send, done) {
|
|
33
|
+
if (!deviceNode.driver) {
|
|
34
|
+
node.error('AM2320 not initialised', msg);
|
|
35
|
+
done();
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
queue = queue.then(async () => {
|
|
39
|
+
try {
|
|
40
|
+
msg.payload = await deviceNode.driver.read();
|
|
41
|
+
send(msg);
|
|
42
|
+
done();
|
|
43
|
+
} catch (e) {
|
|
44
|
+
done(e);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
RED.nodes.registerType('am2320', AM2320ReadNode);
|
|
50
|
+
};
|
package/nodes/bme280/bme280.html
CHANGED
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
|
|
104
104
|
<!-- Read node: trigger → measurements -->
|
|
105
105
|
<script type="text/javascript">
|
|
106
|
-
RED.nodes.registerType('
|
|
106
|
+
RED.nodes.registerType('bme280', {
|
|
107
107
|
category: 'Peripheral',
|
|
108
108
|
color: '#C084FC',
|
|
109
109
|
defaults: {
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
});
|
|
120
120
|
</script>
|
|
121
121
|
|
|
122
|
-
<script type="text/html" data-template-name="
|
|
122
|
+
<script type="text/html" data-template-name="bme280">
|
|
123
123
|
<div class="form-row">
|
|
124
124
|
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
125
125
|
<input type="text" id="node-input-device">
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
</div>
|
|
135
135
|
</script>
|
|
136
136
|
|
|
137
|
-
<script type="text/html" data-help-name="
|
|
137
|
+
<script type="text/html" data-help-name="bme280">
|
|
138
138
|
<p>Reads temperature, pressure, humidity, altitude, and dew point
|
|
139
139
|
from a BME280 combined humidity + pressure + temperature sensor.</p>
|
|
140
140
|
<p>Any input message triggers a measurement. The device is configured via a <b>bme280-device</b> config node.</p>
|
package/nodes/bme280/bme280.js
CHANGED
package/nodes/bme680/bme680.html
CHANGED
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
|
|
94
94
|
<!-- Read node: trigger → measurements -->
|
|
95
95
|
<script type="text/javascript">
|
|
96
|
-
RED.nodes.registerType('
|
|
96
|
+
RED.nodes.registerType('bme680', {
|
|
97
97
|
category: 'Peripheral',
|
|
98
98
|
color: '#C084FC',
|
|
99
99
|
defaults: {
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
});
|
|
110
110
|
</script>
|
|
111
111
|
|
|
112
|
-
<script type="text/html" data-template-name="
|
|
112
|
+
<script type="text/html" data-template-name="bme680">
|
|
113
113
|
<div class="form-row">
|
|
114
114
|
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
115
115
|
<input type="text" id="node-input-device">
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
</div>
|
|
125
125
|
</script>
|
|
126
126
|
|
|
127
|
-
<script type="text/html" data-help-name="
|
|
127
|
+
<script type="text/html" data-help-name="bme680">
|
|
128
128
|
<p>Reads temperature, pressure, humidity, gas resistance, altitude, and dew point
|
|
129
129
|
from a BME680 4-in-1 environmental sensor.</p>
|
|
130
130
|
<p>Any input message triggers a measurement. The device is configured via a <b>bme680-device</b> config node.</p>
|
package/nodes/bme680/bme680.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-periph-environmental",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "Node-RED nodes for environmental sensor chips",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node-red",
|
|
@@ -10,11 +10,13 @@
|
|
|
10
10
|
"sensor",
|
|
11
11
|
"peripheral"
|
|
12
12
|
],
|
|
13
|
-
"main": "index.js",
|
|
14
13
|
"node-red": {
|
|
15
14
|
"nodes": {
|
|
15
|
+
"aht10": "nodes/aht10/aht10.js",
|
|
16
|
+
"aht20": "nodes/aht20/aht20.js",
|
|
16
17
|
"aht21": "nodes/aht21/aht21.js",
|
|
17
18
|
"am2315": "nodes/am2315/am2315.js",
|
|
19
|
+
"am2320": "nodes/am2320/am2320.js",
|
|
18
20
|
"bme280": "nodes/bme280/bme280.js",
|
|
19
21
|
"bme680": "nodes/bme680/bme680.js"
|
|
20
22
|
}
|
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
|
-
};
|