question

michael-protogerakis avatar image
michael-protogerakis asked

Gathering EM24 data via nodered

I have a EM24 Ethernet as part of an ESS. Is it possible to gather data from the EM24 via nodered through one of the Victron nodes?

If not, is there an example anywhere of how to poll data from the EM24 Ethernet in parallel to the GX via Modbus TCP from nodered?

ESSNode-REDem24
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

3 Answers
hominidae avatar image
hominidae answered ·

...most lightweight approach with node-red would be to use mqtt, as this comes natively with it.

Just enable mqtt in the GX and check, i.e. with mqttexplorer what the GX publishes to its broker and which topics you want to subscribe to.

Enable the GX to publish the required topics with keepalive.
See: https://github.com/victronenergy/dbus-mqtt#keep-alive

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

michael-protogerakis avatar image
michael-protogerakis answered ·

works perfect. thank you so much.


Using modbus tcp it would look like this

1685387030678.png


The left node is "Modbus-Read" is configured like in the picture below.

https://www.enika.eu/data/files/produkty/energy%20m/CP/em24%20ethernet%20cp.pdf describes the modbus registers to read. "Sum W" is under address 0028h which is 40 in decimal and consists of 2 16bit words.

1685387095067.png


Converting those two words to a valid 32bit Integer Value can be done like this in the JavaScript function block:

var rawData = new ArrayBuffer(4);
var intView = new Uint16Array(rawData);
var int32View = new Int32Array(rawData);


intView[0] = msg.payload[0]; //low
intView[1] = msg.payload[1]; //high


msg.payload = int32View[0].toFixed(1)/10.0;
msg.topic = "power";


node.status({fill:"blue",shape:"ring",text:msg.topic + ":" + msg.payload});    


return msg;


Of course the dbus-mqtt solution is much more elegant.

1685387347149.png


with the contents
1685387386784.png



1685387455688.png


1685387030678.png (43.4 KiB)
1685387095067.png (130.9 KiB)
1685387347149.png (171.9 KiB)
1685387386784.png (114.1 KiB)
1685387455688.png (95.9 KiB)
1 comment
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

hominidae avatar image hominidae commented ·

nice. Note, that IMHO with modbus read node, the conversion in the function node could me much more simple, when using the Response Buffer, not the data-bytes.

This is for a Bernecker MPM3PM meter, that I use outside of the victron ecosystem/GX.

1685437706032.png


For a signed 32bit BigEndian Buffer, coming from the modbus-read node, this is what I do:

var W = 0;
W = parseInt(msg.responseBuffer.buffer.readInt32BE() / 100);
msg.payload = W;
return msg;
0 Likes 0 ·
1685437706032.png (30.9 KiB)
markus-001 avatar image
markus-001 answered ·

You can also use the Victron node grid meter the EM24 Ethernet publishes a few basic values in that node which might be just what you need.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.