node-red-contrib-periph-pressure 1.1.0 → 1.2.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.
@@ -0,0 +1,93 @@
1
+ <!-- Config node: one instance per physical device -->
2
+ <script type="text/javascript">
3
+ RED.nodes.registerType('bmp085-device', {
4
+ category: 'config',
5
+ defaults: {
6
+ name: { value: '' },
7
+ bus: { value: '1', required: true, validate: RED.validators.number() },
8
+ oss: { value: '0', required: true, validate: RED.validators.number() }
9
+ },
10
+ label: function() {
11
+ return this.name || ('BMP085 @ 0x77 (bus ' + this.bus + ')');
12
+ }
13
+ });
14
+ </script>
15
+
16
+ <script type="text/html" data-template-name="bmp085-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="BMP085">
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"> &nbsp;(Linux /dev/i2c-N)
24
+ </div>
25
+ <div class="form-row">
26
+ <label for="node-config-input-oss">Oversampling mode</label>
27
+ <select id="node-config-input-oss" style="width:180px">
28
+ <option value="0">ULP (4.5 ms)</option>
29
+ <option value="1">Standard (7.5 ms)</option>
30
+ <option value="2">High Resolution (13.5 ms)</option>
31
+ <option value="3">Ultra High Resolution (25.5 ms)</option>
32
+ </select>
33
+ </div>
34
+ </script>
35
+
36
+ <!-- Read node: trigger → measurements -->
37
+ <script type="text/javascript">
38
+ RED.nodes.registerType('periph-bmp085', {
39
+ category: 'Peripheral',
40
+ color: '#C084FC',
41
+ defaults: {
42
+ name: { value: '' },
43
+ device: { value: '', type: 'bmp085-device', required: true },
44
+ seaLevelPa: { value: '101325' }
45
+ },
46
+ inputs: 1,
47
+ outputs: 1,
48
+ icon: 'font-awesome/fa-tachometer',
49
+ label: function() { return this.name || 'BMP085'; },
50
+ paletteLabel: 'BMP085'
51
+ });
52
+ </script>
53
+
54
+ <script type="text/html" data-template-name="periph-bmp085">
55
+ <div class="form-row">
56
+ <label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
57
+ <input type="text" id="node-input-device">
58
+ </div>
59
+ <div class="form-row">
60
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
61
+ <input type="text" id="node-input-name" placeholder="BMP085">
62
+ </div>
63
+ <div class="form-row">
64
+ <label for="node-input-seaLevelPa">Sea-level pressure (Pa)</label>
65
+ <input type="number" id="node-input-seaLevelPa" min="80000" max="110000" step="100" style="width:100px">
66
+ </div>
67
+ </script>
68
+
69
+ <script type="text/html" data-help-name="periph-bmp085">
70
+ <p>Reads temperature and pressure from a BMP085 barometric pressure sensor over I²C.</p>
71
+ <p>Any input message triggers a measurement. The device is configured via a <b>bmp085-device</b> config node.</p>
72
+
73
+ <h3>Inputs</h3>
74
+ <dl class="message-properties">
75
+ <dt>payload <span class="property-type">any</span></dt>
76
+ <dd>Any incoming message triggers a measurement.</dd>
77
+ </dl>
78
+
79
+ <h3>Outputs</h3>
80
+ <dl class="message-properties">
81
+ <dt>payload.temperature <span class="property-type">number</span></dt>
82
+ <dd>Temperature in degrees Celsius.</dd>
83
+ <dt>payload.pressure <span class="property-type">number</span></dt>
84
+ <dd>Pressure in pascals.</dd>
85
+ <dt>payload.altitude <span class="property-type">number</span></dt>
86
+ <dd>Altitude in metres computed from the configured sea-level pressure.</dd>
87
+ </dl>
88
+
89
+ <h3>Configuration</h3>
90
+ <p>Set the I²C bus number and oversampling mode in the device config node.
91
+ The sea-level reference pressure defaults to <code>101325</code> Pa and can be
92
+ adjusted in the read node config panel.</p>
93
+ </script>
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ module.exports = function(RED) {
4
+ const { I2CConnection } = require('periph/src/connection/i2c');
5
+ const { BMP085Full } = require('periph/src/chips/pressure/bmp085');
6
+
7
+ function BMP085DeviceNode(config) {
8
+ RED.nodes.createNode(this, config);
9
+ const node = this;
10
+ try {
11
+ const connection = new I2CConnection(parseInt(config.bus), 0x77);
12
+ node.driver = new BMP085Full(connection, parseInt(config.oss) || 0);
13
+ node.connection = connection;
14
+ } catch (e) {
15
+ node.error('BMP085 init failed: ' + e.message);
16
+ }
17
+ node.on('close', function() {
18
+ if (node.connection) node.connection.close();
19
+ });
20
+ }
21
+ RED.nodes.registerType('bmp085-device', BMP085DeviceNode);
22
+
23
+ function BMP085ReadNode(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 BMP085 device configured', msg);
31
+ done();
32
+ return;
33
+ }
34
+ try {
35
+ const d = node.device.driver;
36
+ msg.payload = {
37
+ temperature: await d.temperature(),
38
+ pressure: await d.pressure(),
39
+ altitude: await d.altitude(parseFloat(config.seaLevelPa) || 101325.0)
40
+ };
41
+ send(msg);
42
+ done();
43
+ } catch (e) {
44
+ done(e);
45
+ }
46
+ });
47
+ }
48
+ RED.nodes.registerType('periph-bmp085', BMP085ReadNode);
49
+ };
@@ -37,7 +37,7 @@
37
37
  <script type="text/javascript">
38
38
  RED.nodes.registerType('periph-bmp180', {
39
39
  category: 'Peripheral',
40
- color: '#a6bbcf',
40
+ color: '#C084FC',
41
41
  defaults: {
42
42
  name: { value: '' },
43
43
  device: { value: '', type: 'bmp180-device', required: true },
@@ -67,7 +67,7 @@
67
67
  </script>
68
68
 
69
69
  <script type="text/html" data-help-name="periph-bmp180">
70
- <p>Reads bus voltage, load current, and power from an INA219 power monitor.</p>
70
+ <p>Reads temperature and pressure from a BMP180 barometric pressure sensor over I²C.</p>
71
71
  <p>Any input message triggers a measurement. The device is configured via a <b>bmp180-device</b> config node.</p>
72
72
 
73
73
  <h3>Inputs</h3>
@@ -1,21 +1,21 @@
1
1
  'use strict';
2
2
 
3
3
  module.exports = function(RED) {
4
- const { I2CTransport } = require('periph/src/transport/i2c');
4
+ const { I2CConnection } = require('periph/src/connection/i2c');
5
5
  const { BMP180Full } = require('periph/src/chips/pressure/bmp180');
6
6
 
7
7
  function BMP180DeviceNode(config) {
8
8
  RED.nodes.createNode(this, config);
9
9
  const node = this;
10
10
  try {
11
- const transport = new I2CTransport(parseInt(config.bus), 0x77);
12
- node.driver = new BMP180Full(transport, parseInt(config.oss) || 0);
13
- node.transport = transport;
11
+ const connection = new I2CConnection(parseInt(config.bus), 0x77);
12
+ node.driver = new BMP180Full(connection, parseInt(config.oss) || 0);
13
+ node.connection = connection;
14
14
  } catch (e) {
15
15
  node.error('BMP180 init failed: ' + e.message);
16
16
  }
17
17
  node.on('close', function() {
18
- if (node.transport) node.transport.close();
18
+ if (node.connection) node.connection.close();
19
19
  });
20
20
  }
21
21
  RED.nodes.registerType('bmp180-device', BMP180DeviceNode);
@@ -25,7 +25,7 @@ module.exports = function(RED) {
25
25
  const node = this;
26
26
  node.device = RED.nodes.getNode(config.device);
27
27
 
28
- node.on('input', function(msg, send, done) {
28
+ node.on('input', async function(msg, send, done) {
29
29
  if (!node.device || !node.device.driver) {
30
30
  node.error('No BMP180 device configured', msg);
31
31
  done();
@@ -34,9 +34,9 @@ module.exports = function(RED) {
34
34
  try {
35
35
  const d = node.device.driver;
36
36
  msg.payload = {
37
- temperature: d.temperature(),
38
- pressure: d.pressure(),
39
- altitude: d.altitude(parseFloat(config.seaLevelHpa) || 1013.25)
37
+ temperature: await d.temperature(),
38
+ pressure: await d.pressure(),
39
+ altitude: await d.altitude(parseFloat(config.seaLevelHpa) || 1013.25)
40
40
  };
41
41
  send(msg);
42
42
  done();
@@ -92,7 +92,7 @@
92
92
  <script type="text/javascript">
93
93
  RED.nodes.registerType('periph-bmp280', {
94
94
  category: 'Peripheral',
95
- color: '#a6bbcf',
95
+ color: '#C084FC',
96
96
  defaults: {
97
97
  name: { value: '' },
98
98
  device: { value: '', type: 'bmp280-device', required: true },
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  module.exports = function(RED) {
4
- const { I2CTransport } = require('periph/src/transport/i2c');
4
+ const { I2CConnection } = require('periph/src/connection/i2c');
5
5
  const { BMP280Full } = require('periph/src/chips/pressure/bmp280');
6
6
 
7
7
  function BMP280DeviceNode(config) {
@@ -9,8 +9,8 @@ module.exports = function(RED) {
9
9
  const node = this;
10
10
  try {
11
11
  const addr = parseInt(config.addr) || 0x76;
12
- const transport = new I2CTransport(parseInt(config.bus), addr);
13
- node.driver = new BMP280Full(transport);
12
+ const connection = new I2CConnection(parseInt(config.bus), addr);
13
+ node.driver = new BMP280Full(connection);
14
14
  node.driver.configure(
15
15
  parseInt(config.osrsT) || 1,
16
16
  parseInt(config.osrsP) || 1,
@@ -18,12 +18,12 @@ module.exports = function(RED) {
18
18
  parseInt(config.filter) || 0,
19
19
  parseInt(config.tSb) || 0
20
20
  );
21
- node.transport = transport;
21
+ node.connection = connection;
22
22
  } catch (e) {
23
23
  node.error('BMP280 init failed: ' + e.message);
24
24
  }
25
25
  node.on('close', function() {
26
- if (node.transport) node.transport.close();
26
+ if (node.connection) node.connection.close();
27
27
  });
28
28
  }
29
29
  RED.nodes.registerType('bmp280-device', BMP280DeviceNode);
@@ -33,7 +33,7 @@ module.exports = function(RED) {
33
33
  const node = this;
34
34
  node.device = RED.nodes.getNode(config.device);
35
35
 
36
- node.on('input', function(msg, send, done) {
36
+ node.on('input', async function(msg, send, done) {
37
37
  if (!node.device || !node.device.driver) {
38
38
  node.error('No BMP280 device configured', msg);
39
39
  done();
@@ -42,9 +42,9 @@ module.exports = function(RED) {
42
42
  try {
43
43
  const d = node.device.driver;
44
44
  msg.payload = {
45
- temperature: d.temperature(),
46
- pressure: d.pressure(),
47
- altitude: d.altitude(parseFloat(config.seaLevelHpa) || 1013.25)
45
+ temperature: await d.temperature(),
46
+ pressure: await d.pressure(),
47
+ altitude: await d.altitude(parseFloat(config.seaLevelHpa) || 1013.25)
48
48
  };
49
49
  send(msg);
50
50
  done();
@@ -0,0 +1,150 @@
1
+ <!-- Config node: one instance per physical device -->
2
+ <script type="text/javascript">
3
+ RED.nodes.registerType('bmp384-device', {
4
+ category: 'config',
5
+ defaults: {
6
+ name: { value: '' },
7
+ bus: { value: '1', required: true, validate: RED.validators.number() },
8
+ addr: { value: '0x76', required: true },
9
+ osrP: { value: '4', required: true, validate: RED.validators.number() },
10
+ osrT: { value: '1', required: true, validate: RED.validators.number() },
11
+ iir: { value: '2', required: true, validate: RED.validators.number() },
12
+ odr: { value: '3', required: true, validate: RED.validators.number() }
13
+ },
14
+ label: function() {
15
+ return this.name || ('BMP384 @ ' + this.addr + ' (bus ' + this.bus + ')');
16
+ }
17
+ });
18
+ </script>
19
+
20
+ <script type="text/html" data-template-name="bmp384-device">
21
+ <div class="form-row">
22
+ <label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
23
+ <input type="text" id="node-config-input-name" placeholder="BMP384">
24
+ </div>
25
+ <div class="form-row">
26
+ <label for="node-config-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
27
+ <input type="number" id="node-config-input-bus" min="0" style="width:80px"> &nbsp;(Linux /dev/i2c-N)
28
+ </div>
29
+ <div class="form-row">
30
+ <label for="node-config-input-addr"><i class="fa fa-microchip"></i> I²C address</label>
31
+ <select id="node-config-input-addr" style="width:100px">
32
+ <option value="0x76">0x76 (SDO=GND)</option>
33
+ <option value="0x77">0x77 (SDO=VDD)</option>
34
+ </select>
35
+ </div>
36
+ <div class="form-row">
37
+ <label for="node-config-input-osrT">Temperature oversampling</label>
38
+ <select id="node-config-input-osrT" style="width:180px">
39
+ <option value="0">×1</option>
40
+ <option value="1" selected>×2</option>
41
+ <option value="2">×4</option>
42
+ <option value="3">×8</option>
43
+ <option value="4">×16</option>
44
+ <option value="5">×32</option>
45
+ </select>
46
+ </div>
47
+ <div class="form-row">
48
+ <label for="node-config-input-osrP">Pressure oversampling</label>
49
+ <select id="node-config-input-osrP" style="width:180px">
50
+ <option value="0">×1</option>
51
+ <option value="1">×2</option>
52
+ <option value="2">×4</option>
53
+ <option value="3">×8</option>
54
+ <option value="4" selected>×16</option>
55
+ <option value="5">×32</option>
56
+ </select>
57
+ </div>
58
+ <div class="form-row">
59
+ <label for="node-config-input-iir">IIR filter coefficient</label>
60
+ <select id="node-config-input-iir" style="width:180px">
61
+ <option value="0">Off</option>
62
+ <option value="1">1</option>
63
+ <option value="2" selected>3</option>
64
+ <option value="3">7</option>
65
+ <option value="4">15</option>
66
+ <option value="5">31</option>
67
+ <option value="6">63</option>
68
+ <option value="7">127</option>
69
+ </select>
70
+ </div>
71
+ <div class="form-row">
72
+ <label for="node-config-input-odr">Output data rate</label>
73
+ <select id="node-config-input-odr" style="width:180px">
74
+ <option value="0">200 Hz</option>
75
+ <option value="1">100 Hz</option>
76
+ <option value="2">50 Hz</option>
77
+ <option value="3" selected>25 Hz</option>
78
+ <option value="4">12.5 Hz</option>
79
+ <option value="5">6.25 Hz</option>
80
+ <option value="6">3.1 Hz</option>
81
+ <option value="7">1.5 Hz</option>
82
+ <option value="8">0.78 Hz</option>
83
+ <option value="9">0.39 Hz</option>
84
+ <option value="10">0.2 Hz</option>
85
+ <option value="11">0.1 Hz</option>
86
+ <option value="12">0.05 Hz</option>
87
+ </select>
88
+ </div>
89
+ </script>
90
+
91
+ <!-- Read node: trigger → measurements -->
92
+ <script type="text/javascript">
93
+ RED.nodes.registerType('periph-bmp384', {
94
+ category: 'Peripheral',
95
+ color: '#C084FC',
96
+ defaults: {
97
+ name: { value: '' },
98
+ device: { value: '', type: 'bmp384-device', required: true },
99
+ seaLevelHpa: { value: '1013.25' }
100
+ },
101
+ inputs: 1,
102
+ outputs: 1,
103
+ icon: 'font-awesome/fa-tachometer',
104
+ label: function() { return this.name || 'BMP384'; },
105
+ paletteLabel: 'BMP384'
106
+ });
107
+ </script>
108
+
109
+ <script type="text/html" data-template-name="periph-bmp384">
110
+ <div class="form-row">
111
+ <label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
112
+ <input type="text" id="node-input-device">
113
+ </div>
114
+ <div class="form-row">
115
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
116
+ <input type="text" id="node-input-name" placeholder="BMP384">
117
+ </div>
118
+ <div class="form-row">
119
+ <label for="node-input-seaLevelHpa">Sea-level pressure (hPa)</label>
120
+ <input type="number" id="node-input-seaLevelHpa" min="800" max="1100" step="0.01" style="width:100px">
121
+ </div>
122
+ </script>
123
+
124
+ <script type="text/html" data-help-name="periph-bmp384">
125
+ <p>Reads temperature, pressure, and altitude from a BMP384 barometric pressure sensor.</p>
126
+ <p>Any input message triggers a measurement. The device is configured via a <b>bmp384-device</b> config node.</p>
127
+
128
+ <h3>Inputs</h3>
129
+ <dl class="message-properties">
130
+ <dt>payload <span class="property-type">any</span></dt>
131
+ <dd>Any incoming message triggers a measurement.</dd>
132
+ </dl>
133
+
134
+ <h3>Outputs</h3>
135
+ <dl class="message-properties">
136
+ <dt>payload.temperature <span class="property-type">number</span></dt>
137
+ <dd>Temperature in degrees Celsius.</dd>
138
+ <dt>payload.pressure <span class="property-type">number</span></dt>
139
+ <dd>Pressure in hectopascals (hPa).</dd>
140
+ <dt>payload.altitude <span class="property-type">number</span></dt>
141
+ <dd>Altitude in metres computed from the configured sea-level pressure.</dd>
142
+ </dl>
143
+
144
+ <h3>Configuration</h3>
145
+ <p>Set the I²C bus number, I²C address (<code>0x76</code> or <code>0x77</code>),
146
+ temperature and pressure oversampling, IIR filter coefficient, and output
147
+ data rate in the device config node. The sea-level reference pressure
148
+ defaults to <code>1013.25</code> hPa and can be adjusted in the read node
149
+ config panel.</p>
150
+ </script>
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ module.exports = function(RED) {
4
+ const { I2CConnection } = require('periph/src/connection/i2c');
5
+ const { BMP384Full } = require('periph/src/chips/pressure/bmp384');
6
+
7
+ function BMP384DeviceNode(config) {
8
+ RED.nodes.createNode(this, config);
9
+ const node = this;
10
+ try {
11
+ const addr = parseInt(config.addr) || 0x76;
12
+ const connection = new I2CConnection(parseInt(config.bus), addr);
13
+ node.driver = new BMP384Full(connection);
14
+ node.driver.configure(
15
+ parseInt(config.osrP) || 4,
16
+ parseInt(config.osrT) || 1,
17
+ parseInt(config.iir) || 2,
18
+ parseInt(config.odr) || 0x03
19
+ ).catch((e) => node.error('BMP384 configure failed: ' + e.message));
20
+ node.connection = connection;
21
+ } catch (e) {
22
+ node.error('BMP384 init failed: ' + e.message);
23
+ }
24
+ node.on('close', function() {
25
+ if (node.connection) node.connection.close();
26
+ });
27
+ }
28
+ RED.nodes.registerType('bmp384-device', BMP384DeviceNode);
29
+
30
+ function BMP384ReadNode(config) {
31
+ RED.nodes.createNode(this, config);
32
+ const node = this;
33
+ node.device = RED.nodes.getNode(config.device);
34
+
35
+ node.on('input', async function(msg, send, done) {
36
+ if (!node.device || !node.device.driver) {
37
+ node.error('No BMP384 device configured', msg);
38
+ done();
39
+ return;
40
+ }
41
+ try {
42
+ const d = node.device.driver;
43
+ msg.payload = {
44
+ temperature: await d.temperature(),
45
+ pressure: await d.pressure(),
46
+ altitude: await d.altitude(parseFloat(config.seaLevelHpa) || 1013.25)
47
+ };
48
+ send(msg);
49
+ done();
50
+ } catch (e) {
51
+ done(e);
52
+ }
53
+ });
54
+ }
55
+ RED.nodes.registerType('periph-bmp384', BMP384ReadNode);
56
+ };
@@ -0,0 +1,142 @@
1
+ <!-- Config node: one instance per physical device -->
2
+ <script type="text/javascript">
3
+ RED.nodes.registerType('bmp581-device', {
4
+ category: 'config',
5
+ defaults: {
6
+ name: { value: '' },
7
+ bus: { value: '1', required: true, validate: RED.validators.number() },
8
+ addr: { value: '0x46', required: true },
9
+ odr: { value: '28', required: true, validate: RED.validators.number() },
10
+ osrP: { value: '0', required: true, validate: RED.validators.number() },
11
+ osrT: { value: '0', required: true, validate: RED.validators.number() },
12
+ pressEn: { value: 'true' }
13
+ },
14
+ label: function() {
15
+ return this.name || ('BMP581 @ ' + this.addr + ' (bus ' + this.bus + ')');
16
+ }
17
+ });
18
+ </script>
19
+
20
+ <script type="text/html" data-template-name="bmp581-device">
21
+ <div class="form-row">
22
+ <label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
23
+ <input type="text" id="node-config-input-name" placeholder="BMP581">
24
+ </div>
25
+ <div class="form-row">
26
+ <label for="node-config-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
27
+ <input type="number" id="node-config-input-bus" min="0" style="width:80px"> &nbsp;(Linux /dev/i2c-N)
28
+ </div>
29
+ <div class="form-row">
30
+ <label for="node-config-input-addr"><i class="fa fa-microchip"></i> I²C address</label>
31
+ <select id="node-config-input-addr" style="width:100px">
32
+ <option value="0x46" selected>0x46 (SDO=GND)</option>
33
+ <option value="0x47">0x47 (SDO=VDDIO)</option>
34
+ </select>
35
+ </div>
36
+ <div class="form-row">
37
+ <label for="node-config-input-odr">Output Data Rate</label>
38
+ <select id="node-config-input-odr" style="width:180px">
39
+ <option value="0">240 Hz</option>
40
+ <option value="4">160 Hz</option>
41
+ <option value="8">120 Hz</option>
42
+ <option value="13">70 Hz</option>
43
+ <option value="14">60 Hz</option>
44
+ <option value="15">50 Hz</option>
45
+ <option value="17">10 Hz</option>
46
+ <option value="28" selected>1 Hz</option>
47
+ <option value="29">0.5 Hz</option>
48
+ <option value="30">0.25 Hz</option>
49
+ <option value="31">0.125 Hz</option>
50
+ </select>
51
+ </div>
52
+ <div class="form-row">
53
+ <label for="node-config-input-osrP">Pressure oversampling</label>
54
+ <select id="node-config-input-osrP" style="width:180px">
55
+ <option value="0" selected>×1</option>
56
+ <option value="1">×2</option>
57
+ <option value="2">×4</option>
58
+ <option value="3">×8</option>
59
+ <option value="4">×16</option>
60
+ <option value="5">×32</option>
61
+ <option value="6">×64</option>
62
+ <option value="7">×128</option>
63
+ </select>
64
+ </div>
65
+ <div class="form-row">
66
+ <label for="node-config-input-osrT">Temperature oversampling</label>
67
+ <select id="node-config-input-osrT" style="width:180px">
68
+ <option value="0" selected>×1</option>
69
+ <option value="1">×2</option>
70
+ <option value="2">×4</option>
71
+ <option value="3">×8</option>
72
+ <option value="4">×16</option>
73
+ <option value="5">×32</option>
74
+ <option value="6">×64</option>
75
+ <option value="7">×128</option>
76
+ </select>
77
+ </div>
78
+ <div class="form-row">
79
+ <label for="node-config-input-pressEn"><i class="fa fa-microchip"></i> Enable pressure</label>
80
+ <input type="checkbox" id="node-config-input-pressEn" checked>
81
+ </div>
82
+ </script>
83
+
84
+ <!-- Read node: trigger → measurements -->
85
+ <script type="text/javascript">
86
+ RED.nodes.registerType('periph-bmp581', {
87
+ category: 'Peripheral',
88
+ color: '#C084FC',
89
+ defaults: {
90
+ name: { value: '' },
91
+ device: { value: '', type: 'bmp581-device', required: true },
92
+ seaLevelPa: { value: '101325' }
93
+ },
94
+ inputs: 1,
95
+ outputs: 1,
96
+ icon: 'font-awesome/fa-tachometer',
97
+ label: function() { return this.name || 'BMP581'; },
98
+ paletteLabel: 'BMP581'
99
+ });
100
+ </script>
101
+
102
+ <script type="text/html" data-template-name="periph-bmp581">
103
+ <div class="form-row">
104
+ <label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
105
+ <input type="text" id="node-input-device">
106
+ </div>
107
+ <div class="form-row">
108
+ <label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
109
+ <input type="text" id="node-input-name" placeholder="BMP581">
110
+ </div>
111
+ <div class="form-row">
112
+ <label for="node-input-seaLevelPa">Sea-level pressure (Pa)</label>
113
+ <input type="number" id="node-input-seaLevelPa" min="80000" max="110000" step="1" style="width:120px">
114
+ </div>
115
+ </script>
116
+
117
+ <script type="text/html" data-help-name="periph-bmp581">
118
+ <p>Reads pressure, temperature, and altitude from a BMP581 barometric pressure sensor.</p>
119
+ <p>Any input message triggers a measurement. The device is configured via a <b>bmp581-device</b> config node.</p>
120
+
121
+ <h3>Inputs</h3>
122
+ <dl class="message-properties">
123
+ <dt>payload <span class="property-type">any</span></dt>
124
+ <dd>Any incoming message triggers a measurement.</dd>
125
+ </dl>
126
+
127
+ <h3>Outputs</h3>
128
+ <dl class="message-properties">
129
+ <dt>payload.pressure <span class="property-type">number</span></dt>
130
+ <dd>Pressure in Pa.</dd>
131
+ <dt>payload.temperature <span class="property-type">number</span></dt>
132
+ <dd>Temperature in degrees Celsius.</dd>
133
+ <dt>payload.altitude <span class="property-type">number</span></dt>
134
+ <dd>Altitude in metres computed from the configured sea-level pressure.</dd>
135
+ </dl>
136
+
137
+ <h3>Configuration</h3>
138
+ <p>Set the I²C bus number, I²C address (<code>0x46</code> or <code>0x47</code>),
139
+ output data rate, pressure and temperature oversampling, and whether pressure measurements
140
+ are enabled in the device config node. The sea-level reference pressure defaults to
141
+ <code>101325</code> Pa and can be adjusted in the read node config panel.</p>
142
+ </script>