node-red-contrib-periph-pressure 1.5.4 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # node-red-contrib-periph-pressure
2
2
 
3
- Node-RED nodes for pressure sensor chips: BMP085, BMP180, BMP280, BMP384, BMP581, LPS22DF, LPS22HB, LPS28DFW, LPS33HW, MPL115A2, MPL3115A2, MS5607, MS5611 — part of the [Periph](https://github.com/tuhde/Periph) library.
3
+ Node-RED nodes for pressure sensor chips: BMP085, BMP180, BMP280, BMP384, BMP581, LPS22DF, LPS22HB, LPS28DFW, LPS33HW, MPL115A2, MPL3115A2, MS5607, MS5611, SPL06 — part of the [Periph](https://github.com/tuhde/Periph) library.
4
4
 
5
- **Supported chips (13):** BMP085, BMP180, BMP280, BMP384, BMP581, LPS22DF, LPS22HB, LPS28DFW, LPS33HW, MPL115A2, MPL3115A2, MS5607, MS5611.
5
+ **Supported chips (14):** BMP085, BMP180, BMP280, BMP384, BMP581, LPS22DF, LPS22HB, LPS28DFW, LPS33HW, MPL115A2, MPL3115A2, MS5607, MS5611, SPL06.
6
6
 
7
7
  Each chip has a sensor/actuator node plus a shared `-device` config node that holds the bus settings. Importable example flows are in [`examples/`](https://github.com/tuhde/Periph/tree/main/nodejs/packages/node-red-contrib-periph-pressure/examples).
8
8
 
@@ -46,6 +46,8 @@ npm install node-red-contrib-periph-pressure
46
46
  | `ms5607` | input | Reads temperature and barometric pressure from a TE Connectivity MS5607 over I²C (address 0x77, or 0x76 with CSB high). Each message converts the temperature and then the pressure and applies the first- and second-order compensation. |
47
47
  | `ms5611-device` | config | I²C bus and address for a MS5611 |
48
48
  | `ms5611` | input | Reads temperature and barometric pressure from a TE Connectivity MS5611 over I²C (address 0x77, or 0x76 with CSB high). Each message converts the temperature and then the pressure and applies the first- and second-order compensation. |
49
+ | `spl06-device` | config | I²C bus and address for a SPL06 |
50
+ | `spl06` | input | Reads temperature and absolute pressure from a Goertek SPL06-007 over I²C (address 0x77 or 0x76), one compensated measurement per message. |
49
51
 
50
52
  ## Links
51
53
 
@@ -0,0 +1,136 @@
1
+ [
2
+ {
3
+ "id": "spl06-tab",
4
+ "type": "tab",
5
+ "label": "SPL06 altimeter",
6
+ "disabled": false,
7
+ "info": "Barometric altimeter with an SPL06-007. An inject node fires every 2 s and triggers one temperature and pressure measurement. A function node converts the pressure into altitude with the international barometric formula (reference 101325 Pa, editable in the function) and feeds a dashboard gauge; the debug node shows the full reading in pascals, degrees Celsius and metres."
8
+ },
9
+ {
10
+ "id": "spl06-inject",
11
+ "type": "inject",
12
+ "z": "spl06-tab",
13
+ "name": "every 2 s",
14
+ "props": [
15
+ {
16
+ "p": "payload"
17
+ }
18
+ ],
19
+ "repeat": "2",
20
+ "crontab": "",
21
+ "once": true,
22
+ "onceDelay": 0.5,
23
+ "topic": "",
24
+ "payloadType": "date",
25
+ "x": 150,
26
+ "y": 160,
27
+ "wires": [
28
+ [
29
+ "spl06-node"
30
+ ]
31
+ ]
32
+ },
33
+ {
34
+ "id": "spl06-device-1",
35
+ "type": "spl06-device",
36
+ "name": "SPL06",
37
+ "bus": "1",
38
+ "address": "0x77",
39
+ "oversampling": "16"
40
+ },
41
+ {
42
+ "id": "spl06-node",
43
+ "type": "spl06",
44
+ "z": "spl06-tab",
45
+ "name": "SPL06",
46
+ "device": "spl06-device-1",
47
+ "x": 340,
48
+ "y": 160,
49
+ "wires": [
50
+ [
51
+ "spl06-altitude"
52
+ ]
53
+ ]
54
+ },
55
+ {
56
+ "id": "spl06-altitude",
57
+ "type": "function",
58
+ "z": "spl06-tab",
59
+ "name": "Altitude",
60
+ "func": "const seaLevelPa = 101325;\nconst p = msg.payload.pressure_pa;\nmsg.payload.altitude_m = 44330 * (1 - Math.pow(p / seaLevelPa, 1 / 5.255));\nreturn [msg, { payload: Math.round(msg.payload.altitude_m * 10) / 10 }];",
61
+ "outputs": 2,
62
+ "noerr": 0,
63
+ "initialize": "",
64
+ "finalize": "",
65
+ "libs": [],
66
+ "x": 530,
67
+ "y": 160,
68
+ "wires": [
69
+ [
70
+ "spl06-debug"
71
+ ],
72
+ [
73
+ "spl06-gauge"
74
+ ]
75
+ ]
76
+ },
77
+ {
78
+ "id": "spl06-debug",
79
+ "type": "debug",
80
+ "z": "spl06-tab",
81
+ "name": "Reading",
82
+ "active": true,
83
+ "tosidebar": true,
84
+ "console": false,
85
+ "tostatus": false,
86
+ "complete": "payload",
87
+ "targetType": "msg",
88
+ "statusVal": "",
89
+ "statusType": "auto",
90
+ "x": 740,
91
+ "y": 120,
92
+ "wires": []
93
+ },
94
+ {
95
+ "id": "spl06-gauge",
96
+ "type": "ui_gauge",
97
+ "z": "spl06-tab",
98
+ "name": "Altitude gauge",
99
+ "group": "spl06-group-1",
100
+ "order": 1,
101
+ "width": 6,
102
+ "height": 4,
103
+ "gtype": "gage",
104
+ "title": "Altitude",
105
+ "label": "m",
106
+ "format": "{{value}}",
107
+ "min": -100,
108
+ "max": 1000,
109
+ "colors": [
110
+ "#00b500",
111
+ "#e6e600",
112
+ "#ca3838"
113
+ ],
114
+ "seg1": "",
115
+ "seg2": "",
116
+ "x": 750,
117
+ "y": 200,
118
+ "wires": []
119
+ },
120
+ {
121
+ "id": "spl06-group-1",
122
+ "type": "ui_group",
123
+ "name": "SPL06 Altimeter",
124
+ "tab": "spl06-ui-tab-1",
125
+ "order": 1,
126
+ "disp": true,
127
+ "width": 6
128
+ },
129
+ {
130
+ "id": "spl06-ui-tab-1",
131
+ "type": "ui_tab",
132
+ "name": "SPL06 Demo",
133
+ "icon": "dashboard",
134
+ "order": 1
135
+ }
136
+ ]
@@ -0,0 +1,98 @@
1
+ <!-- Config node: one instance per physical device -->
2
+ <script type="text/javascript">
3
+ RED.nodes.registerType('spl06-device', {
4
+ category: 'config',
5
+ defaults: {
6
+ name: { value: '' },
7
+ bus: { value: '1', required: true, validate: RED.validators.number() },
8
+ address: { value: '0x77' },
9
+ oversampling: { value: '16' }
10
+ },
11
+ label: function() {
12
+ return this.name || ('SPL06 @ ' + this.address + ' (bus ' + this.bus + ')');
13
+ }
14
+ });
15
+ </script>
16
+
17
+ <script type="text/html" data-template-name="spl06-device">
18
+ <div class="form-row">
19
+ <label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
20
+ <input type="text" id="node-config-input-name" placeholder="SPL06">
21
+ </div>
22
+ <div class="form-row">
23
+ <label for="node-config-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
24
+ <input type="number" id="node-config-input-bus" min="0" style="width:80px"> &nbsp;(Linux /dev/i2c-N)
25
+ </div>
26
+ <div class="form-row">
27
+ <label for="node-config-input-address"><i class="fa fa-microchip"></i> I²C address</label>
28
+ <select id="node-config-input-address" style="width:120px">
29
+ <option value="0x77" selected>0x77 (SDO high / open)</option>
30
+ <option value="0x76">0x76 (SDO low)</option>
31
+ </select>
32
+ </div>
33
+ <div class="form-row">
34
+ <label for="node-config-input-oversampling"><i class="fa fa-cog"></i> Pressure oversampling</label>
35
+ <select id="node-config-input-oversampling" style="width:120px">
36
+ <option value="1">1×</option><option value="2">2×</option><option value="4">4×</option>
37
+ <option value="8">8×</option><option value="16" selected>16×</option><option value="32">32×</option>
38
+ <option value="64">64×</option><option value="128">128×</option>
39
+ </select>
40
+ </div>
41
+ </script>
42
+
43
+ <!-- Read node -->
44
+ <script type="text/javascript">
45
+ RED.nodes.registerType('spl06', {
46
+ category: 'Peripheral',
47
+ color: '#C084FC',
48
+ defaults: {
49
+ name: { value: '' },
50
+ device: { value: '', type: 'spl06-device', required: true }
51
+ },
52
+ inputs: 1,
53
+ outputs: 1,
54
+ icon: 'bridge.svg',
55
+ label: function() { return this.name || 'SPL06'; },
56
+ paletteLabel: 'SPL06'
57
+ });
58
+ </script>
59
+
60
+ <script type="text/html" data-template-name="spl06">
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="SPL06">
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="spl06">
72
+ <p>Reads temperature and absolute pressure from a Goertek SPL06-007 over I²C (address 0x77 or 0x76),
73
+ one compensated measurement per message.</p>
74
+ <h3>Inputs</h3>
75
+ <dl class="message-properties">
76
+ <dt>payload <span class="property-type">any</span></dt>
77
+ <dd>Any incoming message triggers one temperature and one pressure measurement.</dd>
78
+ </dl>
79
+ <h3>Outputs</h3>
80
+ <dl class="message-properties">
81
+ <dt>payload.temperature_c <span class="property-type">number</span></dt>
82
+ <dd>Temperature in degrees Celsius.</dd>
83
+ <dt>payload.pressure_pa <span class="property-type">number</span></dt>
84
+ <dd>Absolute pressure in pascals.</dd>
85
+ </dl>
86
+ <h3>Configuration</h3>
87
+ <dl class="message-properties">
88
+ <dt>I²C bus <span class="property-type">number</span></dt>
89
+ <dd>Linux bus number N of <code>/dev/i2c-N</code>.</dd>
90
+ <dt>I²C address <span class="property-type">0x76 | 0x77</span></dt>
91
+ <dd>0x77 with SDO high or open (default), 0x76 with SDO low.</dd>
92
+ <dt>Pressure oversampling <span class="property-type">1–128</span></dt>
93
+ <dd>More oversampling lowers the noise (16× ≈ 0.5 Pa RMS) but lengthens each measurement
94
+ (16×: about 28 ms, 128×: about 207 ms). The temperature always uses the external sensor at 1×.</dd>
95
+ </dl>
96
+ <h3>Details</h3>
97
+ <p>The chip stays in standby between messages. Its calibration coefficients are read once at start-up.</p>
98
+ </script>
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ module.exports = function(RED) {
4
+ const { I2CConnection } = require('periph/src/connection/i2c');
5
+ const { SPL06Full } = require('periph/src/chips/pressure/spl06');
6
+
7
+ function SPL06DeviceNode(config) {
8
+ RED.nodes.createNode(this, config);
9
+ const node = this;
10
+ try {
11
+ const address = parseInt(config.address, 16) || 0x77;
12
+ const connection = new I2CConnection(parseInt(config.bus), address);
13
+ node.connection = connection;
14
+ node.driver = new SPL06Full(connection);
15
+ node.ready = (async () => {
16
+ await node.driver.init();
17
+ const osr = parseInt(config.oversampling);
18
+ await node.driver.setPressureConfig(isNaN(osr) ? 16 : osr, 1);
19
+ })();
20
+ node.ready.catch((e) => {
21
+ node.error('SPL06 init failed: ' + e.message);
22
+ });
23
+ } catch (e) {
24
+ node.error('SPL06 init failed: ' + e.message);
25
+ }
26
+
27
+ node.on('close', function() {
28
+ if (node.connection) node.connection.close();
29
+ });
30
+ }
31
+ RED.nodes.registerType('spl06-device', SPL06DeviceNode);
32
+
33
+ function SPL06ReadNode(config) {
34
+ RED.nodes.createNode(this, config);
35
+ const node = this;
36
+ const deviceNode = RED.nodes.getNode(config.device) || {};
37
+
38
+ node.on('input', async function(msg, send, done) {
39
+ if (!deviceNode.driver) {
40
+ node.error('SPL06 not initialised', msg);
41
+ done();
42
+ return;
43
+ }
44
+ try {
45
+ await deviceNode.ready;
46
+ const { temperature_c, pressure_pa } = await deviceNode.driver.read();
47
+ msg.payload = { temperature_c, pressure_pa };
48
+ send(msg);
49
+ done();
50
+ } catch (e) {
51
+ done(e);
52
+ }
53
+ });
54
+ }
55
+ RED.nodes.registerType('spl06', SPL06ReadNode);
56
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "node-red-contrib-periph-pressure",
3
- "version": "1.5.4",
4
- "description": "Node-RED nodes for pressure sensor chips: BMP085, BMP180, BMP280, BMP384, BMP581, LPS22DF, LPS22HB, LPS28DFW, LPS33HW, MPL115A2, MPL3115A2, MS5607, MS5611",
3
+ "version": "1.6.0",
4
+ "description": "Node-RED nodes for pressure sensor chips: BMP085, BMP180, BMP280, BMP384, BMP581, LPS22DF, LPS22HB, LPS28DFW, LPS33HW, MPL115A2, MPL3115A2, MS5607, MS5611, SPL06",
5
5
  "keywords": [
6
6
  "node-red",
7
7
  "pressure",
@@ -22,7 +22,8 @@
22
22
  "mpl115a2",
23
23
  "mpl3115a2",
24
24
  "ms5607",
25
- "ms5611"
25
+ "ms5611",
26
+ "spl06"
26
27
  ],
27
28
  "node-red": {
28
29
  "version": ">=3.0.0",
@@ -39,7 +40,8 @@
39
40
  "mpl115a2": "nodes/mpl115a2/mpl115a2.js",
40
41
  "mpl3115a2": "nodes/mpl3115a2/mpl3115a2.js",
41
42
  "ms5607": "nodes/ms5607/ms5607.js",
42
- "ms5611": "nodes/ms5611/ms5611.js"
43
+ "ms5611": "nodes/ms5611/ms5611.js",
44
+ "spl06": "nodes/spl06/spl06.js"
43
45
  }
44
46
  },
45
47
  "dependencies": {