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
package/README.md
CHANGED
|
@@ -16,15 +16,26 @@ npm install node-red-contrib-periph-power
|
|
|
16
16
|
|
|
17
17
|
| Node | Kind | Description |
|
|
18
18
|
|------|------|-------------|
|
|
19
|
-
| `
|
|
19
|
+
| `ade7953-device` | config | Bus configuration for an ADE7953 |
|
|
20
|
+
| `ade7953` | input | Reads bus voltage, load current, active power, and accumulated active energy from an ADE7953 single-phase multifunction metering IC. |
|
|
20
21
|
| `axp2101-device` | config | I²C bus and address for an AXP2101 |
|
|
21
22
|
| `axp2101` | input | Reads battery, charger and power-input state from an AXP2101 single-cell power-management IC over I²C. |
|
|
22
23
|
| `ina219-device` | config | I²C bus and address for an INA219 |
|
|
23
24
|
| `ina219` | input | Reads voltage, current, power, and shunt voltage from an INA219 power monitor over I²C. |
|
|
24
25
|
| `ina226-device` | config | I²C bus and address for an INA226 |
|
|
25
26
|
| `ina226` | input | Reads voltage, current, power, and shunt voltage from an INA226 power monitor over I²C. |
|
|
27
|
+
| `ina260-device` | config | I²C bus and address for an INA260 |
|
|
28
|
+
| `ina260` | input | Reads bus voltage, current, and power from an INA260 power monitor (integrated 2 mΩ shunt) over I²C. |
|
|
26
29
|
| `ina3221-device` | config | I²C bus and address for an INA3221 |
|
|
27
|
-
| `
|
|
30
|
+
| `ina3221` | input | Reads bus voltage, shunt voltage, current, and power from an INA3221 three-channel power monitor over I²C. |
|
|
31
|
+
| `lc709203f-device` | config | I²C bus and address for a LC709203F |
|
|
32
|
+
| `lc709203f` | input | Reads cell voltage, state of charge and temperature from an LC709203F 1-cell Li-ion fuel gauge over I²C. |
|
|
33
|
+
| `lm25066-device` | config | I²C bus and address for a LM25066 |
|
|
34
|
+
| `lm25066` | input | Reads input and output voltage, input current, input power and MOSFET temperature from an LM25066 hot-swap controller over I²C/PMBus. |
|
|
35
|
+
| `ltc4151-device` | config | I²C bus and address for a LTC4151 |
|
|
36
|
+
| `ltc4151` | input | Reads supply voltage, load current and power from an LTC4151 7–80 V high-side power monitor over I²C. |
|
|
37
|
+
| `max17048-device` | config | I²C bus and address for a MAX17048 |
|
|
38
|
+
| `max17048` | input | Reads cell voltage and state of charge from a MAX17048 (1-cell) or MAX17049 (2-cell) lithium fuel gauge over I²C. |
|
|
28
39
|
|
|
29
40
|
## Links
|
|
30
41
|
|
|
@@ -5,17 +5,28 @@
|
|
|
5
5
|
"name": "ADE7953 Demo",
|
|
6
6
|
"icon": "bolt",
|
|
7
7
|
"order": 1,
|
|
8
|
-
"info": "This flow demonstrates the ADE7953 single-phase multifunction metering IC.\n\n**Continuous single-phase metering**: an inject node fires once per second into the
|
|
8
|
+
"info": "This flow demonstrates the ADE7953 single-phase multifunction metering IC.\n\n**Continuous single-phase metering**: an inject node fires once per second into the ade7953 node, which emits voltage, current, active power, and cumulative active energy for Current Channel A. A function node formats the four values as one line; a debug node prints them to the sidebar — the user sees a live single-phase energy-monitoring feed, with active energy visibly climbing over the session.\n\nThe chip is wired to the host over I²C at the chip's fixed 7-bit address 0x38; the calibration constants (voltage_gain = 251.0 V/V, current_gain = 30.0 A/V) are placeholders — replace them with the actual values for the external voltage divider and current sensor on your PCB."
|
|
9
9
|
},
|
|
10
10
|
{
|
|
11
11
|
"id": "ade7953-device-1",
|
|
12
|
-
"type": "
|
|
13
|
-
"name": "ADE7953
|
|
12
|
+
"type": "ade7953-device",
|
|
13
|
+
"name": "ADE7953",
|
|
14
14
|
"bus": "1",
|
|
15
15
|
"addr": "0x38",
|
|
16
16
|
"voltageGain": "251.0",
|
|
17
|
-
"currentGain": "30.0"
|
|
18
|
-
|
|
17
|
+
"currentGain": "30.0"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"id": "ade7953-read-1",
|
|
21
|
+
"type": "ade7953",
|
|
22
|
+
"name": "ADE7953",
|
|
23
|
+
"wires": [
|
|
24
|
+
[
|
|
25
|
+
"debug-ade7953-1",
|
|
26
|
+
"format-ade7953-1"
|
|
27
|
+
]
|
|
28
|
+
],
|
|
29
|
+
"device": "ade7953-device-1"
|
|
19
30
|
},
|
|
20
31
|
{
|
|
21
32
|
"id": "format-ade7953-1",
|
|
@@ -45,6 +56,10 @@
|
|
|
45
56
|
"crontab": "",
|
|
46
57
|
"once": false,
|
|
47
58
|
"onceDelay": 0.1,
|
|
48
|
-
"wires": [
|
|
59
|
+
"wires": [
|
|
60
|
+
[
|
|
61
|
+
"ade7953-read-1"
|
|
62
|
+
]
|
|
63
|
+
]
|
|
49
64
|
}
|
|
50
|
-
]
|
|
65
|
+
]
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "tab-ina260-demo",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "INA260 Power Monitor",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "Reads voltage, current, and power from an INA260 every second and displays a formatted string in the debug panel."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "cfg-ina260",
|
|
11
|
+
"type": "ina260-device",
|
|
12
|
+
"name": "INA260",
|
|
13
|
+
"bus": "1",
|
|
14
|
+
"address": "40",
|
|
15
|
+
"rShunt": "0.1",
|
|
16
|
+
"maxCurrent": "2.0"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"id": "inj-tick",
|
|
20
|
+
"type": "inject",
|
|
21
|
+
"name": "every 1 s",
|
|
22
|
+
"repeat": "1",
|
|
23
|
+
"crontab": "",
|
|
24
|
+
"once": true,
|
|
25
|
+
"onceDelay": 0.1,
|
|
26
|
+
"topic": "",
|
|
27
|
+
"payload": "",
|
|
28
|
+
"payloadType": "date",
|
|
29
|
+
"z": "tab-ina260-demo",
|
|
30
|
+
"x": 120,
|
|
31
|
+
"y": 160,
|
|
32
|
+
"wires": [["read-ina260"]]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"id": "read-ina260",
|
|
36
|
+
"type": "ina260",
|
|
37
|
+
"name": "INA260",
|
|
38
|
+
"device": "cfg-ina260",
|
|
39
|
+
"z": "tab-ina260-demo",
|
|
40
|
+
"x": 300,
|
|
41
|
+
"y": 160,
|
|
42
|
+
"wires": [["fmt-readings"]]
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"id": "fmt-readings",
|
|
46
|
+
"type": "function",
|
|
47
|
+
"name": "format",
|
|
48
|
+
"func": "const p = msg.payload;\nmsg.payload = p.voltage_v.toFixed(3) + 'V ' + p.current_a.toFixed(4) + 'A ' + p.power_w.toFixed(4) + 'W';\nreturn msg;",
|
|
49
|
+
"outputs": 1,
|
|
50
|
+
"noerr": 0,
|
|
51
|
+
"initialize": "",
|
|
52
|
+
"finalize": "",
|
|
53
|
+
"libs": [],
|
|
54
|
+
"z": "tab-ina260-demo",
|
|
55
|
+
"x": 480,
|
|
56
|
+
"y": 160,
|
|
57
|
+
"wires": [["dbg-readings"]]
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"id": "dbg-readings",
|
|
61
|
+
"type": "debug",
|
|
62
|
+
"name": "",
|
|
63
|
+
"active": true,
|
|
64
|
+
"tosidebar": true,
|
|
65
|
+
"console": false,
|
|
66
|
+
"tostatus": true,
|
|
67
|
+
"complete": "payload",
|
|
68
|
+
"targetType": "msg",
|
|
69
|
+
"statusVal": "payload",
|
|
70
|
+
"statusType": "auto",
|
|
71
|
+
"z": "tab-ina260-demo",
|
|
72
|
+
"x": 650,
|
|
73
|
+
"y": 160,
|
|
74
|
+
"wires": []
|
|
75
|
+
}
|
|
76
|
+
]
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "tab-lc709203f-demo",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "LC709203F Battery Monitor",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "Battery monitor: every 5 s reads cell voltage, state of charge and temperature from an LC709203F fuel gauge on a 1000 mAh LiPo and shows a formatted string in the debug panel. The host temperature is fed as 25 °C."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "cfg-lc709203f",
|
|
11
|
+
"type": "lc709203f-device",
|
|
12
|
+
"name": "LC709203F",
|
|
13
|
+
"bus": "1",
|
|
14
|
+
"address": "0B",
|
|
15
|
+
"capacity": "1000",
|
|
16
|
+
"profile": "1"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"id": "inj-tick",
|
|
20
|
+
"type": "inject",
|
|
21
|
+
"name": "every 5 s",
|
|
22
|
+
"repeat": "5",
|
|
23
|
+
"crontab": "",
|
|
24
|
+
"once": true,
|
|
25
|
+
"onceDelay": 0.1,
|
|
26
|
+
"topic": "",
|
|
27
|
+
"payload": "",
|
|
28
|
+
"payloadType": "date",
|
|
29
|
+
"z": "tab-lc709203f-demo",
|
|
30
|
+
"x": 120,
|
|
31
|
+
"y": 160,
|
|
32
|
+
"wires": [
|
|
33
|
+
[
|
|
34
|
+
"set-temp"
|
|
35
|
+
]
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "set-temp",
|
|
40
|
+
"type": "function",
|
|
41
|
+
"name": "host temperature 25 °C",
|
|
42
|
+
"func": "msg.temperature = 25;\nreturn msg;",
|
|
43
|
+
"outputs": 1,
|
|
44
|
+
"noerr": 0,
|
|
45
|
+
"initialize": "",
|
|
46
|
+
"finalize": "",
|
|
47
|
+
"libs": [],
|
|
48
|
+
"z": "tab-lc709203f-demo",
|
|
49
|
+
"x": 320,
|
|
50
|
+
"y": 160,
|
|
51
|
+
"wires": [
|
|
52
|
+
[
|
|
53
|
+
"read-lc709203f"
|
|
54
|
+
]
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"id": "read-lc709203f",
|
|
59
|
+
"type": "lc709203f",
|
|
60
|
+
"name": "LC709203F",
|
|
61
|
+
"device": "cfg-lc709203f",
|
|
62
|
+
"z": "tab-lc709203f-demo",
|
|
63
|
+
"x": 530,
|
|
64
|
+
"y": 160,
|
|
65
|
+
"wires": [
|
|
66
|
+
[
|
|
67
|
+
"fmt-readings"
|
|
68
|
+
]
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"id": "fmt-readings",
|
|
73
|
+
"type": "function",
|
|
74
|
+
"name": "format",
|
|
75
|
+
"func": "const p = msg.payload;\nmsg.payload = p.voltage_v.toFixed(3) + ' V ' + p.percent.toFixed(1) + ' % ' + p.temperature_c.toFixed(1) + ' °C';\nreturn msg;",
|
|
76
|
+
"outputs": 1,
|
|
77
|
+
"noerr": 0,
|
|
78
|
+
"initialize": "",
|
|
79
|
+
"finalize": "",
|
|
80
|
+
"libs": [],
|
|
81
|
+
"z": "tab-lc709203f-demo",
|
|
82
|
+
"x": 720,
|
|
83
|
+
"y": 160,
|
|
84
|
+
"wires": [
|
|
85
|
+
[
|
|
86
|
+
"dbg"
|
|
87
|
+
]
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"id": "dbg",
|
|
92
|
+
"type": "debug",
|
|
93
|
+
"name": "battery",
|
|
94
|
+
"active": true,
|
|
95
|
+
"tosidebar": true,
|
|
96
|
+
"console": false,
|
|
97
|
+
"tostatus": false,
|
|
98
|
+
"complete": "payload",
|
|
99
|
+
"targetType": "msg",
|
|
100
|
+
"statusVal": "",
|
|
101
|
+
"statusType": "auto",
|
|
102
|
+
"z": "tab-lc709203f-demo",
|
|
103
|
+
"x": 900,
|
|
104
|
+
"y": 160,
|
|
105
|
+
"wires": []
|
|
106
|
+
}
|
|
107
|
+
]
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "tab-lm25066-demo",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "LM25066 Hot-swap Rail Monitor",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "Hot-swap rail monitor: every 1 s reads VIN, VOUT, input current, input power and MOSFET temperature from an LM25066 on a 12 V rail with a 1 mOhm sense resistor, and shows a formatted string in the debug panel. The node never writes the control registers."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "cfg-lm25066",
|
|
11
|
+
"type": "lm25066-device",
|
|
12
|
+
"name": "LM25066",
|
|
13
|
+
"bus": "1",
|
|
14
|
+
"address": "40",
|
|
15
|
+
"rsense": "1.0",
|
|
16
|
+
"climit": "25"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"id": "inj-tick",
|
|
20
|
+
"type": "inject",
|
|
21
|
+
"name": "every 1 s",
|
|
22
|
+
"repeat": "1",
|
|
23
|
+
"crontab": "",
|
|
24
|
+
"once": true,
|
|
25
|
+
"onceDelay": 0.1,
|
|
26
|
+
"topic": "",
|
|
27
|
+
"payload": "",
|
|
28
|
+
"payloadType": "date",
|
|
29
|
+
"z": "tab-lm25066-demo",
|
|
30
|
+
"x": 120,
|
|
31
|
+
"y": 160,
|
|
32
|
+
"wires": [
|
|
33
|
+
[
|
|
34
|
+
"read-lm25066"
|
|
35
|
+
]
|
|
36
|
+
]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"id": "read-lm25066",
|
|
40
|
+
"type": "lm25066",
|
|
41
|
+
"name": "LM25066",
|
|
42
|
+
"device": "cfg-lm25066",
|
|
43
|
+
"z": "tab-lm25066-demo",
|
|
44
|
+
"x": 320,
|
|
45
|
+
"y": 160,
|
|
46
|
+
"wires": [
|
|
47
|
+
[
|
|
48
|
+
"fmt-readings"
|
|
49
|
+
]
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"id": "fmt-readings",
|
|
54
|
+
"type": "function",
|
|
55
|
+
"name": "format",
|
|
56
|
+
"func": "const p = msg.payload;\nmsg.payload = p.voltage_in_v.toFixed(2) + ' V in ' + p.voltage_out_v.toFixed(2) + ' V out ' + p.current_a.toFixed(3) + ' A ' + p.power_w.toFixed(2) + ' W ' + p.temperature_c.toFixed(1) + ' °C';\nreturn msg;",
|
|
57
|
+
"outputs": 1,
|
|
58
|
+
"noerr": 0,
|
|
59
|
+
"initialize": "",
|
|
60
|
+
"finalize": "",
|
|
61
|
+
"libs": [],
|
|
62
|
+
"z": "tab-lm25066-demo",
|
|
63
|
+
"x": 520,
|
|
64
|
+
"y": 160,
|
|
65
|
+
"wires": [
|
|
66
|
+
[
|
|
67
|
+
"dbg"
|
|
68
|
+
]
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"id": "dbg",
|
|
73
|
+
"type": "debug",
|
|
74
|
+
"name": "rail",
|
|
75
|
+
"active": true,
|
|
76
|
+
"tosidebar": true,
|
|
77
|
+
"console": false,
|
|
78
|
+
"tostatus": false,
|
|
79
|
+
"complete": "payload",
|
|
80
|
+
"targetType": "msg",
|
|
81
|
+
"statusVal": "",
|
|
82
|
+
"statusType": "auto",
|
|
83
|
+
"z": "tab-lm25066-demo",
|
|
84
|
+
"x": 700,
|
|
85
|
+
"y": 160,
|
|
86
|
+
"wires": []
|
|
87
|
+
}
|
|
88
|
+
]
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "tab-ltc4151-demo",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "LTC4151 High-side Supply Monitor",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "High-side supply monitor: every 1 s reads the supply voltage, load current and power from an LTC4151 on a 48 V rail with a 20 mOhm sense resistor and shows a formatted string in the debug panel. Adjust the sense resistor in the device config node to match your hardware. The node only reads the continuous scan and never writes the chip."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "cfg-ltc4151",
|
|
11
|
+
"type": "ltc4151-device",
|
|
12
|
+
"name": "LTC4151",
|
|
13
|
+
"bus": "1",
|
|
14
|
+
"address": "6A",
|
|
15
|
+
"rsense": "20"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"id": "inj-tick",
|
|
19
|
+
"type": "inject",
|
|
20
|
+
"name": "every 1 s",
|
|
21
|
+
"repeat": "1",
|
|
22
|
+
"crontab": "",
|
|
23
|
+
"once": true,
|
|
24
|
+
"onceDelay": 0.1,
|
|
25
|
+
"topic": "",
|
|
26
|
+
"payload": "",
|
|
27
|
+
"payloadType": "date",
|
|
28
|
+
"z": "tab-ltc4151-demo",
|
|
29
|
+
"x": 120,
|
|
30
|
+
"y": 160,
|
|
31
|
+
"wires": [
|
|
32
|
+
[
|
|
33
|
+
"read-ltc4151"
|
|
34
|
+
]
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"id": "read-ltc4151",
|
|
39
|
+
"type": "ltc4151",
|
|
40
|
+
"name": "LTC4151",
|
|
41
|
+
"device": "cfg-ltc4151",
|
|
42
|
+
"z": "tab-ltc4151-demo",
|
|
43
|
+
"x": 320,
|
|
44
|
+
"y": 160,
|
|
45
|
+
"wires": [
|
|
46
|
+
[
|
|
47
|
+
"fmt-readings"
|
|
48
|
+
]
|
|
49
|
+
],
|
|
50
|
+
"adin": false
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"id": "fmt-readings",
|
|
54
|
+
"type": "function",
|
|
55
|
+
"name": "format",
|
|
56
|
+
"func": "const p = msg.payload;\nmsg.payload = p.voltage.toFixed(2) + ' V ' + p.current.toFixed(3) + ' A ' + p.power.toFixed(2) + ' W';\nreturn msg;",
|
|
57
|
+
"outputs": 1,
|
|
58
|
+
"noerr": 0,
|
|
59
|
+
"initialize": "",
|
|
60
|
+
"finalize": "",
|
|
61
|
+
"libs": [],
|
|
62
|
+
"z": "tab-ltc4151-demo",
|
|
63
|
+
"x": 520,
|
|
64
|
+
"y": 160,
|
|
65
|
+
"wires": [
|
|
66
|
+
[
|
|
67
|
+
"dbg"
|
|
68
|
+
]
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"id": "dbg",
|
|
73
|
+
"type": "debug",
|
|
74
|
+
"name": "rail",
|
|
75
|
+
"active": true,
|
|
76
|
+
"tosidebar": true,
|
|
77
|
+
"console": false,
|
|
78
|
+
"tostatus": false,
|
|
79
|
+
"complete": "payload",
|
|
80
|
+
"targetType": "msg",
|
|
81
|
+
"statusVal": "",
|
|
82
|
+
"statusType": "auto",
|
|
83
|
+
"z": "tab-ltc4151-demo",
|
|
84
|
+
"x": 700,
|
|
85
|
+
"y": 160,
|
|
86
|
+
"wires": []
|
|
87
|
+
}
|
|
88
|
+
]
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "tab-max17048-demo",
|
|
4
|
+
"type": "tab",
|
|
5
|
+
"label": "MAX17048 Battery Fuel Gauge",
|
|
6
|
+
"disabled": false,
|
|
7
|
+
"info": "Battery fuel gauge: every 5 s reads the cell voltage and state of charge from a MAX17048 on a single Li-ion/LiPo cell and shows a formatted string such as \"3.87 V / 74.3 %\" in the debug panel. The node only reads and never writes the chip."
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"id": "cfg-max17048",
|
|
11
|
+
"type": "max17048-device",
|
|
12
|
+
"name": "MAX17048",
|
|
13
|
+
"bus": "1",
|
|
14
|
+
"address": "36",
|
|
15
|
+
"cells": "1"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"id": "inj-tick",
|
|
19
|
+
"type": "inject",
|
|
20
|
+
"name": "every 5 s",
|
|
21
|
+
"repeat": "5",
|
|
22
|
+
"crontab": "",
|
|
23
|
+
"once": true,
|
|
24
|
+
"onceDelay": 0.1,
|
|
25
|
+
"topic": "",
|
|
26
|
+
"payload": "",
|
|
27
|
+
"payloadType": "date",
|
|
28
|
+
"z": "tab-max17048-demo",
|
|
29
|
+
"x": 120,
|
|
30
|
+
"y": 160,
|
|
31
|
+
"wires": [
|
|
32
|
+
[
|
|
33
|
+
"read-max17048"
|
|
34
|
+
]
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"id": "read-max17048",
|
|
39
|
+
"type": "max17048",
|
|
40
|
+
"name": "MAX17048",
|
|
41
|
+
"device": "cfg-max17048",
|
|
42
|
+
"z": "tab-max17048-demo",
|
|
43
|
+
"x": 320,
|
|
44
|
+
"y": 160,
|
|
45
|
+
"wires": [
|
|
46
|
+
[
|
|
47
|
+
"fmt-readings"
|
|
48
|
+
]
|
|
49
|
+
],
|
|
50
|
+
"rate": false
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"id": "fmt-readings",
|
|
54
|
+
"type": "function",
|
|
55
|
+
"name": "format",
|
|
56
|
+
"func": "const p = msg.payload;\nmsg.payload = p.voltage.toFixed(2) + ' V / ' + p.percent.toFixed(1) + ' %';\nreturn msg;",
|
|
57
|
+
"outputs": 1,
|
|
58
|
+
"noerr": 0,
|
|
59
|
+
"initialize": "",
|
|
60
|
+
"finalize": "",
|
|
61
|
+
"libs": [],
|
|
62
|
+
"z": "tab-max17048-demo",
|
|
63
|
+
"x": 520,
|
|
64
|
+
"y": 160,
|
|
65
|
+
"wires": [
|
|
66
|
+
[
|
|
67
|
+
"dbg"
|
|
68
|
+
]
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"id": "dbg",
|
|
73
|
+
"type": "debug",
|
|
74
|
+
"name": "battery",
|
|
75
|
+
"active": true,
|
|
76
|
+
"tosidebar": true,
|
|
77
|
+
"console": false,
|
|
78
|
+
"tostatus": false,
|
|
79
|
+
"complete": "payload",
|
|
80
|
+
"targetType": "msg",
|
|
81
|
+
"statusVal": "",
|
|
82
|
+
"statusType": "auto",
|
|
83
|
+
"z": "tab-max17048-demo",
|
|
84
|
+
"x": 700,
|
|
85
|
+
"y": 160,
|
|
86
|
+
"wires": []
|
|
87
|
+
}
|
|
88
|
+
]
|
|
@@ -1,4 +1,72 @@
|
|
|
1
|
-
|
|
1
|
+
<!-- Config node: one instance per physical device -->
|
|
2
|
+
<script type="text/javascript">
|
|
3
|
+
RED.nodes.registerType('ade7953-device', {
|
|
4
|
+
category: 'config',
|
|
5
|
+
defaults: {
|
|
6
|
+
name: { value: '' },
|
|
7
|
+
bus: { value: '1', required: true, validate: RED.validators.number() },
|
|
8
|
+
addr: { value: '0x38', required: true, validate: RED.validators.regex(/^0x[0-9a-fA-F]{1,2}$/) },
|
|
9
|
+
voltageGain: { value: '251.0', required: true, validate: RED.validators.number() },
|
|
10
|
+
currentGain: { value: '30.0', required: true, validate: RED.validators.number() }
|
|
11
|
+
},
|
|
12
|
+
label: function() {
|
|
13
|
+
return this.name || ('ADE7953 @ ' + this.addr + ' (bus ' + this.bus + ')');
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<script type="text/html" data-template-name="ade7953-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="ADE7953">
|
|
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-addr">Address (hex)</label>
|
|
29
|
+
<input type="text" id="node-config-input-addr" placeholder="0x38" style="width:80px"> fixed: 0x38
|
|
30
|
+
</div>
|
|
31
|
+
<div class="form-row">
|
|
32
|
+
<label for="node-config-input-voltageGain">Voltage gain</label>
|
|
33
|
+
<input type="number" id="node-config-input-voltageGain" step="any" style="width:100px"> V per V at VP–VN
|
|
34
|
+
</div>
|
|
35
|
+
<div class="form-row">
|
|
36
|
+
<label for="node-config-input-currentGain">Current gain</label>
|
|
37
|
+
<input type="number" id="node-config-input-currentGain" step="any" style="width:100px"> A per V at IAP–IAN
|
|
38
|
+
</div>
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<!-- Read node -->
|
|
42
|
+
<script type="text/javascript">
|
|
43
|
+
RED.nodes.registerType('ade7953', {
|
|
44
|
+
category: 'Peripheral',
|
|
45
|
+
color: '#C084FC',
|
|
46
|
+
defaults: {
|
|
47
|
+
name: { value: '' },
|
|
48
|
+
device: { value: '', type: 'ade7953-device', required: true }
|
|
49
|
+
},
|
|
50
|
+
inputs: 1,
|
|
51
|
+
outputs: 1,
|
|
52
|
+
icon: 'font-awesome/fa-microchip',
|
|
53
|
+
label: function() { return this.name || 'ADE7953'; },
|
|
54
|
+
paletteLabel: 'ADE7953'
|
|
55
|
+
});
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<script type="text/html" data-template-name="ade7953">
|
|
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="ADE7953">
|
|
62
|
+
</div>
|
|
63
|
+
<div class="form-row">
|
|
64
|
+
<label for="node-input-device"><i class="fa fa-microchip"></i> Device</label>
|
|
65
|
+
<input type="text" id="node-input-device">
|
|
66
|
+
</div>
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<script type="text/html" data-help-name="ade7953">
|
|
2
70
|
<p>Reads bus voltage, load current, active power, and accumulated active
|
|
3
71
|
energy from an ADE7953 single-phase multifunction metering IC.</p>
|
|
4
72
|
<h3>Inputs</h3>
|
|
@@ -27,26 +95,3 @@
|
|
|
27
95
|
Both must be supplied at construction — there is no universal default
|
|
28
96
|
because they depend on the external sensor network.</p>
|
|
29
97
|
</script>
|
|
30
|
-
|
|
31
|
-
<script type="text/javascript">
|
|
32
|
-
RED.nodes.registerType('periph-ade7953', {
|
|
33
|
-
category: 'Periph',
|
|
34
|
-
color: '#C084FC',
|
|
35
|
-
defaults: {
|
|
36
|
-
name: { value: '' },
|
|
37
|
-
bus: { value: '1', validate: RED.validators.number() },
|
|
38
|
-
addr: { value: '0x38', validate: RED.validators.regex(/^0x[0-9a-fA-F]{1,2}$/) },
|
|
39
|
-
voltageGain: { value: '251.0', validate: RED.validators.number() },
|
|
40
|
-
currentGain: { value: '30.0', validate: RED.validators.number() },
|
|
41
|
-
},
|
|
42
|
-
inputs: 1,
|
|
43
|
-
outputs: 1,
|
|
44
|
-
icon: 'light.png',
|
|
45
|
-
label: function() {
|
|
46
|
-
return this.name || 'ADE7953';
|
|
47
|
-
},
|
|
48
|
-
labelStyle: function() {
|
|
49
|
-
return this.name ? 'node_label_italic' : '';
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
</script>
|
package/nodes/ade7953/ade7953.js
CHANGED
|
@@ -4,7 +4,7 @@ module.exports = function(RED) {
|
|
|
4
4
|
const { I2CConnection } = require('periph/src/connection/i2c');
|
|
5
5
|
const { ADE7953Full } = require('periph/src/chips/power/ade7953');
|
|
6
6
|
|
|
7
|
-
function
|
|
7
|
+
function ADE7953DeviceNode(config) {
|
|
8
8
|
RED.nodes.createNode(this, config);
|
|
9
9
|
const node = this;
|
|
10
10
|
try {
|
|
@@ -24,15 +24,22 @@ module.exports = function(RED) {
|
|
|
24
24
|
node.on('close', function() {
|
|
25
25
|
if (node.connection) node.connection.close();
|
|
26
26
|
});
|
|
27
|
+
}
|
|
28
|
+
RED.nodes.registerType('ade7953-device', ADE7953DeviceNode);
|
|
29
|
+
|
|
30
|
+
function ADE7953ReadNode(config) {
|
|
31
|
+
RED.nodes.createNode(this, config);
|
|
32
|
+
const node = this;
|
|
33
|
+
const deviceNode = RED.nodes.getNode(config.device) || {};
|
|
27
34
|
|
|
28
35
|
node.on('input', async function(msg, send, done) {
|
|
29
|
-
if (!
|
|
30
|
-
node.error('No ADE7953
|
|
36
|
+
if (!deviceNode.driver) {
|
|
37
|
+
node.error('No ADE7953 device configured', msg);
|
|
31
38
|
done();
|
|
32
39
|
return;
|
|
33
40
|
}
|
|
34
41
|
try {
|
|
35
|
-
const d =
|
|
42
|
+
const d = deviceNode.driver;
|
|
36
43
|
const voltage = await d.voltage();
|
|
37
44
|
const current = await d.current();
|
|
38
45
|
const activePower = await d.activePower();
|
|
@@ -50,5 +57,5 @@ module.exports = function(RED) {
|
|
|
50
57
|
}
|
|
51
58
|
});
|
|
52
59
|
}
|
|
53
|
-
RED.nodes.registerType('
|
|
60
|
+
RED.nodes.registerType('ade7953', ADE7953ReadNode);
|
|
54
61
|
};
|