node-red-contrib-periph-humidity 1.5.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -7
- package/examples/dht11/demo.json +68 -6
- package/examples/hdc1008/demo.json +10 -4
- package/examples/hdc1080/demo.json +10 -4
- package/examples/hs30xx/demo.json +10 -4
- package/examples/hs40xx/demo.json +10 -4
- package/examples/htu21df/demo.json +11 -5
- package/examples/sht31/demo.json +11 -5
- package/examples/si7021/demo.json +11 -5
- package/nodes/hdc1008/hdc1008.html +41 -16
- package/nodes/hdc1008/hdc1008.js +16 -9
- package/nodes/hdc1080/hdc1080.html +41 -16
- package/nodes/hdc1080/hdc1080.js +16 -9
- package/nodes/hs30xx/hs30xx.html +40 -15
- package/nodes/hs30xx/hs30xx.js +15 -8
- package/nodes/hs40xx/hs40xx.html +40 -15
- package/nodes/hs40xx/hs40xx.js +16 -9
- package/nodes/htu21df/htu21df.html +44 -19
- package/nodes/htu21df/htu21df.js +16 -9
- package/nodes/sht31/sht31.html +41 -16
- package/nodes/sht31/sht31.js +16 -9
- package/nodes/si7021/si7021.html +44 -19
- package/nodes/si7021/si7021.js +16 -9
- package/package.json +1 -1
- package/index.js +0 -11
package/README.md
CHANGED
|
@@ -18,13 +18,20 @@ npm install node-red-contrib-periph-humidity
|
|
|
18
18
|
|------|------|-------------|
|
|
19
19
|
| `dht11-device` | config | Bus configuration for a DHT11 |
|
|
20
20
|
| `dht11` | input | Reads temperature and humidity from a DHT11 sensor over a single GPIO data line. |
|
|
21
|
-
| `
|
|
22
|
-
| `
|
|
23
|
-
| `
|
|
24
|
-
| `
|
|
25
|
-
| `
|
|
26
|
-
| `
|
|
27
|
-
| `
|
|
21
|
+
| `hdc1008-device` | config | I²C bus and address for a HDC1008 |
|
|
22
|
+
| `hdc1008` | input | Reads temperature and relative humidity from a Texas Instruments HDC1008 over I²C (addresses 0x40–0x43) with one sequence measurement (temperature then humidity) per message. |
|
|
23
|
+
| `hdc1080-device` | config | I²C bus and address for a HDC1080 |
|
|
24
|
+
| `hdc1080` | input | Reads temperature and relative humidity from a Texas Instruments HDC1080 over I²C (address 0x40) with one sequence measurement (temperature then humidity) per message. |
|
|
25
|
+
| `hs30xx-device` | config | I²C bus and address for a HS30XX |
|
|
26
|
+
| `hs30xx` | input | Reads temperature and relative humidity from a Renesas HS3001, HS3002 or HS3003 (the HS30xx family, one protocol) over I²C (fixed address 0x44) with one measurement per message. |
|
|
27
|
+
| `hs40xx-device` | config | I²C bus and address for a HS40XX |
|
|
28
|
+
| `hs40xx` | input | Reads temperature and relative humidity from a Renesas HS4001 or HS4003 (the HS40xx family, one protocol) over I²C (fixed address 0x54) with one no-hold measurement per message. HS4002 and the HS401x variants are physically different versions of the same part and are not offered separately. |
|
|
29
|
+
| `htu21df-device` | config | I²C bus and address for a HTU21DF |
|
|
30
|
+
| `htu21df` | input | Reads temperature and relative humidity from a Measurement Specialties HTU21D-F over I²C (fixed address 0x40) with one temperature and one humidity measurement per message. The CRC of both results is verified. |
|
|
31
|
+
| `sht31-device` | config | I²C bus and address for a SHT31 |
|
|
32
|
+
| `sht31` | input | Reads temperature and relative humidity from a Sensirion SHT31 over I²C (0x44 with ADDR low, 0x45 with ADDR high) with one single-shot measurement per message. Both CRC bytes are verified. |
|
|
33
|
+
| `si7021-device` | config | I²C bus and address for a SI7021 |
|
|
34
|
+
| `si7021` | input | Reads relative humidity and temperature from a Silicon Labs Si7021 over I²C (fixed address 0x40) with one relative-humidity measurement per message; the temperature comes from the same conversion. The CRC of the humidity result is verified. |
|
|
28
35
|
|
|
29
36
|
## Links
|
|
30
37
|
|
package/examples/dht11/demo.json
CHANGED
|
@@ -1,8 +1,70 @@
|
|
|
1
1
|
[
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
{
|
|
3
|
+
"id": "dht11_demo_tab",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "DHT11 Demo",
|
|
6
|
+
"info": "Indoor comfort monitor using a DHT11 sensor.\n\nAn inject node fires every 5 seconds and triggers a `dht11` read. The output connects to a debug node (logging the full payload) and two dashboard gauge nodes (node-red-dashboard): one for temperature in °C and one for humidity in %RH.\n\nConfigure the `dht11-device` config node with the GPIO pin number wired to the DHT11 DATA line (with a 4.7 kΩ pull-up to 3V3). Set the retry count to 3 to gracefully handle occasional checksum errors.",
|
|
7
|
+
"disabled": false
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "dht11-device-1",
|
|
11
|
+
"type": "dht11-device",
|
|
12
|
+
"name": "DHT11",
|
|
13
|
+
"dataPin": "4",
|
|
14
|
+
"retries": "3"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"id": "dht11-inject-1",
|
|
18
|
+
"type": "inject",
|
|
19
|
+
"z": "dht11_demo_tab",
|
|
20
|
+
"name": "Every 5 s",
|
|
21
|
+
"props": [
|
|
22
|
+
{
|
|
23
|
+
"p": "payload"
|
|
24
|
+
}
|
|
25
|
+
],
|
|
26
|
+
"repeat": "5",
|
|
27
|
+
"crontab": "",
|
|
28
|
+
"once": true,
|
|
29
|
+
"onceDelay": 1,
|
|
30
|
+
"topic": "",
|
|
31
|
+
"payload": "",
|
|
32
|
+
"payloadType": "date",
|
|
33
|
+
"x": 140,
|
|
34
|
+
"y": 100,
|
|
35
|
+
"wires": [
|
|
36
|
+
[
|
|
37
|
+
"dht11-read-1"
|
|
38
|
+
]
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "dht11-read-1",
|
|
43
|
+
"type": "dht11",
|
|
44
|
+
"z": "dht11_demo_tab",
|
|
45
|
+
"name": "DHT11",
|
|
46
|
+
"device": "dht11-device-1",
|
|
47
|
+
"x": 330,
|
|
48
|
+
"y": 100,
|
|
49
|
+
"wires": [
|
|
50
|
+
[
|
|
51
|
+
"dht11-debug-1"
|
|
52
|
+
]
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"id": "dht11-debug-1",
|
|
57
|
+
"type": "debug",
|
|
58
|
+
"z": "dht11_demo_tab",
|
|
59
|
+
"name": "DHT11 reading",
|
|
60
|
+
"active": true,
|
|
61
|
+
"tosidebar": true,
|
|
62
|
+
"console": false,
|
|
63
|
+
"tostatus": false,
|
|
64
|
+
"complete": "payload",
|
|
65
|
+
"targetType": "msg",
|
|
66
|
+
"x": 540,
|
|
67
|
+
"y": 100,
|
|
68
|
+
"wires": []
|
|
69
|
+
}
|
|
8
70
|
]
|
|
@@ -31,12 +31,18 @@
|
|
|
31
31
|
]
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
|
-
"id": "hdc1008-
|
|
35
|
-
"type": "
|
|
36
|
-
"z": "hdc1008-tab",
|
|
34
|
+
"id": "hdc1008-device-1",
|
|
35
|
+
"type": "hdc1008-device",
|
|
37
36
|
"name": "HDC1008",
|
|
38
37
|
"bus": "1",
|
|
39
38
|
"address": "0x40",
|
|
39
|
+
"resolution": "14/14"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "hdc1008-node",
|
|
43
|
+
"type": "hdc1008",
|
|
44
|
+
"z": "hdc1008-tab",
|
|
45
|
+
"name": "HDC1008",
|
|
40
46
|
"x": 380,
|
|
41
47
|
"y": 160,
|
|
42
48
|
"wires": [
|
|
@@ -44,7 +50,7 @@
|
|
|
44
50
|
"hdc1008-format"
|
|
45
51
|
]
|
|
46
52
|
],
|
|
47
|
-
"
|
|
53
|
+
"device": "hdc1008-device-1"
|
|
48
54
|
},
|
|
49
55
|
{
|
|
50
56
|
"id": "hdc1008-format",
|
|
@@ -31,12 +31,18 @@
|
|
|
31
31
|
]
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
|
-
"id": "hdc1080-
|
|
35
|
-
"type": "
|
|
36
|
-
"z": "hdc1080-tab",
|
|
34
|
+
"id": "hdc1080-device-1",
|
|
35
|
+
"type": "hdc1080-device",
|
|
37
36
|
"name": "HDC1080",
|
|
38
37
|
"bus": "1",
|
|
39
38
|
"address": "0x40",
|
|
39
|
+
"resolution": "14/14"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "hdc1080-node",
|
|
43
|
+
"type": "hdc1080",
|
|
44
|
+
"z": "hdc1080-tab",
|
|
45
|
+
"name": "HDC1080",
|
|
40
46
|
"x": 380,
|
|
41
47
|
"y": 160,
|
|
42
48
|
"wires": [
|
|
@@ -44,7 +50,7 @@
|
|
|
44
50
|
"hdc1080-format"
|
|
45
51
|
]
|
|
46
52
|
],
|
|
47
|
-
"
|
|
53
|
+
"device": "hdc1080-device-1"
|
|
48
54
|
},
|
|
49
55
|
{
|
|
50
56
|
"id": "hdc1080-format",
|
|
@@ -30,20 +30,26 @@
|
|
|
30
30
|
]
|
|
31
31
|
]
|
|
32
32
|
},
|
|
33
|
+
{
|
|
34
|
+
"id": "hs30xx-device-1",
|
|
35
|
+
"type": "hs30xx-device",
|
|
36
|
+
"name": "HS30XX",
|
|
37
|
+
"bus": "1",
|
|
38
|
+
"address": "0x44"
|
|
39
|
+
},
|
|
33
40
|
{
|
|
34
41
|
"id": "hs30xx-node",
|
|
35
|
-
"type": "
|
|
42
|
+
"type": "hs30xx",
|
|
36
43
|
"z": "hs30xx-tab",
|
|
37
44
|
"name": "HS30xx",
|
|
38
|
-
"bus": "1",
|
|
39
|
-
"address": "0x44",
|
|
40
45
|
"x": 380,
|
|
41
46
|
"y": 160,
|
|
42
47
|
"wires": [
|
|
43
48
|
[
|
|
44
49
|
"hs30xx-format"
|
|
45
50
|
]
|
|
46
|
-
]
|
|
51
|
+
],
|
|
52
|
+
"device": "hs30xx-device-1"
|
|
47
53
|
},
|
|
48
54
|
{
|
|
49
55
|
"id": "hs30xx-format",
|
|
@@ -30,20 +30,26 @@
|
|
|
30
30
|
]
|
|
31
31
|
]
|
|
32
32
|
},
|
|
33
|
+
{
|
|
34
|
+
"id": "hs40xx-device-1",
|
|
35
|
+
"type": "hs40xx-device",
|
|
36
|
+
"name": "HS40XX",
|
|
37
|
+
"bus": "1",
|
|
38
|
+
"address": "0x54"
|
|
39
|
+
},
|
|
33
40
|
{
|
|
34
41
|
"id": "hs40xx-node",
|
|
35
|
-
"type": "
|
|
42
|
+
"type": "hs40xx",
|
|
36
43
|
"z": "hs40xx-tab",
|
|
37
44
|
"name": "HS40xx",
|
|
38
|
-
"bus": "1",
|
|
39
|
-
"address": "0x54",
|
|
40
45
|
"x": 380,
|
|
41
46
|
"y": 160,
|
|
42
47
|
"wires": [
|
|
43
48
|
[
|
|
44
49
|
"hs40xx-format"
|
|
45
50
|
]
|
|
46
|
-
]
|
|
51
|
+
],
|
|
52
|
+
"device": "hs40xx-device-1"
|
|
47
53
|
},
|
|
48
54
|
{
|
|
49
55
|
"id": "hs40xx-format",
|
|
@@ -30,13 +30,20 @@
|
|
|
30
30
|
]
|
|
31
31
|
]
|
|
32
32
|
},
|
|
33
|
+
{
|
|
34
|
+
"id": "htu21df-device-1",
|
|
35
|
+
"type": "htu21df-device",
|
|
36
|
+
"name": "HTU21DF",
|
|
37
|
+
"resolution": "12/14",
|
|
38
|
+
"bus": "1",
|
|
39
|
+
"address": "0x40",
|
|
40
|
+
"heater": false
|
|
41
|
+
},
|
|
33
42
|
{
|
|
34
43
|
"id": "htu21df-node",
|
|
35
|
-
"type": "
|
|
44
|
+
"type": "htu21df",
|
|
36
45
|
"z": "htu21df-tab",
|
|
37
46
|
"name": "HTU21D-F",
|
|
38
|
-
"bus": "1",
|
|
39
|
-
"address": "0x40",
|
|
40
47
|
"x": 380,
|
|
41
48
|
"y": 160,
|
|
42
49
|
"wires": [
|
|
@@ -44,8 +51,7 @@
|
|
|
44
51
|
"htu21df-format"
|
|
45
52
|
]
|
|
46
53
|
],
|
|
47
|
-
"
|
|
48
|
-
"heater": false
|
|
54
|
+
"device": "htu21df-device-1"
|
|
49
55
|
},
|
|
50
56
|
{
|
|
51
57
|
"id": "htu21df-format",
|
package/examples/sht31/demo.json
CHANGED
|
@@ -31,20 +31,26 @@
|
|
|
31
31
|
]
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
|
-
"id": "sht31-
|
|
35
|
-
"type": "
|
|
36
|
-
"z": "sht31-tab",
|
|
34
|
+
"id": "sht31-device-1",
|
|
35
|
+
"type": "sht31-device",
|
|
37
36
|
"name": "SHT31",
|
|
38
37
|
"bus": "1",
|
|
39
38
|
"address": "0x44",
|
|
40
|
-
"repeatability": "high"
|
|
39
|
+
"repeatability": "high"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"id": "sht31-node",
|
|
43
|
+
"type": "sht31",
|
|
44
|
+
"z": "sht31-tab",
|
|
45
|
+
"name": "SHT31",
|
|
41
46
|
"x": 380,
|
|
42
47
|
"y": 160,
|
|
43
48
|
"wires": [
|
|
44
49
|
[
|
|
45
50
|
"sht31-format"
|
|
46
51
|
]
|
|
47
|
-
]
|
|
52
|
+
],
|
|
53
|
+
"device": "sht31-device-1"
|
|
48
54
|
},
|
|
49
55
|
{
|
|
50
56
|
"id": "sht31-format",
|
|
@@ -30,13 +30,20 @@
|
|
|
30
30
|
]
|
|
31
31
|
]
|
|
32
32
|
},
|
|
33
|
+
{
|
|
34
|
+
"id": "si7021-device-1",
|
|
35
|
+
"type": "si7021-device",
|
|
36
|
+
"name": "SI7021",
|
|
37
|
+
"resolution": "12/14",
|
|
38
|
+
"bus": "1",
|
|
39
|
+
"address": "0x40",
|
|
40
|
+
"heater": false
|
|
41
|
+
},
|
|
33
42
|
{
|
|
34
43
|
"id": "si7021-node",
|
|
35
|
-
"type": "
|
|
44
|
+
"type": "si7021",
|
|
36
45
|
"z": "si7021-tab",
|
|
37
46
|
"name": "Si7021",
|
|
38
|
-
"bus": "1",
|
|
39
|
-
"address": "0x40",
|
|
40
47
|
"x": 380,
|
|
41
48
|
"y": 160,
|
|
42
49
|
"wires": [
|
|
@@ -44,8 +51,7 @@
|
|
|
44
51
|
"si7021-format"
|
|
45
52
|
]
|
|
46
53
|
],
|
|
47
|
-
"
|
|
48
|
-
"heater": false
|
|
54
|
+
"device": "si7021-device-1"
|
|
49
55
|
},
|
|
50
56
|
{
|
|
51
57
|
"id": "si7021-format",
|
|
@@ -1,38 +1,35 @@
|
|
|
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('hdc1008-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: '0x40' },
|
|
9
9
|
resolution: { value: '14/14' }
|
|
10
10
|
},
|
|
11
|
-
inputs: 1,
|
|
12
|
-
outputs: 1,
|
|
13
|
-
icon: 'bridge.svg',
|
|
14
11
|
label: function() {
|
|
15
12
|
return this.name || ('HDC1008 @ ' + this.address + ' (bus ' + this.bus + ')');
|
|
16
13
|
}
|
|
17
14
|
});
|
|
18
15
|
</script>
|
|
19
16
|
|
|
20
|
-
<script type="text/html" data-template-name="
|
|
17
|
+
<script type="text/html" data-template-name="hdc1008-device">
|
|
21
18
|
<div class="form-row">
|
|
22
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
23
|
-
<input type="text" id="node-input-name" placeholder="HDC1008">
|
|
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="HDC1008">
|
|
24
21
|
</div>
|
|
25
22
|
<div class="form-row">
|
|
26
|
-
<label for="node-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
27
|
-
<input type="number" id="node-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N)
|
|
23
|
+
<label for="node-config-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
24
|
+
<input type="number" id="node-config-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N)
|
|
28
25
|
</div>
|
|
29
26
|
<div class="form-row">
|
|
30
|
-
<label for="node-input-address"><i class="fa fa-microchip"></i> I²C address</label>
|
|
31
|
-
<input type="text" id="node-input-address" style="width:80px" placeholder="0x40"> (0x40 – 0x43, set by ADR0/ADR1)
|
|
27
|
+
<label for="node-config-input-address"><i class="fa fa-microchip"></i> I²C address</label>
|
|
28
|
+
<input type="text" id="node-config-input-address" style="width:80px" placeholder="0x40"> (0x40 – 0x43, set by ADR0/ADR1)
|
|
32
29
|
</div>
|
|
33
30
|
<div class="form-row">
|
|
34
|
-
<label for="node-input-resolution"><i class="fa fa-cog"></i> Resolution</label>
|
|
35
|
-
<select id="node-input-resolution" style="width:200px">
|
|
31
|
+
<label for="node-config-input-resolution"><i class="fa fa-cog"></i> Resolution</label>
|
|
32
|
+
<select id="node-config-input-resolution" style="width:200px">
|
|
36
33
|
<option value="14/14" selected>T 14 bit / RH 14 bit</option>
|
|
37
34
|
<option value="14/11">T 14 bit / RH 11 bit</option>
|
|
38
35
|
<option value="14/8">T 14 bit / RH 8 bit</option>
|
|
@@ -43,7 +40,35 @@
|
|
|
43
40
|
</div>
|
|
44
41
|
</script>
|
|
45
42
|
|
|
46
|
-
|
|
43
|
+
<!-- Read node -->
|
|
44
|
+
<script type="text/javascript">
|
|
45
|
+
RED.nodes.registerType('hdc1008', {
|
|
46
|
+
category: 'Peripheral',
|
|
47
|
+
color: '#C084FC',
|
|
48
|
+
defaults: {
|
|
49
|
+
name: { value: '' },
|
|
50
|
+
device: { value: '', type: 'hdc1008-device', required: true }
|
|
51
|
+
},
|
|
52
|
+
inputs: 1,
|
|
53
|
+
outputs: 1,
|
|
54
|
+
icon: 'bridge.svg',
|
|
55
|
+
label: function() { return this.name || 'HDC1008'; },
|
|
56
|
+
paletteLabel: 'HDC1008'
|
|
57
|
+
});
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<script type="text/html" data-template-name="hdc1008">
|
|
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="HDC1008">
|
|
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="hdc1008">
|
|
47
72
|
<p>Reads temperature and relative humidity from a Texas Instruments HDC1008 over I²C (addresses 0x40–0x43)
|
|
48
73
|
with one sequence measurement (temperature then humidity) per message.</p>
|
|
49
74
|
<h3>Inputs</h3>
|
package/nodes/hdc1008/hdc1008.js
CHANGED
|
@@ -6,7 +6,7 @@ module.exports = function(RED) {
|
|
|
6
6
|
|
|
7
7
|
const RESOLUTIONS = { '14/14': [14, 14], '14/11': [14, 11], '14/8': [14, 8], '11/14': [11, 14], '11/11': [11, 11], '11/8': [11, 8] };
|
|
8
8
|
|
|
9
|
-
function
|
|
9
|
+
function HDC1008DeviceNode(config) {
|
|
10
10
|
RED.nodes.createNode(this, config);
|
|
11
11
|
const node = this;
|
|
12
12
|
try {
|
|
@@ -26,15 +26,26 @@ module.exports = function(RED) {
|
|
|
26
26
|
node.error('HDC1008 init failed: ' + e.message);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
node.on('close', function() {
|
|
30
|
+
if (node.connection) node.connection.close();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
RED.nodes.registerType('hdc1008-device', HDC1008DeviceNode);
|
|
34
|
+
|
|
35
|
+
function HDC1008ReadNode(config) {
|
|
36
|
+
RED.nodes.createNode(this, config);
|
|
37
|
+
const node = this;
|
|
38
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
39
|
+
|
|
29
40
|
node.on('input', async function(msg, send, done) {
|
|
30
|
-
if (!
|
|
41
|
+
if (!deviceNode.driver) {
|
|
31
42
|
node.error('HDC1008 not initialised', msg);
|
|
32
43
|
done();
|
|
33
44
|
return;
|
|
34
45
|
}
|
|
35
46
|
try {
|
|
36
|
-
await
|
|
37
|
-
const [temperature_c, humidity_pct] = await
|
|
47
|
+
await deviceNode.ready;
|
|
48
|
+
const [temperature_c, humidity_pct] = await deviceNode.driver.read();
|
|
38
49
|
msg.payload = { temperature_c, humidity_pct };
|
|
39
50
|
send(msg);
|
|
40
51
|
done();
|
|
@@ -42,10 +53,6 @@ module.exports = function(RED) {
|
|
|
42
53
|
done(e);
|
|
43
54
|
}
|
|
44
55
|
});
|
|
45
|
-
|
|
46
|
-
node.on('close', function() {
|
|
47
|
-
if (node.connection) node.connection.close();
|
|
48
|
-
});
|
|
49
56
|
}
|
|
50
|
-
RED.nodes.registerType('
|
|
57
|
+
RED.nodes.registerType('hdc1008', HDC1008ReadNode);
|
|
51
58
|
};
|
|
@@ -1,38 +1,35 @@
|
|
|
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('hdc1080-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: '0x40' },
|
|
9
9
|
resolution: { value: '14/14' }
|
|
10
10
|
},
|
|
11
|
-
inputs: 1,
|
|
12
|
-
outputs: 1,
|
|
13
|
-
icon: 'bridge.svg',
|
|
14
11
|
label: function() {
|
|
15
12
|
return this.name || ('HDC1080 @ ' + this.address + ' (bus ' + this.bus + ')');
|
|
16
13
|
}
|
|
17
14
|
});
|
|
18
15
|
</script>
|
|
19
16
|
|
|
20
|
-
<script type="text/html" data-template-name="
|
|
17
|
+
<script type="text/html" data-template-name="hdc1080-device">
|
|
21
18
|
<div class="form-row">
|
|
22
|
-
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
23
|
-
<input type="text" id="node-input-name" placeholder="HDC1080">
|
|
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="HDC1080">
|
|
24
21
|
</div>
|
|
25
22
|
<div class="form-row">
|
|
26
|
-
<label for="node-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
27
|
-
<input type="number" id="node-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N)
|
|
23
|
+
<label for="node-config-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
24
|
+
<input type="number" id="node-config-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N)
|
|
28
25
|
</div>
|
|
29
26
|
<div class="form-row">
|
|
30
|
-
<label for="node-input-address"><i class="fa fa-microchip"></i> I²C address</label>
|
|
31
|
-
<input type="text" id="node-input-address" style="width:80px" placeholder="0x40"> (fixed 0x40)
|
|
27
|
+
<label for="node-config-input-address"><i class="fa fa-microchip"></i> I²C address</label>
|
|
28
|
+
<input type="text" id="node-config-input-address" style="width:80px" placeholder="0x40"> (fixed 0x40)
|
|
32
29
|
</div>
|
|
33
30
|
<div class="form-row">
|
|
34
|
-
<label for="node-input-resolution"><i class="fa fa-cog"></i> Resolution</label>
|
|
35
|
-
<select id="node-input-resolution" style="width:200px">
|
|
31
|
+
<label for="node-config-input-resolution"><i class="fa fa-cog"></i> Resolution</label>
|
|
32
|
+
<select id="node-config-input-resolution" style="width:200px">
|
|
36
33
|
<option value="14/14" selected>T 14 bit / RH 14 bit</option>
|
|
37
34
|
<option value="14/11">T 14 bit / RH 11 bit</option>
|
|
38
35
|
<option value="14/8">T 14 bit / RH 8 bit</option>
|
|
@@ -43,7 +40,35 @@
|
|
|
43
40
|
</div>
|
|
44
41
|
</script>
|
|
45
42
|
|
|
46
|
-
|
|
43
|
+
<!-- Read node -->
|
|
44
|
+
<script type="text/javascript">
|
|
45
|
+
RED.nodes.registerType('hdc1080', {
|
|
46
|
+
category: 'Peripheral',
|
|
47
|
+
color: '#C084FC',
|
|
48
|
+
defaults: {
|
|
49
|
+
name: { value: '' },
|
|
50
|
+
device: { value: '', type: 'hdc1080-device', required: true }
|
|
51
|
+
},
|
|
52
|
+
inputs: 1,
|
|
53
|
+
outputs: 1,
|
|
54
|
+
icon: 'bridge.svg',
|
|
55
|
+
label: function() { return this.name || 'HDC1080'; },
|
|
56
|
+
paletteLabel: 'HDC1080'
|
|
57
|
+
});
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<script type="text/html" data-template-name="hdc1080">
|
|
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="HDC1080">
|
|
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="hdc1080">
|
|
47
72
|
<p>Reads temperature and relative humidity from a Texas Instruments HDC1080 over I²C (address 0x40)
|
|
48
73
|
with one sequence measurement (temperature then humidity) per message.</p>
|
|
49
74
|
<h3>Inputs</h3>
|
package/nodes/hdc1080/hdc1080.js
CHANGED
|
@@ -6,7 +6,7 @@ module.exports = function(RED) {
|
|
|
6
6
|
|
|
7
7
|
const RESOLUTIONS = { '14/14': [14, 14], '14/11': [14, 11], '14/8': [14, 8], '11/14': [11, 14], '11/11': [11, 11], '11/8': [11, 8] };
|
|
8
8
|
|
|
9
|
-
function
|
|
9
|
+
function HDC1080DeviceNode(config) {
|
|
10
10
|
RED.nodes.createNode(this, config);
|
|
11
11
|
const node = this;
|
|
12
12
|
try {
|
|
@@ -26,15 +26,26 @@ module.exports = function(RED) {
|
|
|
26
26
|
node.error('HDC1080 init failed: ' + e.message);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
node.on('close', function() {
|
|
30
|
+
if (node.connection) node.connection.close();
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
RED.nodes.registerType('hdc1080-device', HDC1080DeviceNode);
|
|
34
|
+
|
|
35
|
+
function HDC1080ReadNode(config) {
|
|
36
|
+
RED.nodes.createNode(this, config);
|
|
37
|
+
const node = this;
|
|
38
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
39
|
+
|
|
29
40
|
node.on('input', async function(msg, send, done) {
|
|
30
|
-
if (!
|
|
41
|
+
if (!deviceNode.driver) {
|
|
31
42
|
node.error('HDC1080 not initialised', msg);
|
|
32
43
|
done();
|
|
33
44
|
return;
|
|
34
45
|
}
|
|
35
46
|
try {
|
|
36
|
-
await
|
|
37
|
-
const [temperature_c, humidity_pct] = await
|
|
47
|
+
await deviceNode.ready;
|
|
48
|
+
const [temperature_c, humidity_pct] = await deviceNode.driver.read();
|
|
38
49
|
msg.payload = { temperature_c, humidity_pct };
|
|
39
50
|
send(msg);
|
|
40
51
|
done();
|
|
@@ -42,10 +53,6 @@ module.exports = function(RED) {
|
|
|
42
53
|
done(e);
|
|
43
54
|
}
|
|
44
55
|
});
|
|
45
|
-
|
|
46
|
-
node.on('close', function() {
|
|
47
|
-
if (node.connection) node.connection.close();
|
|
48
|
-
});
|
|
49
56
|
}
|
|
50
|
-
RED.nodes.registerType('
|
|
57
|
+
RED.nodes.registerType('hdc1080', HDC1080ReadNode);
|
|
51
58
|
};
|