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,77 @@
|
|
|
1
|
+
<!-- Config node: one instance per physical device -->
|
|
2
|
+
<script type="text/javascript">
|
|
3
|
+
RED.nodes.registerType('ina260-device', {
|
|
4
|
+
category: 'config',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
|
+
address: { value: '40', required: true }
|
|
9
|
+
},
|
|
10
|
+
label: function() {
|
|
11
|
+
return this.name || ('INA260 @ 0x' + this.address + ' (bus ' + this.bus + ')');
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<script type="text/html" data-template-name="ina260-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="INA260">
|
|
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"> (Linux /dev/i2c-N)
|
|
24
|
+
</div>
|
|
25
|
+
<div class="form-row">
|
|
26
|
+
<label for="node-config-input-address">Address (hex)</label>
|
|
27
|
+
<input type="text" id="node-config-input-address" placeholder="40" style="width:80px"> default: 40 (0x40)
|
|
28
|
+
</div>
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<!-- Read node: trigger → measurements -->
|
|
32
|
+
<script type="text/javascript">
|
|
33
|
+
RED.nodes.registerType('ina260', {
|
|
34
|
+
category: 'Peripheral',
|
|
35
|
+
color: '#C084FC',
|
|
36
|
+
defaults: {
|
|
37
|
+
name: { value: '' },
|
|
38
|
+
device: { value: '', type: 'ina260-device', required: true }
|
|
39
|
+
},
|
|
40
|
+
inputs: 1,
|
|
41
|
+
outputs: 1,
|
|
42
|
+
icon: 'font-awesome/fa-bolt',
|
|
43
|
+
label: function() { return this.name || 'INA260'; },
|
|
44
|
+
paletteLabel: 'INA260'
|
|
45
|
+
});
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<script type="text/html" data-template-name="ina260">
|
|
49
|
+
<div class="form-row">
|
|
50
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
51
|
+
<input type="text" id="node-input-device">
|
|
52
|
+
</div>
|
|
53
|
+
<div class="form-row">
|
|
54
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
55
|
+
<input type="text" id="node-input-name" placeholder="INA260">
|
|
56
|
+
</div>
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<script type="text/html" data-help-name="ina260">
|
|
60
|
+
<p>Reads bus voltage, current, and power from an INA260 power monitor (integrated 2 mΩ shunt) over I²C.</p>
|
|
61
|
+
<p>Any input message triggers one reading. The device is configured via an <b>ina260-device</b> config node.</p>
|
|
62
|
+
|
|
63
|
+
<h3>Output</h3>
|
|
64
|
+
<dl class="message-properties">
|
|
65
|
+
<dt>payload.voltage_v <span class="property-type">number</span></dt>
|
|
66
|
+
<dd>Bus voltage in volts.</dd>
|
|
67
|
+
<dt>payload.current_a <span class="property-type">number</span></dt>
|
|
68
|
+
<dd>Current in amperes (signed; positive flows IN+ to IN−).</dd>
|
|
69
|
+
<dt>payload.power_w <span class="property-type">number</span></dt>
|
|
70
|
+
<dd>Power in watts.</dd>
|
|
71
|
+
</dl>
|
|
72
|
+
|
|
73
|
+
<h3>Details</h3>
|
|
74
|
+
<p>Configure the I²C bus number and address (default <code>0x40</code>, range <code>0x40</code>–<code>0x4F</code>)
|
|
75
|
+
in the device config node. The INA260 needs no calibration: the shunt is integrated and the registers have
|
|
76
|
+
fixed LSBs.</p>
|
|
77
|
+
</script>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function(RED) {
|
|
4
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
|
+
const { INA260Full } = require('periph/src/chips/power/ina260');
|
|
6
|
+
|
|
7
|
+
function INA260DeviceNode(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 INA260Full(connection);
|
|
13
|
+
node.connection = connection;
|
|
14
|
+
} catch (e) {
|
|
15
|
+
node.error('INA260 init failed: ' + e.message);
|
|
16
|
+
}
|
|
17
|
+
node.on('close', function() {
|
|
18
|
+
if (node.connection) node.connection.close();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
RED.nodes.registerType('ina260-device', INA260DeviceNode);
|
|
22
|
+
|
|
23
|
+
function INA260ReadNode(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 INA260 device configured', msg);
|
|
31
|
+
done();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const d = node.device.driver;
|
|
36
|
+
msg.payload = {
|
|
37
|
+
voltage_v: await d.voltage(),
|
|
38
|
+
current_a: await d.current(),
|
|
39
|
+
power_w: await d.power()
|
|
40
|
+
};
|
|
41
|
+
send(msg);
|
|
42
|
+
done();
|
|
43
|
+
} catch (e) {
|
|
44
|
+
done(e);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
RED.nodes.registerType('ina260', INA260ReadNode);
|
|
49
|
+
};
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
|
|
36
36
|
<!-- Read node: trigger → measurements -->
|
|
37
37
|
<script type="text/javascript">
|
|
38
|
-
RED.nodes.registerType('
|
|
38
|
+
RED.nodes.registerType('ina3221', {
|
|
39
39
|
category: 'Peripheral',
|
|
40
40
|
color: '#C084FC',
|
|
41
41
|
defaults: {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
});
|
|
51
51
|
</script>
|
|
52
52
|
|
|
53
|
-
<script type="text/html" data-template-name="
|
|
53
|
+
<script type="text/html" data-template-name="ina3221">
|
|
54
54
|
<div class="form-row">
|
|
55
55
|
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
56
56
|
<input type="text" id="node-input-device">
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
</div>
|
|
62
62
|
</script>
|
|
63
63
|
|
|
64
|
-
<script type="text/html" data-help-name="
|
|
64
|
+
<script type="text/html" data-help-name="ina3221">
|
|
65
65
|
<p>Reads bus voltage, shunt voltage, current, and power from an INA3221 three-channel power monitor over I²C.</p>
|
|
66
66
|
<p>Any input message triggers a measurement. The device is configured via an <b>ina3221-device</b> config node.</p>
|
|
67
67
|
|
package/nodes/ina3221/ina3221.js
CHANGED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<!-- Config node: one instance per physical device -->
|
|
2
|
+
<script type="text/javascript">
|
|
3
|
+
RED.nodes.registerType('lc709203f-device', {
|
|
4
|
+
category: 'config',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
|
+
address: { value: '0B', required: true },
|
|
9
|
+
capacity: { value: '1000', required: true, validate: RED.validators.number() },
|
|
10
|
+
profile: { value: '1', required: true }
|
|
11
|
+
},
|
|
12
|
+
label: function() {
|
|
13
|
+
return this.name || ('LC709203F @ 0x' + this.address + ' (bus ' + this.bus + ')');
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<script type="text/html" data-template-name="lc709203f-device">
|
|
19
|
+
<div class="form-row">
|
|
20
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
21
|
+
<input type="text" id="node-config-input-name" placeholder="LC709203F">
|
|
22
|
+
</div>
|
|
23
|
+
<div class="form-row">
|
|
24
|
+
<label for="node-config-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
25
|
+
<input type="number" id="node-config-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N)
|
|
26
|
+
</div>
|
|
27
|
+
<div class="form-row">
|
|
28
|
+
<label for="node-config-input-address">Address (hex)</label>
|
|
29
|
+
<input type="text" id="node-config-input-address" placeholder="0B" style="width:80px"> fixed: 0B (0x0B)
|
|
30
|
+
</div>
|
|
31
|
+
<div class="form-row">
|
|
32
|
+
<label for="node-config-input-capacity">Capacity (mAh)</label>
|
|
33
|
+
<input type="number" id="node-config-input-capacity" min="100" max="3000" style="width:100px">
|
|
34
|
+
</div>
|
|
35
|
+
<div class="form-row">
|
|
36
|
+
<label for="node-config-input-profile">Battery profile</label>
|
|
37
|
+
<select id="node-config-input-profile" style="width:100px">
|
|
38
|
+
<option value="0">0</option>
|
|
39
|
+
<option value="1">1 (3.7 V / 4.2 V)</option>
|
|
40
|
+
</select>
|
|
41
|
+
</div>
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<!-- Read node: trigger → measurements -->
|
|
45
|
+
<script type="text/javascript">
|
|
46
|
+
RED.nodes.registerType('lc709203f', {
|
|
47
|
+
category: 'Peripheral',
|
|
48
|
+
color: '#C084FC',
|
|
49
|
+
defaults: {
|
|
50
|
+
name: { value: '' },
|
|
51
|
+
device: { value: '', type: 'lc709203f-device', required: true }
|
|
52
|
+
},
|
|
53
|
+
inputs: 1,
|
|
54
|
+
outputs: 1,
|
|
55
|
+
icon: 'font-awesome/fa-battery-half',
|
|
56
|
+
label: function() { return this.name || 'LC709203F'; },
|
|
57
|
+
paletteLabel: 'LC709203F'
|
|
58
|
+
});
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<script type="text/html" data-template-name="lc709203f">
|
|
62
|
+
<div class="form-row">
|
|
63
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
64
|
+
<input type="text" id="node-input-device">
|
|
65
|
+
</div>
|
|
66
|
+
<div class="form-row">
|
|
67
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
68
|
+
<input type="text" id="node-input-name" placeholder="LC709203F">
|
|
69
|
+
</div>
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<script type="text/html" data-help-name="lc709203f">
|
|
73
|
+
<p>Reads cell voltage, state of charge and temperature from an LC709203F 1-cell Li-ion fuel gauge over I²C.</p>
|
|
74
|
+
<p>Any input message triggers one reading. The device is configured via an <b>lc709203f-device</b> config node.</p>
|
|
75
|
+
|
|
76
|
+
<h3>Input</h3>
|
|
77
|
+
<dl class="message-properties">
|
|
78
|
+
<dt class="optional">temperature <span class="property-type">number</span></dt>
|
|
79
|
+
<dd>Host-supplied cell temperature in °C (I²C temperature mode); written to the gauge before the reading.</dd>
|
|
80
|
+
</dl>
|
|
81
|
+
|
|
82
|
+
<h3>Output</h3>
|
|
83
|
+
<dl class="message-properties">
|
|
84
|
+
<dt>payload.voltage_v <span class="property-type">number</span></dt>
|
|
85
|
+
<dd>Cell voltage in volts.</dd>
|
|
86
|
+
<dt>payload.percent <span class="property-type">number</span></dt>
|
|
87
|
+
<dd>State of charge in % (0.1 % resolution).</dd>
|
|
88
|
+
<dt>payload.temperature_c <span class="property-type">number</span></dt>
|
|
89
|
+
<dd>Cell temperature in °C.</dd>
|
|
90
|
+
</dl>
|
|
91
|
+
|
|
92
|
+
<h3>Details</h3>
|
|
93
|
+
<p>The address is fixed at <code>0x0B</code>. The design capacity (100–3000 mAh) selects the APA value and the
|
|
94
|
+
battery profile selects the data file (profile 1 = 3.7 V / 4.2 V on <code>-01</code>/<code>-03</code> parts).
|
|
95
|
+
Every transfer is protected by a CRC-8 that the driver checks. The chip stretches the I²C clock.</p>
|
|
96
|
+
</script>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function(RED) {
|
|
4
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
|
+
const { LC709203FFull } = require('periph/src/chips/power/lc709203f');
|
|
6
|
+
|
|
7
|
+
function LC709203FDeviceNode(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 LC709203FFull(connection, parseInt(config.capacity), parseInt(config.profile));
|
|
13
|
+
node.connection = connection;
|
|
14
|
+
} catch (e) {
|
|
15
|
+
node.error('LC709203F init failed: ' + e.message);
|
|
16
|
+
}
|
|
17
|
+
node.on('close', function() {
|
|
18
|
+
if (node.connection) node.connection.close();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
RED.nodes.registerType('lc709203f-device', LC709203FDeviceNode);
|
|
22
|
+
|
|
23
|
+
function LC709203FReadNode(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 LC709203F device configured', msg);
|
|
31
|
+
done();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const d = node.device.driver;
|
|
36
|
+
if (typeof msg.temperature === 'number') {
|
|
37
|
+
await d.setTemperature(msg.temperature);
|
|
38
|
+
}
|
|
39
|
+
msg.payload = {
|
|
40
|
+
voltage_v: await d.voltage(),
|
|
41
|
+
percent: await d.percent(),
|
|
42
|
+
temperature_c: await d.temperature()
|
|
43
|
+
};
|
|
44
|
+
send(msg);
|
|
45
|
+
done();
|
|
46
|
+
} catch (e) {
|
|
47
|
+
done(e);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
RED.nodes.registerType('lc709203f', LC709203FReadNode);
|
|
52
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
<!-- Config node: one instance per physical device -->
|
|
2
|
+
<script type="text/javascript">
|
|
3
|
+
RED.nodes.registerType('lm25066-device', {
|
|
4
|
+
category: 'config',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
|
+
address: { value: '40', required: true },
|
|
9
|
+
rsense: { value: '1.0', required: true, validate: RED.validators.number() },
|
|
10
|
+
climit: { value: '25', required: true }
|
|
11
|
+
},
|
|
12
|
+
label: function() {
|
|
13
|
+
return this.name || ('LM25066 @ 0x' + this.address + ' (bus ' + this.bus + ')');
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<script type="text/html" data-template-name="lm25066-device">
|
|
19
|
+
<div class="form-row">
|
|
20
|
+
<label for="node-config-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
21
|
+
<input type="text" id="node-config-input-name" placeholder="LM25066">
|
|
22
|
+
</div>
|
|
23
|
+
<div class="form-row">
|
|
24
|
+
<label for="node-config-input-bus"><i class="fa fa-microchip"></i> I²C bus</label>
|
|
25
|
+
<input type="number" id="node-config-input-bus" min="0" style="width:80px"> (Linux /dev/i2c-N)
|
|
26
|
+
</div>
|
|
27
|
+
<div class="form-row">
|
|
28
|
+
<label for="node-config-input-address">Address (hex)</label>
|
|
29
|
+
<input type="text" id="node-config-input-address" placeholder="40" style="width:80px"> 10-17, 40-47 or 50-5A (ADR0/1/2 pins)
|
|
30
|
+
</div>
|
|
31
|
+
<div class="form-row">
|
|
32
|
+
<label for="node-config-input-rsense">Sense resistor (mΩ)</label>
|
|
33
|
+
<input type="number" id="node-config-input-rsense" min="0.01" step="0.01" style="width:100px">
|
|
34
|
+
</div>
|
|
35
|
+
<div class="form-row">
|
|
36
|
+
<label for="node-config-input-climit">Current-limit pin</label>
|
|
37
|
+
<select id="node-config-input-climit" style="width:140px">
|
|
38
|
+
<option value="25">GND (25 mV)</option>
|
|
39
|
+
<option value="46">VDD (46 mV)</option>
|
|
40
|
+
</select>
|
|
41
|
+
</div>
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<!-- Read node: trigger → measurements -->
|
|
45
|
+
<script type="text/javascript">
|
|
46
|
+
RED.nodes.registerType('lm25066', {
|
|
47
|
+
category: 'Peripheral',
|
|
48
|
+
color: '#C084FC',
|
|
49
|
+
defaults: {
|
|
50
|
+
name: { value: '' },
|
|
51
|
+
device: { value: '', type: 'lm25066-device', required: true }
|
|
52
|
+
},
|
|
53
|
+
inputs: 1,
|
|
54
|
+
outputs: 1,
|
|
55
|
+
icon: 'font-awesome/fa-bolt',
|
|
56
|
+
label: function() { return this.name || 'LM25066'; },
|
|
57
|
+
paletteLabel: 'LM25066'
|
|
58
|
+
});
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<script type="text/html" data-template-name="lm25066">
|
|
62
|
+
<div class="form-row">
|
|
63
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
64
|
+
<input type="text" id="node-input-device">
|
|
65
|
+
</div>
|
|
66
|
+
<div class="form-row">
|
|
67
|
+
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label>
|
|
68
|
+
<input type="text" id="node-input-name" placeholder="LM25066">
|
|
69
|
+
</div>
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<script type="text/html" data-help-name="lm25066">
|
|
73
|
+
<p>Reads input and output voltage, input current, input power and MOSFET temperature from an LM25066 hot-swap controller over I²C/PMBus.</p>
|
|
74
|
+
<p>Any input message triggers one reading. The device is configured via a <b>lm25066-device</b> config node. The node never writes the control registers (OPERATION, GATE_MASK, DEVICE_SETUP).</p>
|
|
75
|
+
|
|
76
|
+
<h3>Input</h3>
|
|
77
|
+
<p>Any message.</p>
|
|
78
|
+
|
|
79
|
+
<h3>Output</h3>
|
|
80
|
+
<dl class="message-properties">
|
|
81
|
+
<dt>payload.voltage_in_v <span class="property-type">number</span></dt>
|
|
82
|
+
<dd>Input voltage VIN in volts.</dd>
|
|
83
|
+
<dt>payload.voltage_out_v <span class="property-type">number</span></dt>
|
|
84
|
+
<dd>Output voltage VOUT in volts.</dd>
|
|
85
|
+
<dt>payload.current_a <span class="property-type">number</span></dt>
|
|
86
|
+
<dd>Input current in amperes.</dd>
|
|
87
|
+
<dt>payload.power_w <span class="property-type">number</span></dt>
|
|
88
|
+
<dd>Input power in watts.</dd>
|
|
89
|
+
<dt>payload.temperature_c <span class="property-type">number</span></dt>
|
|
90
|
+
<dd>External MOSFET temperature in °C.</dd>
|
|
91
|
+
</dl>
|
|
92
|
+
|
|
93
|
+
<h3>Details</h3>
|
|
94
|
+
<p>The address (<code>0x10</code>–<code>0x17</code>, <code>0x40</code>–<code>0x47</code>, <code>0x50</code>–<code>0x5A</code>) is selected by the
|
|
95
|
+
three-state ADR0/ADR1/ADR2 pins. The current and power conversion depends on the sense resistor value and the CL pin
|
|
96
|
+
(GND = 25 mV, VDD = 46 mV); a wrong setting scales the readings.</p>
|
|
97
|
+
</script>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function(RED) {
|
|
4
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
|
+
const { LM25066Minimal } = require('periph/src/chips/power/lm25066');
|
|
6
|
+
|
|
7
|
+
function LM25066DeviceNode(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 LM25066Minimal(connection, parseFloat(config.rsense), config.climit === '46');
|
|
13
|
+
node.connection = connection;
|
|
14
|
+
} catch (e) {
|
|
15
|
+
node.error('LM25066 init failed: ' + e.message);
|
|
16
|
+
}
|
|
17
|
+
node.on('close', function() {
|
|
18
|
+
if (node.connection) node.connection.close();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
RED.nodes.registerType('lm25066-device', LM25066DeviceNode);
|
|
22
|
+
|
|
23
|
+
function LM25066ReadNode(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 LM25066 device configured', msg);
|
|
31
|
+
done();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const d = node.device.driver;
|
|
36
|
+
msg.payload = {
|
|
37
|
+
voltage_in_v: await d.voltageIn(),
|
|
38
|
+
voltage_out_v: await d.voltageOut(),
|
|
39
|
+
current_a: await d.current(),
|
|
40
|
+
power_w: await d.power(),
|
|
41
|
+
temperature_c: await d.temperature()
|
|
42
|
+
};
|
|
43
|
+
send(msg);
|
|
44
|
+
done();
|
|
45
|
+
} catch (e) {
|
|
46
|
+
done(e);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
RED.nodes.registerType('lm25066', LM25066ReadNode);
|
|
51
|
+
};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<!-- Config node: one instance per physical device -->
|
|
2
|
+
<script type="text/javascript">
|
|
3
|
+
RED.nodes.registerType('ltc4151-device', {
|
|
4
|
+
category: 'config',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
|
+
address: { value: '6A', required: true },
|
|
9
|
+
rsense: { value: '20', required: true, validate: RED.validators.number() }
|
|
10
|
+
},
|
|
11
|
+
label: function() {
|
|
12
|
+
return this.name || ('LTC4151 @ 0x' + this.address + ' (bus ' + this.bus + ')');
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<script type="text/html" data-template-name="ltc4151-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="LTC4151">
|
|
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="6A" style="width:80px"> 67–6F (ADR1/ADR0 pins)
|
|
29
|
+
</div>
|
|
30
|
+
<div class="form-row">
|
|
31
|
+
<label for="node-config-input-rsense">Sense resistor (mΩ)</label>
|
|
32
|
+
<input type="number" id="node-config-input-rsense" min="0.01" step="0.01" style="width:100px">
|
|
33
|
+
</div>
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<!-- Read node: trigger → measurements -->
|
|
37
|
+
<script type="text/javascript">
|
|
38
|
+
RED.nodes.registerType('ltc4151', {
|
|
39
|
+
category: 'Peripheral',
|
|
40
|
+
color: '#C084FC',
|
|
41
|
+
defaults: {
|
|
42
|
+
name: { value: '' },
|
|
43
|
+
device: { value: '', type: 'ltc4151-device', required: true },
|
|
44
|
+
adin: { value: false }
|
|
45
|
+
},
|
|
46
|
+
inputs: 1,
|
|
47
|
+
outputs: 1,
|
|
48
|
+
icon: 'font-awesome/fa-bolt',
|
|
49
|
+
label: function() { return this.name || 'LTC4151'; },
|
|
50
|
+
paletteLabel: 'LTC4151'
|
|
51
|
+
});
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<script type="text/html" data-template-name="ltc4151">
|
|
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="LTC4151">
|
|
62
|
+
</div>
|
|
63
|
+
<div class="form-row">
|
|
64
|
+
<label for="node-input-adin"><i class="fa fa-plug"></i> ADIN</label>
|
|
65
|
+
<input type="checkbox" id="node-input-adin" style="width:auto"> also output the ADIN pin voltage
|
|
66
|
+
</div>
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<script type="text/html" data-help-name="ltc4151">
|
|
70
|
+
<p>Reads supply voltage, load current and power from an LTC4151 7–80 V high-side power monitor over I²C.</p>
|
|
71
|
+
<p>Any input message triggers one reading. The device is configured via a <b>ltc4151-device</b> config node.</p>
|
|
72
|
+
|
|
73
|
+
<h3>Output</h3>
|
|
74
|
+
<dl class="message-properties">
|
|
75
|
+
<dt>payload.voltage <span class="property-type">number</span></dt>
|
|
76
|
+
<dd>Supply voltage at VIN in volts.</dd>
|
|
77
|
+
<dt>payload.current <span class="property-type">number</span></dt>
|
|
78
|
+
<dd>Load current in amperes (sense voltage divided by the sense resistor).</dd>
|
|
79
|
+
<dt>payload.power <span class="property-type">number</span></dt>
|
|
80
|
+
<dd>Load power in watts.</dd>
|
|
81
|
+
<dt>payload.adin <span class="property-type">number</span></dt>
|
|
82
|
+
<dd>ADIN pin voltage in volts (only when the <b>ADIN</b> option is enabled).</dd>
|
|
83
|
+
</dl>
|
|
84
|
+
|
|
85
|
+
<h3>Details</h3>
|
|
86
|
+
<p>Configure the I²C bus number, the address (<code>0x67</code>–<code>0x6F</code>, default <code>0x6A</code> with
|
|
87
|
+
both address pins open) and the sense resistor value in milliohms (default 20) in the device config node.
|
|
88
|
+
The node uses the continuous scan mode (about 7.5 Hz) and never writes the chip.</p>
|
|
89
|
+
</script>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = function(RED) {
|
|
4
|
+
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
|
+
const { LTC4151Full } = require('periph/src/chips/power/ltc4151');
|
|
6
|
+
|
|
7
|
+
function LTC4151DeviceNode(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 LTC4151Full(connection, parseFloat(config.rsense) / 1000);
|
|
13
|
+
node.connection = connection;
|
|
14
|
+
} catch (e) {
|
|
15
|
+
node.error('LTC4151 init failed: ' + e.message);
|
|
16
|
+
}
|
|
17
|
+
node.on('close', function() {
|
|
18
|
+
if (node.connection) node.connection.close();
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
RED.nodes.registerType('ltc4151-device', LTC4151DeviceNode);
|
|
22
|
+
|
|
23
|
+
function LTC4151ReadNode(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 LTC4151 device configured', msg);
|
|
31
|
+
done();
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
try {
|
|
35
|
+
const d = node.device.driver;
|
|
36
|
+
const r = await d.readAll();
|
|
37
|
+
msg.payload = {
|
|
38
|
+
voltage: r.vin,
|
|
39
|
+
current: r.current,
|
|
40
|
+
power: r.power
|
|
41
|
+
};
|
|
42
|
+
if (config.adin) msg.payload.adin = r.adin;
|
|
43
|
+
send(msg);
|
|
44
|
+
done();
|
|
45
|
+
} catch (e) {
|
|
46
|
+
done(e);
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
RED.nodes.registerType('ltc4151', LTC4151ReadNode);
|
|
51
|
+
};
|