node-red-contrib-periph-power 1.5.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -2
- package/examples/ade7953/demo.json +22 -7
- package/examples/ina260/demo.json +76 -0
- package/examples/ina3221/demo.json +1 -1
- package/examples/lc709203f/demo.json +107 -0
- package/examples/lm25066/demo.json +88 -0
- package/examples/ltc4151/demo.json +88 -0
- package/examples/max17048/demo.json +88 -0
- package/nodes/ade7953/ade7953.html +69 -24
- package/nodes/ade7953/ade7953.js +12 -5
- package/nodes/ina260/ina260.html +77 -0
- package/nodes/ina260/ina260.js +49 -0
- package/nodes/ina3221/ina3221.html +3 -3
- package/nodes/ina3221/ina3221.js +1 -1
- package/nodes/lc709203f/lc709203f.html +96 -0
- package/nodes/lc709203f/lc709203f.js +52 -0
- package/nodes/lm25066/lm25066.html +97 -0
- package/nodes/lm25066/lm25066.js +51 -0
- package/nodes/ltc4151/ltc4151.html +89 -0
- package/nodes/ltc4151/ltc4151.js +51 -0
- package/nodes/max17048/max17048.html +89 -0
- package/nodes/max17048/max17048.js +49 -0
- package/package.json +7 -3
- package/index.js +0 -11
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<!-- Config node: one instance per physical device -->
|
|
2
|
+
<script type="text/javascript">
|
|
3
|
+
RED.nodes.registerType('max17048-device', {
|
|
4
|
+
category: 'config',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
|
+
address: { value: '36', required: true },
|
|
9
|
+
cells: { value: '1', required: true }
|
|
10
|
+
},
|
|
11
|
+
label: function() {
|
|
12
|
+
return this.name || ('MAX17048 @ 0x' + this.address + ' (bus ' + this.bus + ')');
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script type="text/html" data-template-name="max17048-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="MAX17048">
|
|
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"> (Linux /dev/i2c-N)
|
|
25
|
+
</div>
|
|
26
|
+
<div class="form-row">
|
|
27
|
+
<label for="node-config-input-address">Address (hex)</label>
|
|
28
|
+
<input type="text" id="node-config-input-address" placeholder="36" style="width:80px"> fixed: 36 (0x36)
|
|
29
|
+
</div>
|
|
30
|
+
<div class="form-row">
|
|
31
|
+
<label for="node-config-input-cells">Cells</label>
|
|
32
|
+
<select id="node-config-input-cells" style="width:160px">
|
|
33
|
+
<option value="1">1 (MAX17048)</option>
|
|
34
|
+
<option value="2">2 (MAX17049)</option>
|
|
35
|
+
</select>
|
|
36
|
+
</div>
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<!-- Read node: trigger → measurements -->
|
|
40
|
+
<script type="text/javascript">
|
|
41
|
+
RED.nodes.registerType('max17048', {
|
|
42
|
+
category: 'Peripheral',
|
|
43
|
+
color: '#C084FC',
|
|
44
|
+
defaults: {
|
|
45
|
+
name: { value: '' },
|
|
46
|
+
device: { value: '', type: 'max17048-device', required: true },
|
|
47
|
+
rate: { value: false }
|
|
48
|
+
},
|
|
49
|
+
inputs: 1,
|
|
50
|
+
outputs: 1,
|
|
51
|
+
icon: 'font-awesome/fa-battery-half',
|
|
52
|
+
label: function() { return this.name || 'MAX17048'; },
|
|
53
|
+
paletteLabel: 'MAX17048'
|
|
54
|
+
});
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<script type="text/html" data-template-name="max17048">
|
|
58
|
+
<div class="form-row">
|
|
59
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
60
|
+
<input type="text" id="node-input-device">
|
|
61
|
+
</div>
|
|
62
|
+
<div class="form-row">
|
|
63
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
64
|
+
<input type="text" id="node-input-name" placeholder="MAX17048">
|
|
65
|
+
</div>
|
|
66
|
+
<div class="form-row">
|
|
67
|
+
<label for="node-input-rate"><i class="fa fa-line-chart"></i> Rate</label>
|
|
68
|
+
<input type="checkbox" id="node-input-rate" style="width:auto"> also output the charge/discharge rate
|
|
69
|
+
</div>
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<script type="text/html" data-help-name="max17048">
|
|
73
|
+
<p>Reads cell voltage and state of charge from a MAX17048 (1-cell) or MAX17049 (2-cell) lithium fuel gauge over I²C.</p>
|
|
74
|
+
<p>Any input message triggers one reading. The device is configured via a <b>max17048-device</b> config node.</p>
|
|
75
|
+
|
|
76
|
+
<h3>Output</h3>
|
|
77
|
+
<dl class="message-properties">
|
|
78
|
+
<dt>payload.voltage <span class="property-type">number</span></dt>
|
|
79
|
+
<dd>Cell voltage in volts (pack voltage for the 2-cell part).</dd>
|
|
80
|
+
<dt>payload.percent <span class="property-type">number</span></dt>
|
|
81
|
+
<dd>State of charge in % (0–100).</dd>
|
|
82
|
+
<dt>payload.charge_rate <span class="property-type">number</span></dt>
|
|
83
|
+
<dd>Approximate charge (positive) or discharge rate in %/h (only when the <b>Rate</b> option is enabled).</dd>
|
|
84
|
+
</dl>
|
|
85
|
+
|
|
86
|
+
<h3>Details</h3>
|
|
87
|
+
<p>The address is fixed at <code>0x36</code> (shared with the AS5600). The first state-of-charge value is valid
|
|
88
|
+
about 1 s after power-up. The node only reads; it never writes the chip.</p>
|
|
89
|
+
</script>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function(RED) {
|
|
4
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
|
+
const { MAX17048Full } = require('periph/src/chips/power/max17048');
|
|
6
|
+
|
|
7
|
+
function MAX17048DeviceNode(config) {
|
|
8
|
+
RED.nodes.createNode(this, config);
|
|
9
|
+
const node = this;
|
|
10
|
+
try {
|
|
11
|
+
const connection = new I2CConnection(parseInt(config.bus), parseInt(config.address, 16));
|
|
12
|
+
node.driver = new MAX17048Full(connection, parseInt(config.cells));
|
|
13
|
+
node.connection = connection;
|
|
14
|
+
} catch (e) {
|
|
15
|
+
node.error('MAX17048 init failed: ' + e.message);
|
|
16
|
+
}
|
|
17
|
+
node.on('close', function() {
|
|
18
|
+
if (node.connection) node.connection.close();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
RED.nodes.registerType('max17048-device', MAX17048DeviceNode);
|
|
22
|
+
|
|
23
|
+
function MAX17048ReadNode(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 MAX17048 device configured', msg);
|
|
31
|
+
done();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const d = node.device.driver;
|
|
36
|
+
msg.payload = {
|
|
37
|
+
voltage: await d.voltage(),
|
|
38
|
+
percent: await d.percent()
|
|
39
|
+
};
|
|
40
|
+
if (config.rate) msg.payload.charge_rate = await d.chargeRate();
|
|
41
|
+
send(msg);
|
|
42
|
+
done();
|
|
43
|
+
} catch (e) {
|
|
44
|
+
done(e);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
RED.nodes.registerType('max17048', MAX17048ReadNode);
|
|
49
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-contrib-periph-power",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "Node-RED nodes for power monitor chips",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"node-red",
|
|
@@ -10,14 +10,18 @@
|
|
|
10
10
|
"sensor",
|
|
11
11
|
"peripheral"
|
|
12
12
|
],
|
|
13
|
-
"main": "index.js",
|
|
14
13
|
"node-red": {
|
|
15
14
|
"nodes": {
|
|
16
15
|
"ina226": "nodes/ina226/ina226.js",
|
|
16
|
+
"ina260": "nodes/ina260/ina260.js",
|
|
17
17
|
"ina219": "nodes/ina219/ina219.js",
|
|
18
18
|
"ina3221": "nodes/ina3221/ina3221.js",
|
|
19
19
|
"ade7953": "nodes/ade7953/ade7953.js",
|
|
20
|
-
"axp2101": "nodes/axp2101/axp2101.js"
|
|
20
|
+
"axp2101": "nodes/axp2101/axp2101.js",
|
|
21
|
+
"lc709203f": "nodes/lc709203f/lc709203f.js",
|
|
22
|
+
"lm25066": "nodes/lm25066/lm25066.js",
|
|
23
|
+
"ltc4151": "nodes/ltc4151/ltc4151.js",
|
|
24
|
+
"max17048": "nodes/max17048/max17048.js"
|
|
21
25
|
}
|
|
22
26
|
},
|
|
23
27
|
"dependencies": {
|
package/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
module.exports = function(RED) {
|
|
5
|
-
const nodesDir = path.join(__dirname, 'nodes');
|
|
6
|
-
if (!fs.existsSync(nodesDir)) return;
|
|
7
|
-
fs.readdirSync(nodesDir).forEach(function(chip) {
|
|
8
|
-
const nodeFile = path.join(nodesDir, chip, chip + '.js');
|
|
9
|
-
if (fs.existsSync(nodeFile)) require(nodeFile)(RED);
|
|
10
|
-
});
|
|
11
|
-
};
|