node-red-contrib-periph-humidity 1.5.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/examples/hdc1008/demo.json +85 -0
- package/examples/hdc1080/demo.json +85 -0
- package/examples/hs30xx/demo.json +84 -0
- package/examples/hs40xx/demo.json +84 -0
- package/nodes/hdc1008/hdc1008.html +63 -0
- package/nodes/hdc1008/hdc1008.js +51 -0
- package/nodes/hdc1080/hdc1080.html +63 -0
- package/nodes/hdc1080/hdc1080.js +51 -0
- package/nodes/hs30xx/hs30xx.html +53 -0
- package/nodes/hs30xx/hs30xx.js +39 -0
- package/nodes/hs40xx/hs40xx.html +65 -0
- package/nodes/hs40xx/hs40xx.js +44 -0
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -18,6 +18,10 @@ 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
|
+
| `periph-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. |
|
|
22
|
+
| `periph-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. |
|
|
23
|
+
| `periph-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. |
|
|
24
|
+
| `periph-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. |
|
|
21
25
|
| `periph-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. |
|
|
22
26
|
| `periph-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. |
|
|
23
27
|
| `periph-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. |
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "hdc1008-tab",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "HDC1008 humidity logger",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "Reads temperature and relative humidity from an HDC1008 every 2 s and formats them. Demonstrates the sequence-mode measurement (temperature then humidity in one read)."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "hdc1008-inject",
|
|
11
|
+
"type": "inject",
|
|
12
|
+
"z": "hdc1008-tab",
|
|
13
|
+
"name": "2 s timer",
|
|
14
|
+
"props": [
|
|
15
|
+
{
|
|
16
|
+
"p": "payload"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"repeat": "2",
|
|
20
|
+
"crontab": "",
|
|
21
|
+
"once": false,
|
|
22
|
+
"onceDelay": 0.1,
|
|
23
|
+
"topic": "",
|
|
24
|
+
"payloadType": "date",
|
|
25
|
+
"x": 160,
|
|
26
|
+
"y": 160,
|
|
27
|
+
"wires": [
|
|
28
|
+
[
|
|
29
|
+
"hdc1008-node"
|
|
30
|
+
]
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "hdc1008-node",
|
|
35
|
+
"type": "periph-hdc1008",
|
|
36
|
+
"z": "hdc1008-tab",
|
|
37
|
+
"name": "HDC1008",
|
|
38
|
+
"bus": "1",
|
|
39
|
+
"address": "0x40",
|
|
40
|
+
"x": 380,
|
|
41
|
+
"y": 160,
|
|
42
|
+
"wires": [
|
|
43
|
+
[
|
|
44
|
+
"hdc1008-format"
|
|
45
|
+
]
|
|
46
|
+
],
|
|
47
|
+
"resolution": "14/14"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"id": "hdc1008-format",
|
|
51
|
+
"type": "function",
|
|
52
|
+
"z": "hdc1008-tab",
|
|
53
|
+
"name": "Format",
|
|
54
|
+
"func": "msg.payload = msg.payload.temperature_c.toFixed(2) + ' °C, ' + msg.payload.humidity_pct.toFixed(1) + ' %RH';\nreturn msg;",
|
|
55
|
+
"outputs": 1,
|
|
56
|
+
"noerr": 0,
|
|
57
|
+
"initialize": "",
|
|
58
|
+
"finalize": "",
|
|
59
|
+
"libs": [],
|
|
60
|
+
"x": 600,
|
|
61
|
+
"y": 160,
|
|
62
|
+
"wires": [
|
|
63
|
+
[
|
|
64
|
+
"hdc1008-debug"
|
|
65
|
+
]
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"id": "hdc1008-debug",
|
|
70
|
+
"type": "debug",
|
|
71
|
+
"z": "hdc1008-tab",
|
|
72
|
+
"name": "Reading",
|
|
73
|
+
"active": true,
|
|
74
|
+
"tosidebar": true,
|
|
75
|
+
"console": false,
|
|
76
|
+
"tostatus": false,
|
|
77
|
+
"complete": "payload",
|
|
78
|
+
"targetType": "msg",
|
|
79
|
+
"statusVal": "",
|
|
80
|
+
"statusType": "auto",
|
|
81
|
+
"x": 800,
|
|
82
|
+
"y": 160,
|
|
83
|
+
"wires": []
|
|
84
|
+
}
|
|
85
|
+
]
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "hdc1080-tab",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "HDC1080 humidity logger",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "Reads temperature and relative humidity from an HDC1080 every 2 s and formats them. Demonstrates the sequence-mode measurement (temperature then humidity in one read)."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "hdc1080-inject",
|
|
11
|
+
"type": "inject",
|
|
12
|
+
"z": "hdc1080-tab",
|
|
13
|
+
"name": "2 s timer",
|
|
14
|
+
"props": [
|
|
15
|
+
{
|
|
16
|
+
"p": "payload"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"repeat": "2",
|
|
20
|
+
"crontab": "",
|
|
21
|
+
"once": false,
|
|
22
|
+
"onceDelay": 0.1,
|
|
23
|
+
"topic": "",
|
|
24
|
+
"payloadType": "date",
|
|
25
|
+
"x": 160,
|
|
26
|
+
"y": 160,
|
|
27
|
+
"wires": [
|
|
28
|
+
[
|
|
29
|
+
"hdc1080-node"
|
|
30
|
+
]
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "hdc1080-node",
|
|
35
|
+
"type": "periph-hdc1080",
|
|
36
|
+
"z": "hdc1080-tab",
|
|
37
|
+
"name": "HDC1080",
|
|
38
|
+
"bus": "1",
|
|
39
|
+
"address": "0x40",
|
|
40
|
+
"x": 380,
|
|
41
|
+
"y": 160,
|
|
42
|
+
"wires": [
|
|
43
|
+
[
|
|
44
|
+
"hdc1080-format"
|
|
45
|
+
]
|
|
46
|
+
],
|
|
47
|
+
"resolution": "14/14"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"id": "hdc1080-format",
|
|
51
|
+
"type": "function",
|
|
52
|
+
"z": "hdc1080-tab",
|
|
53
|
+
"name": "Format",
|
|
54
|
+
"func": "msg.payload = msg.payload.temperature_c.toFixed(2) + ' °C, ' + msg.payload.humidity_pct.toFixed(1) + ' %RH';\nreturn msg;",
|
|
55
|
+
"outputs": 1,
|
|
56
|
+
"noerr": 0,
|
|
57
|
+
"initialize": "",
|
|
58
|
+
"finalize": "",
|
|
59
|
+
"libs": [],
|
|
60
|
+
"x": 600,
|
|
61
|
+
"y": 160,
|
|
62
|
+
"wires": [
|
|
63
|
+
[
|
|
64
|
+
"hdc1080-debug"
|
|
65
|
+
]
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
"id": "hdc1080-debug",
|
|
70
|
+
"type": "debug",
|
|
71
|
+
"z": "hdc1080-tab",
|
|
72
|
+
"name": "Reading",
|
|
73
|
+
"active": true,
|
|
74
|
+
"tosidebar": true,
|
|
75
|
+
"console": false,
|
|
76
|
+
"tostatus": false,
|
|
77
|
+
"complete": "payload",
|
|
78
|
+
"targetType": "msg",
|
|
79
|
+
"statusVal": "",
|
|
80
|
+
"statusType": "auto",
|
|
81
|
+
"x": 800,
|
|
82
|
+
"y": 160,
|
|
83
|
+
"wires": []
|
|
84
|
+
}
|
|
85
|
+
]
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "hs30xx-tab",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "HS30xx humidity logger",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "Reads temperature and relative humidity from an HS30xx (HS3001/HS3002/HS3003) every 2 s and formats them. Each message sends one measurement request, waits 40 ms and fetches the result."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "hs30xx-inject",
|
|
11
|
+
"type": "inject",
|
|
12
|
+
"z": "hs30xx-tab",
|
|
13
|
+
"name": "2 s timer",
|
|
14
|
+
"props": [
|
|
15
|
+
{
|
|
16
|
+
"p": "payload"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"repeat": "2",
|
|
20
|
+
"crontab": "",
|
|
21
|
+
"once": false,
|
|
22
|
+
"onceDelay": 0.1,
|
|
23
|
+
"topic": "",
|
|
24
|
+
"payloadType": "date",
|
|
25
|
+
"x": 160,
|
|
26
|
+
"y": 160,
|
|
27
|
+
"wires": [
|
|
28
|
+
[
|
|
29
|
+
"hs30xx-node"
|
|
30
|
+
]
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "hs30xx-node",
|
|
35
|
+
"type": "periph-hs30xx",
|
|
36
|
+
"z": "hs30xx-tab",
|
|
37
|
+
"name": "HS30xx",
|
|
38
|
+
"bus": "1",
|
|
39
|
+
"address": "0x44",
|
|
40
|
+
"x": 380,
|
|
41
|
+
"y": 160,
|
|
42
|
+
"wires": [
|
|
43
|
+
[
|
|
44
|
+
"hs30xx-format"
|
|
45
|
+
]
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"id": "hs30xx-format",
|
|
50
|
+
"type": "function",
|
|
51
|
+
"z": "hs30xx-tab",
|
|
52
|
+
"name": "Format",
|
|
53
|
+
"func": "msg.payload = msg.payload.temperature_c.toFixed(2) + ' °C, ' + msg.payload.humidity_pct.toFixed(1) + ' %RH';\nreturn msg;",
|
|
54
|
+
"outputs": 1,
|
|
55
|
+
"noerr": 0,
|
|
56
|
+
"initialize": "",
|
|
57
|
+
"finalize": "",
|
|
58
|
+
"libs": [],
|
|
59
|
+
"x": 600,
|
|
60
|
+
"y": 160,
|
|
61
|
+
"wires": [
|
|
62
|
+
[
|
|
63
|
+
"hs30xx-debug"
|
|
64
|
+
]
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"id": "hs30xx-debug",
|
|
69
|
+
"type": "debug",
|
|
70
|
+
"z": "hs30xx-tab",
|
|
71
|
+
"name": "Reading",
|
|
72
|
+
"active": true,
|
|
73
|
+
"tosidebar": true,
|
|
74
|
+
"console": false,
|
|
75
|
+
"tostatus": false,
|
|
76
|
+
"complete": "payload",
|
|
77
|
+
"targetType": "msg",
|
|
78
|
+
"statusVal": "",
|
|
79
|
+
"statusType": "auto",
|
|
80
|
+
"x": 800,
|
|
81
|
+
"y": 160,
|
|
82
|
+
"wires": []
|
|
83
|
+
}
|
|
84
|
+
]
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "hs40xx-tab",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "HS40xx humidity logger",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "Reads temperature and relative humidity from an HS40xx (HS4001/HS4003) every 2 s and formats them. Each message sends one no-hold measurement (0xF5), waits 3 ms, reads five bytes and checks the CRC."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "hs40xx-inject",
|
|
11
|
+
"type": "inject",
|
|
12
|
+
"z": "hs40xx-tab",
|
|
13
|
+
"name": "2 s timer",
|
|
14
|
+
"props": [
|
|
15
|
+
{
|
|
16
|
+
"p": "payload"
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"repeat": "2",
|
|
20
|
+
"crontab": "",
|
|
21
|
+
"once": false,
|
|
22
|
+
"onceDelay": 0.1,
|
|
23
|
+
"topic": "",
|
|
24
|
+
"payloadType": "date",
|
|
25
|
+
"x": 160,
|
|
26
|
+
"y": 160,
|
|
27
|
+
"wires": [
|
|
28
|
+
[
|
|
29
|
+
"hs40xx-node"
|
|
30
|
+
]
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"id": "hs40xx-node",
|
|
35
|
+
"type": "periph-hs40xx",
|
|
36
|
+
"z": "hs40xx-tab",
|
|
37
|
+
"name": "HS40xx",
|
|
38
|
+
"bus": "1",
|
|
39
|
+
"address": "0x54",
|
|
40
|
+
"x": 380,
|
|
41
|
+
"y": 160,
|
|
42
|
+
"wires": [
|
|
43
|
+
[
|
|
44
|
+
"hs40xx-format"
|
|
45
|
+
]
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"id": "hs40xx-format",
|
|
50
|
+
"type": "function",
|
|
51
|
+
"z": "hs40xx-tab",
|
|
52
|
+
"name": "Format",
|
|
53
|
+
"func": "msg.payload = msg.payload.temperature_c.toFixed(2) + ' °C, ' + msg.payload.humidity_pct.toFixed(1) + ' %RH';\nreturn msg;",
|
|
54
|
+
"outputs": 1,
|
|
55
|
+
"noerr": 0,
|
|
56
|
+
"initialize": "",
|
|
57
|
+
"finalize": "",
|
|
58
|
+
"libs": [],
|
|
59
|
+
"x": 600,
|
|
60
|
+
"y": 160,
|
|
61
|
+
"wires": [
|
|
62
|
+
[
|
|
63
|
+
"hs40xx-debug"
|
|
64
|
+
]
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"id": "hs40xx-debug",
|
|
69
|
+
"type": "debug",
|
|
70
|
+
"z": "hs40xx-tab",
|
|
71
|
+
"name": "Reading",
|
|
72
|
+
"active": true,
|
|
73
|
+
"tosidebar": true,
|
|
74
|
+
"console": false,
|
|
75
|
+
"tostatus": false,
|
|
76
|
+
"complete": "payload",
|
|
77
|
+
"targetType": "msg",
|
|
78
|
+
"statusVal": "",
|
|
79
|
+
"statusType": "auto",
|
|
80
|
+
"x": 800,
|
|
81
|
+
"y": 160,
|
|
82
|
+
"wires": []
|
|
83
|
+
}
|
|
84
|
+
]
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType('periph-hdc1008', {
|
|
3
|
+
category: 'Peripheral',
|
|
4
|
+
color: '#C084FC',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
|
+
address: { value: '0x40' },
|
|
9
|
+
resolution: { value: '14/14' }
|
|
10
|
+
},
|
|
11
|
+
inputs: 1,
|
|
12
|
+
outputs: 1,
|
|
13
|
+
icon: 'bridge.svg',
|
|
14
|
+
label: function() {
|
|
15
|
+
return this.name || ('HDC1008 @ ' + this.address + ' (bus ' + this.bus + ')');
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script type="text/html" data-template-name="periph-hdc1008">
|
|
21
|
+
<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">
|
|
24
|
+
</div>
|
|
25
|
+
<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)
|
|
28
|
+
</div>
|
|
29
|
+
<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)
|
|
32
|
+
</div>
|
|
33
|
+
<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">
|
|
36
|
+
<option value="14/14" selected>T 14 bit / RH 14 bit</option>
|
|
37
|
+
<option value="14/11">T 14 bit / RH 11 bit</option>
|
|
38
|
+
<option value="14/8">T 14 bit / RH 8 bit</option>
|
|
39
|
+
<option value="11/14">T 11 bit / RH 14 bit</option>
|
|
40
|
+
<option value="11/11">T 11 bit / RH 11 bit</option>
|
|
41
|
+
<option value="11/8">T 11 bit / RH 8 bit</option>
|
|
42
|
+
</select>
|
|
43
|
+
</div>
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<script type="text/html" data-help-name="periph-hdc1008">
|
|
47
|
+
<p>Reads temperature and relative humidity from a Texas Instruments HDC1008 over I²C (addresses 0x40–0x43)
|
|
48
|
+
with one sequence measurement (temperature then humidity) per message.</p>
|
|
49
|
+
<h3>Inputs</h3>
|
|
50
|
+
<dl class="message-properties">
|
|
51
|
+
<dt>payload <span class="property-type">any</span></dt>
|
|
52
|
+
<dd>Any incoming message triggers one measurement.</dd>
|
|
53
|
+
</dl>
|
|
54
|
+
<h3>Outputs</h3>
|
|
55
|
+
<dl class="message-properties">
|
|
56
|
+
<dt>payload.temperature_c <span class="property-type">number</span></dt>
|
|
57
|
+
<dd>Temperature in °C.</dd>
|
|
58
|
+
<dt>payload.humidity_pct <span class="property-type">number</span></dt>
|
|
59
|
+
<dd>Relative humidity in %RH (0 to 100).</dd>
|
|
60
|
+
</dl>
|
|
61
|
+
<h3>Configuration</h3>
|
|
62
|
+
<p>I²C bus number, I²C address (0x40–0x43) and the temperature / humidity resolution (bits).</p>
|
|
63
|
+
</script>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function(RED) {
|
|
4
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
|
+
const { HDC1008Full } = require('periph/src/chips/humidity/hdc1008');
|
|
6
|
+
|
|
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
|
+
|
|
9
|
+
function HDC1008Node(config) {
|
|
10
|
+
RED.nodes.createNode(this, config);
|
|
11
|
+
const node = this;
|
|
12
|
+
try {
|
|
13
|
+
const address = parseInt(config.address, 16) || 0x40;
|
|
14
|
+
const connection = new I2CConnection(parseInt(config.bus), address);
|
|
15
|
+
node.connection = connection;
|
|
16
|
+
node.driver = new HDC1008Full(connection);
|
|
17
|
+
node.ready = (async () => {
|
|
18
|
+
await node.driver.init();
|
|
19
|
+
const res = RESOLUTIONS[config.resolution] || [14, 14];
|
|
20
|
+
await node.driver.setResolution(res[0], res[1]);
|
|
21
|
+
})();
|
|
22
|
+
node.ready.catch((e) => {
|
|
23
|
+
node.error('HDC1008 init failed: ' + e.message);
|
|
24
|
+
});
|
|
25
|
+
} catch (e) {
|
|
26
|
+
node.error('HDC1008 init failed: ' + e.message);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
node.on('input', async function(msg, send, done) {
|
|
30
|
+
if (!node.driver) {
|
|
31
|
+
node.error('HDC1008 not initialised', msg);
|
|
32
|
+
done();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
await node.ready;
|
|
37
|
+
const [temperature_c, humidity_pct] = await node.driver.read();
|
|
38
|
+
msg.payload = { temperature_c, humidity_pct };
|
|
39
|
+
send(msg);
|
|
40
|
+
done();
|
|
41
|
+
} catch (e) {
|
|
42
|
+
done(e);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
node.on('close', function() {
|
|
47
|
+
if (node.connection) node.connection.close();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
RED.nodes.registerType('periph-hdc1008', HDC1008Node);
|
|
51
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType('periph-hdc1080', {
|
|
3
|
+
category: 'Peripheral',
|
|
4
|
+
color: '#C084FC',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
|
+
address: { value: '0x40' },
|
|
9
|
+
resolution: { value: '14/14' }
|
|
10
|
+
},
|
|
11
|
+
inputs: 1,
|
|
12
|
+
outputs: 1,
|
|
13
|
+
icon: 'bridge.svg',
|
|
14
|
+
label: function() {
|
|
15
|
+
return this.name || ('HDC1080 @ ' + this.address + ' (bus ' + this.bus + ')');
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script type="text/html" data-template-name="periph-hdc1080">
|
|
21
|
+
<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">
|
|
24
|
+
</div>
|
|
25
|
+
<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)
|
|
28
|
+
</div>
|
|
29
|
+
<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)
|
|
32
|
+
</div>
|
|
33
|
+
<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">
|
|
36
|
+
<option value="14/14" selected>T 14 bit / RH 14 bit</option>
|
|
37
|
+
<option value="14/11">T 14 bit / RH 11 bit</option>
|
|
38
|
+
<option value="14/8">T 14 bit / RH 8 bit</option>
|
|
39
|
+
<option value="11/14">T 11 bit / RH 14 bit</option>
|
|
40
|
+
<option value="11/11">T 11 bit / RH 11 bit</option>
|
|
41
|
+
<option value="11/8">T 11 bit / RH 8 bit</option>
|
|
42
|
+
</select>
|
|
43
|
+
</div>
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<script type="text/html" data-help-name="periph-hdc1080">
|
|
47
|
+
<p>Reads temperature and relative humidity from a Texas Instruments HDC1080 over I²C (address 0x40)
|
|
48
|
+
with one sequence measurement (temperature then humidity) per message.</p>
|
|
49
|
+
<h3>Inputs</h3>
|
|
50
|
+
<dl class="message-properties">
|
|
51
|
+
<dt>payload <span class="property-type">any</span></dt>
|
|
52
|
+
<dd>Any incoming message triggers one measurement.</dd>
|
|
53
|
+
</dl>
|
|
54
|
+
<h3>Outputs</h3>
|
|
55
|
+
<dl class="message-properties">
|
|
56
|
+
<dt>payload.temperature_c <span class="property-type">number</span></dt>
|
|
57
|
+
<dd>Temperature in °C.</dd>
|
|
58
|
+
<dt>payload.humidity_pct <span class="property-type">number</span></dt>
|
|
59
|
+
<dd>Relative humidity in %RH (0 to 100).</dd>
|
|
60
|
+
</dl>
|
|
61
|
+
<h3>Configuration</h3>
|
|
62
|
+
<p>I²C bus number, I²C address (0x40) and the temperature / humidity resolution (bits).</p>
|
|
63
|
+
</script>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function(RED) {
|
|
4
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
|
+
const { HDC1080Full } = require('periph/src/chips/humidity/hdc1080');
|
|
6
|
+
|
|
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
|
+
|
|
9
|
+
function HDC1080Node(config) {
|
|
10
|
+
RED.nodes.createNode(this, config);
|
|
11
|
+
const node = this;
|
|
12
|
+
try {
|
|
13
|
+
const address = parseInt(config.address, 16) || 0x40;
|
|
14
|
+
const connection = new I2CConnection(parseInt(config.bus), address);
|
|
15
|
+
node.connection = connection;
|
|
16
|
+
node.driver = new HDC1080Full(connection);
|
|
17
|
+
node.ready = (async () => {
|
|
18
|
+
await node.driver.init();
|
|
19
|
+
const res = RESOLUTIONS[config.resolution] || [14, 14];
|
|
20
|
+
await node.driver.setResolution(res[0], res[1]);
|
|
21
|
+
})();
|
|
22
|
+
node.ready.catch((e) => {
|
|
23
|
+
node.error('HDC1080 init failed: ' + e.message);
|
|
24
|
+
});
|
|
25
|
+
} catch (e) {
|
|
26
|
+
node.error('HDC1080 init failed: ' + e.message);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
node.on('input', async function(msg, send, done) {
|
|
30
|
+
if (!node.driver) {
|
|
31
|
+
node.error('HDC1080 not initialised', msg);
|
|
32
|
+
done();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
await node.ready;
|
|
37
|
+
const [temperature_c, humidity_pct] = await node.driver.read();
|
|
38
|
+
msg.payload = { temperature_c, humidity_pct };
|
|
39
|
+
send(msg);
|
|
40
|
+
done();
|
|
41
|
+
} catch (e) {
|
|
42
|
+
done(e);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
node.on('close', function() {
|
|
47
|
+
if (node.connection) node.connection.close();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
RED.nodes.registerType('periph-hdc1080', HDC1080Node);
|
|
51
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType('periph-hs30xx', {
|
|
3
|
+
category: 'Peripheral',
|
|
4
|
+
color: '#C084FC',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
|
+
address: { value: '0x44' }
|
|
9
|
+
},
|
|
10
|
+
inputs: 1,
|
|
11
|
+
outputs: 1,
|
|
12
|
+
icon: 'bridge.svg',
|
|
13
|
+
label: function() {
|
|
14
|
+
return this.name || ('HS30xx @ ' + this.address + ' (bus ' + this.bus + ')');
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<script type="text/html" data-template-name="periph-hs30xx">
|
|
20
|
+
<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="HS30xx">
|
|
23
|
+
</div>
|
|
24
|
+
<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)
|
|
27
|
+
</div>
|
|
28
|
+
<div class="form-row">
|
|
29
|
+
<label for="node-input-address"><i class="fa fa-microchip"></i> I²C address</label>
|
|
30
|
+
<input type="text" id="node-input-address" style="width:80px" placeholder="0x44"> (fixed, 0x44)
|
|
31
|
+
</div>
|
|
32
|
+
</script>
|
|
33
|
+
|
|
34
|
+
<script type="text/html" data-help-name="periph-hs30xx">
|
|
35
|
+
<p>Reads temperature and relative humidity from a Renesas HS3001, HS3002 or HS3003 (the HS30xx family, one
|
|
36
|
+
protocol) over I²C (fixed address 0x44) with one measurement per message.</p>
|
|
37
|
+
<h3>Inputs</h3>
|
|
38
|
+
<dl class="message-properties">
|
|
39
|
+
<dt>payload <span class="property-type">any</span></dt>
|
|
40
|
+
<dd>Any incoming message triggers one measurement (request, 40 ms wait, data fetch).</dd>
|
|
41
|
+
</dl>
|
|
42
|
+
<h3>Outputs</h3>
|
|
43
|
+
<dl class="message-properties">
|
|
44
|
+
<dt>payload.temperature_c <span class="property-type">number</span></dt>
|
|
45
|
+
<dd>Temperature in °C.</dd>
|
|
46
|
+
<dt>payload.humidity_pct <span class="property-type">number</span></dt>
|
|
47
|
+
<dd>Relative humidity in %RH (0 to 100).</dd>
|
|
48
|
+
</dl>
|
|
49
|
+
<h3>Configuration</h3>
|
|
50
|
+
<p>I²C bus number and I²C address (0x44). The node reads at the factory resolution (14 bit) and does not touch the
|
|
51
|
+
sensor's NVM; send no more than one message per second to keep self-heating low. A reading whose status bits
|
|
52
|
+
still report stale data after one retry raises an error.</p>
|
|
53
|
+
</script>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function(RED) {
|
|
4
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
|
+
const { HS30xxMinimal } = require('periph/src/chips/humidity/hs30xx');
|
|
6
|
+
|
|
7
|
+
function HS30xxNode(config) {
|
|
8
|
+
RED.nodes.createNode(this, config);
|
|
9
|
+
const node = this;
|
|
10
|
+
try {
|
|
11
|
+
const address = parseInt(config.address, 16) || 0x44;
|
|
12
|
+
const connection = new I2CConnection(parseInt(config.bus), address);
|
|
13
|
+
node.connection = connection;
|
|
14
|
+
node.driver = new HS30xxMinimal(connection);
|
|
15
|
+
} catch (e) {
|
|
16
|
+
node.error('HS30xx init failed: ' + e.message);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
node.on('input', async function(msg, send, done) {
|
|
20
|
+
if (!node.driver) {
|
|
21
|
+
node.error('HS30xx not initialised', msg);
|
|
22
|
+
done();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
msg.payload = await node.driver.read();
|
|
27
|
+
send(msg);
|
|
28
|
+
done();
|
|
29
|
+
} catch (e) {
|
|
30
|
+
done(e);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
node.on('close', function() {
|
|
35
|
+
if (node.connection) node.connection.close();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
RED.nodes.registerType('periph-hs30xx', HS30xxNode);
|
|
39
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<script type="text/javascript">
|
|
2
|
+
RED.nodes.registerType('periph-hs40xx', {
|
|
3
|
+
category: 'Peripheral',
|
|
4
|
+
color: '#C084FC',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
|
+
address: { value: '0x54' },
|
|
9
|
+
resolution: { value: '14' }
|
|
10
|
+
},
|
|
11
|
+
inputs: 1,
|
|
12
|
+
outputs: 1,
|
|
13
|
+
icon: 'bridge.svg',
|
|
14
|
+
label: function() {
|
|
15
|
+
return this.name || ('HS40xx @ ' + this.address + ' (bus ' + this.bus + ')');
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script type="text/html" data-template-name="periph-hs40xx">
|
|
21
|
+
<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="HS40xx">
|
|
24
|
+
</div>
|
|
25
|
+
<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)
|
|
28
|
+
</div>
|
|
29
|
+
<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="0x54"> (fixed, 0x54)
|
|
32
|
+
</div>
|
|
33
|
+
<div class="form-row">
|
|
34
|
+
<label for="node-input-resolution"><i class="fa fa-sliders"></i> Resolution</label>
|
|
35
|
+
<select id="node-input-resolution" style="width:100px">
|
|
36
|
+
<option value="8">8 bit</option>
|
|
37
|
+
<option value="10">10 bit</option>
|
|
38
|
+
<option value="12">12 bit</option>
|
|
39
|
+
<option value="14">14 bit</option>
|
|
40
|
+
</select> (humidity and temperature)
|
|
41
|
+
</div>
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<script type="text/html" data-help-name="periph-hs40xx">
|
|
45
|
+
<p>Reads temperature and relative humidity from a Renesas HS4001 or HS4003 (the HS40xx family, one protocol)
|
|
46
|
+
over I²C (fixed address 0x54) with one no-hold measurement per message. HS4002 and the HS401x variants are
|
|
47
|
+
physically different versions of the same part and are not offered separately.</p>
|
|
48
|
+
<h3>Inputs</h3>
|
|
49
|
+
<dl class="message-properties">
|
|
50
|
+
<dt>payload <span class="property-type">any</span></dt>
|
|
51
|
+
<dd>Any incoming message triggers one measurement (command 0xF5, 3 ms wait, 5-byte read, CRC check).</dd>
|
|
52
|
+
</dl>
|
|
53
|
+
<h3>Outputs</h3>
|
|
54
|
+
<dl class="message-properties">
|
|
55
|
+
<dt>payload.temperature_c <span class="property-type">number</span></dt>
|
|
56
|
+
<dd>Temperature in °C.</dd>
|
|
57
|
+
<dt>payload.humidity_pct <span class="property-type">number</span></dt>
|
|
58
|
+
<dd>Relative humidity in %RH (0 to 100).</dd>
|
|
59
|
+
</dl>
|
|
60
|
+
<h3>Configuration</h3>
|
|
61
|
+
<p>I²C bus number, I²C address (0x54) and the measurement resolution (8, 10, 12 or 14 bit for humidity and
|
|
62
|
+
temperature). A resolution other than 14 bit is written to the sensor before the first measurement; the
|
|
63
|
+
registers are volatile and return to 14 bit whenever the sensor loses power. A measurement whose CRC is wrong
|
|
64
|
+
after one retry raises an error.</p>
|
|
65
|
+
</script>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function(RED) {
|
|
4
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
|
+
const { HS40xxFull } = require('periph/src/chips/humidity/hs40xx');
|
|
6
|
+
|
|
7
|
+
function HS40xxNode(config) {
|
|
8
|
+
RED.nodes.createNode(this, config);
|
|
9
|
+
const node = this;
|
|
10
|
+
try {
|
|
11
|
+
const address = parseInt(config.address, 16) || 0x54;
|
|
12
|
+
const connection = new I2CConnection(parseInt(config.bus), address);
|
|
13
|
+
node.connection = connection;
|
|
14
|
+
node.driver = new HS40xxFull(connection);
|
|
15
|
+
} catch (e) {
|
|
16
|
+
node.error('HS40xx init failed: ' + e.message);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
node.on('input', async function(msg, send, done) {
|
|
20
|
+
if (!node.driver) {
|
|
21
|
+
node.error('HS40xx not initialised', msg);
|
|
22
|
+
done();
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
if (!node.resolutionSet) {
|
|
27
|
+
const bits = parseInt(config.resolution) || 14;
|
|
28
|
+
if (bits !== 14) await node.driver.setResolution(bits, bits);
|
|
29
|
+
node.resolutionSet = true;
|
|
30
|
+
}
|
|
31
|
+
msg.payload = await node.driver.read();
|
|
32
|
+
send(msg);
|
|
33
|
+
done();
|
|
34
|
+
} catch (e) {
|
|
35
|
+
done(e);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
node.on('close', function() {
|
|
40
|
+
if (node.connection) node.connection.close();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
RED.nodes.registerType('periph-hs40xx', HS40xxNode);
|
|
44
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-periph-humidity",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "Node-RED nodes for humidity sensor chips",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node-red",
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
"node-red": {
|
|
14
14
|
"nodes": {
|
|
15
15
|
"dht11": "nodes/dht11/dht11.js",
|
|
16
|
+
"hdc1008": "nodes/hdc1008/hdc1008.js",
|
|
17
|
+
"hdc1080": "nodes/hdc1080/hdc1080.js",
|
|
18
|
+
"hs30xx": "nodes/hs30xx/hs30xx.js",
|
|
19
|
+
"hs40xx": "nodes/hs40xx/hs40xx.js",
|
|
16
20
|
"htu21df": "nodes/htu21df/htu21df.js",
|
|
17
21
|
"sht31": "nodes/sht31/sht31.js",
|
|
18
22
|
"si7021": "nodes/si7021/si7021.js"
|