question

Volker avatar image
Volker asked

emulating EM24 ethernet meter via modbusTCP server

Hello all,

I have been trying to include a 3rd party generator into the VRM.

For this I set up a modbusTCP server and populated it with the data from the generator
(modbus memory map as defined in this doc => EM24_E1 (Ethernet) COMMUNICATION PROTOCOL (Version 0 Revision 1.2)).

I could detect the emulated meter and connect to it as described here: https://www.victronenergy.com/live/energy-meters:em24-eth.

It shows up in the device list as "CG EM24 Ethernet Energy Meter" and after configuring the device as "PV inverter", the data (U,I,P) also show up in the widgets and dashboard as intended.

What I do not understand, however, is why the device in the remote console shows as "Not Connected" and all data in the associated submenue (AC Phase 1, ... AC totals, ... Energy L3) show "--" (no value).

REM: no intention to replace the 485 connected ESS grid-meter ET340 - the emulation is actually just intended for correct viewing of the setup in the dashboad/advanced overview.

FW-version is 2.73

Thanks a lot for any any help and suggestion!

Kind regards - Volker

VRMModbus TCPem24
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.

markw-1 avatar image markw-1 commented ·
Hello Volker,


seems like we have the same thoughts of emulating an EM24. Mine are a bit younger and I started my research just yesterday as i finna got my Multi.

Can you provide information how you did that? Probably with node red? So I hopefully can follow you then and find a solution for the visualization issue.

My first thought is something like a keep alive signal that might be missing. I’m new to modbus and more the CAN guy but that’s standard in this area.

Best Regards

Mark

0 Likes 0 ·
11 Answers
hansie avatar image
hansie answered ·

Seems like you make a wrong conversion from em24 parameter to victron. Use RMMS to check your values. I made the same project. Best regards.

2 |3000

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

Volker avatar image
Volker answered ·

Hey - sorry for answering late.

On my side this works quite stable now.

@Mark: What I did is just install a docker-based modbus-TCP server which behaves on read-access like an EM24. Updating of data (i.e. register writing) is continously done by a homeserver which has knowledge on the generator status.

two remaining questions:
(1) in the dashboard I see details (U,A,P per phase when details are enabled) for all blocks besides for the "PV inverter" that is emulated. The device itself shows those values.
=> Is this a limitation of the dashboard?
(2) the fact tat in the dashboard the summation is not displayed correctly is (still) a artefact of the ET340 that I use - correct?
(rem: currently on FW 2.84)


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.

christian-k-1 avatar image christian-k-1 commented ·
Hi Volker,

could you please provide more information about your configuration of the modbus TCP docker image?

I try the same with my 3 Zeversolar Inverters.


Wich homeserver do you use? Home Assistant?

0 Likes 0 ·
dafyddhirst avatar image
dafyddhirst answered ·

I Use a USR-302 it allows modbus tcp to rtu protocol conversion works a charm.

2 |3000

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

der-neue avatar image
der-neue answered ·

can someone help me with the implementation? Has anyone implemented this with nodered and can explain it to me a little?

2 |3000

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

pau1phi11ips avatar image
pau1phi11ips answered ·

Wouldn't it be easier to add a new driver for this? You could use the existing Carlo Gavazzi driver as a starting point.

https://github.com/victronenergy/dbus-modbus-client/blob/master/carlo_gavazzi.py

https://github.com/victronenergy/venus/wiki/howto-add-a-driver-to-Venus

2 |3000

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

christian-k-1 avatar image
christian-k-1 answered ·

Hi @Volker

could you please provide more information about your configuration of the modbus TCP docker image?

I try the same with my 3 Zeversolar Inverters.


Wich homeserver do you use? Home Assistant?

2 |3000

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

alferez avatar image
alferez answered ·

I have managed to emulate a Carlo Gavazzi EM24 with Modbus TCP using NodeRED.

As data source I have used a Shelly EM. Of course if you want to use it as a three phase you would need a Shelly 3EM and modify the flow to take the data from the other meters, in my case it was not necessary, but I have left it ready for it.


I have published both the instructions and the flow on my website:

https://www.alferez.es/iot/carlo-gavazzi-em24-node-red-modbus-tcp/


Sorry my website is in Spanish.


I hope this message does not bother, because it is related to the subject and is intended for use in conjunction with Victron, because I only write in the memory addresses that Victron consults.

8 comments
2 |3000

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

t81s avatar image t81s commented ·

Hi alferez,

wow thank you for that, you just saved me a lot of money!

The code works great and is up and running in my system.

Just if any one is wondering, my grid meter (DD3 2R10 DTA - ODZ1) is providing most of the necessary parameters via the optical interface (the missing ones like amps on the phases are calculated later). In NodeRed im using node-red-contrib-smartmeter to read the data and passing it to alferez code.

0 Likes 0 ·
alferez avatar image alferez t81s commented ·

I am happy that you were able to adapt it with your meter.

The idea was precisely to make it as standard as possible so that, as I use shelly, you can use any other meter from which you can obtain data. Including for example an inverter.

0 Likes 0 ·
lichtaus avatar image lichtaus commented ·
Hi Alferez, just what I have been looking for (except it does not run on a Siemens Logo and I do not speak Spanish :-)
0 Likes 0 ·
alferez avatar image alferez lichtaus commented ·

The nodered code is easy to read and easy to adapt.

The text on my website is simply explaining what each part does, but it is easily understandable and if not, there is always Google Translate ;)

0 Likes 0 ·
napal avatar image napal commented ·

Hi alfarez,


Your solution is exactly what I was looking for. However, as a data source a Kostal inverter (Plenticore), whose grid values I query via modbus tcp.

I get the values from the inverter without problems in node red.

Unfortunately I can't get a connection to your flow in Venus OS. No device is found.


I am not an expert regarding modbus. It could be that I have a basic error in my approach:

PV inverter -> Node Red -> Venus OS


I send my flow, maybe you or someone else can help me here.

Node Red EM24 emulated

0 Likes 0 ·
Jannes Peschel avatar image Jannes Peschel napal commented ·
I am unable to download your flow.

On which device are you running NodeRed?

I am running NodeRed inside iobroker on a raspberry and setting the Modbus Server IP Address to e.g. 192.168.188.60 was not working. I had to set the IP to 0.0.0.0 and then the emulated EM24 was found by the GX device at the IP Address of the raspberry.


0 Likes 0 ·
Jannes Peschel avatar image Jannes Peschel commented ·

Hello Alferez,

great work! thank you for sharing!

Can you provide information about the initialization part of your flow? I am trying to understand the "definitions" part and the registers you write the EM24 defenitions. I can not find all the information in the communication protocol of the EM24.

em24-flow.jpg

Another thing I can not find the answer for:
Some registers of the EM24 are working fine, e.g. voltage oder current registers (0x0000, 0x000C). page 8 of the following document.

http://docplayer.net/54399643-Em24-din-communication-protocol-version-2-revision-0.html

But I have problems with the energy registers. I have to use register 0x0042 to get the Energy of L2 right in the software of carlo gavazzi, but according to the protocol the correct register should be 0x0048. Any ideas where this can be caused by?

em24-register-l2-total-energy.jpg

total-energy-l2.jpg


0 Likes 0 ·
marommel avatar image marommel commented ·

hi @Alferez which pallet / plugin are you using for the modbus nodes?

    modbus-client
    modbus-server
    modbus-write


0 Likes 0 ·
crash-override avatar image
crash-override answered ·

Hi,

my solution is like other peoples here, I use Node Red to get all values from my plc which has meters connected and populated it via a custom dbus script.

My meter has no phase saldation so I counted it via Node RED.

Here are my files used, if it helps you.

https://git.bit-cloud.de/carsten.schmiemann/VictronGX_Custom_Sensors

2 |3000

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

stephan-kloidt avatar image
stephan-kloidt answered ·

Hi @Alferez,

thank you so much for sharing your node red solution emulating the EM24 with us. I got the system on venus os (running on a raspberry pi 3b) running, but I am only able to send data via Modbus TCP once. There is no update of the numbers visible in venus os. If i re-install the emulated energy meter, i can again set the values (for debugging) once, but then, they're frozen within venus os... do you have any recommendations?

So far, I am only using fixed debugging values and no continous input. But even this does not work.

Thanks, Stephan

2 |3000

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

alferez avatar image
alferez answered ·

Hello,


It is strange because I also use it from a rpi 3b and no problem, other colleagues use it with Cerbo and also have had no problems.


Try to put a debug module behind the json that converts the Shelly EM data. You should get data every 5 seconds.

2 |3000

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

stephan-kloidt avatar image
stephan-kloidt answered ·

... Data generation is no problem, its running perfectly. Even writing into Modbus registers seem to work: If i re-install the Modbus TCP Energy Meter with proper IP and Port in Venus OS, the new values are correctly displayed! That works every time i re-install it. But: If i do not re-install the device, i only see the initial values constantly. Seems there is a kind of trigger needed to get venus os pulling new data out of the modbus registers (?). Any suggestions? That would be really helpful. Thank you very much in advance!

Stephan

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.

krypto81 avatar image krypto81 commented ·
Hello,
@alferez, thank you very much. That's exactly what I was looking for.

@stephan-kloidt, I had the same problem. Maybe that is a solution for you too. After installing the EM24 on my Cerbo, the display of the test value worked. After changing the test value in Node-Red and distributing the flow, the transmission didn't work anymore. I had to delete and recreate the EM24 on my cerbo.
The reason was the "re-deployment" in Node-Red after changing my test value. The connection was simply not reestablished by my Cerbo.
Because I deploy changes in Node-Red quite often, I deactivated the modbus server in alferez flow and provided a separate modbus server via docker.

Maybe that's the solution for you too.

Regards
0 Likes 0 ·