question

fcriado avatar image
fcriado asked

Mqtt or ModbusTCP

HI everyone!

I am about to implement an opportunity load into a Victron ecosystem.

I already have the code to define the amount of power to be derived to the water heater, but I am not sure of which protocol to use, ModbusTCP or MQTT.

I can use both ( as the project is based on a RPi), but I am not sure which of them I should use, as it seems both adequate to my needs of reading variables from the CCGX.

Could you guide me? I have already read the “Data communication with Victron Energy products”, but I found no guidance apart the internet related or not.

FYI: It is for an offgrid system, without WiFi and the connections will be made via an Ethernet cable.

Thanks for your help!

Fernando

communication protocol
2 |3000

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

5 Answers
wkirby avatar image
wkirby answered ·

If you are comfortable with ModbusTCP then I'd use that. No need for a broker.
Did you get yourself a copy of the Modbus register list? It's in the Whitepapers list of the documents section.
https://www.victronenergy.com/support-and-downloads/whitepapers

MQTT has it place for sure, but Modbus might be easier for certain things.

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.

fcriado avatar image fcriado commented ·

I am discovering both protocols, so I don’t really mind on which to use for this application, as I will have to learn anyway.

The broker would be the CCGX, isn’t it?


0 Likes 0 ·
mariowagner avatar image
mariowagner answered ·

If you have direct connection (Ethernet) and a modbus-client implementation for your target, ModbusTCP is pretty easy. I use it to attach Victron systems to our process control infrastuctures (SPC's).

Venus devices have a Mosquitto MQTT broker installed. i haven't tested, but should be handy too. the repo tells it all: https://github.com/victronenergy/dbus-mqtt

What is your own target? SPC? PC? Raspberry?

all the best for your dev, mario

2 |3000

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

Peter Polz avatar image
Peter Polz answered ·

Clear preference for modbus. .. Simple, Industrie Standard since many years,.. you also can use it with SPS , logo and many many other devices.

2 |3000

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

fcriado avatar image
fcriado answered ·

Hi everyone!

The idea is to use a RPi which will be receiver of the information from the CCGX, and connected by Ethernet.

Then the Rpi will calculate how much load it can derive to the water heater and it will send the command to an esp8266 8it is necessary this esp8266 as the distance between the Rpi and the water heater will be around 20 meters) to control a Triac, which will power the water heater.


Then, knowing the installation, you continue to recommend Modbus? I will have to learn anyway the one I decide to use in this project.

@MarioWagner: May you share an example of the code you use?


Thanks for your answers @Peter Polz, @MarioWagner and @WKirby !!

Best regards,

Fernando


P.S. : @mvader (Victron Energy Staff), @Guy Stewart (Victron Energy Staff), @Johannes Boonstra (Victron Energy Staff) Which is Victron's point of view ?

9 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.

mvader (Victron Energy) avatar image mvader (Victron Energy) ♦♦ commented ·

Hi fcriado; its just a choice. Both are good (mqtt and modbustcp). You could consider to run your code on the CCGX as well; and thereby eliminate the extra box. More information about that here:

https://www.victronenergy.com/live/ccgx:root_access

Anyway, whichever code you make; if it uses modbustcp or mqtt then you can always move it later: it will run both on an external box and local.

0 Likes 0 ·
fcriado avatar image fcriado mvader (Victron Energy) ♦♦ commented ·

Thanks @mvader (Victron Energy Staff)!

So if it is just a choice to make, I will follow the tips I have received and use ModbusTCP.

Frankly, I didn’t even thought of using the CCGX for the calculations. Won’t I saturate CCGX capabilities? That’s why I had the idea of using the RPi, and use only the CCGX to provide the necessary information.

However I didn’t understand your last comment about moving the code between an external box and local. Do you mean to port it to the RPi later?

Best regards,

Fernando

0 Likes 0 ·
mvader (Victron Energy) avatar image mvader (Victron Energy) ♦♦ fcriado commented ·

Hi again Fernando,


Depending slightly on how you do it; your code will be able to run both on the rpi or on the Ccgx. Without any changes. If indeed it saturates; you can move in to the pi.


Btw a few seconds ago someone posted example python code that uses ModbusTCP. See here:

https://groups.google.com/forum/m/?utm_medium=email&utm_source=footer#!msg/victron-dev-venus/6w2xJVfLjLo/NI7PN6RlCAAJ

Note that that mailinglist is also the best place for more questions regarding software development of and around Venus OS

0 Likes 0 ·
fcriado avatar image fcriado mvader (Victron Energy) ♦♦ commented ·

Hi again mvader,

To be safe, I will install it first on a RPi, as I am not often at home I would like that my family has a problem they don't know how to resolve!

I will upload the code to github, and if some colleagues with more time than me find it stable and optimized, I will get rid of the Rpi.

Thanks for the code! It is easier to use something reading some code! I am really happy that Victron took the open-source route!

Is it better to post updates here or in the mailing list?

Best regards,

Fernando

0 Likes 0 ·
mvader (Victron Energy) avatar image mvader (Victron Energy) ♦♦ fcriado commented ·

Hi, yes once you are going to take in detail about python code; lets use the developer mailing list.

0 Likes 0 ·
mariowagner avatar image mariowagner commented ·

u can have a look at my code. no problem. its in ansi c, but very specific to my B&R SPC target. dont think it will help much for your implementation. i`d do what mvader suggests: use the CCGX. btw: our partner Elektro Meisl developed a system that exactly does what u need.

0 Likes 0 ·
fcriado avatar image fcriado mariowagner commented ·

Hi Mario,

Thanks for your answer! May you point me which is that system? In their website I am not able to found it.

Regards,

Fernando

1 Like 1 ·
mariowagner avatar image mariowagner fcriado commented ·

hi again, i've seen that system in their office. i'll check how and if it's available & what the price might be. i'll let u know beginning of next week

0 Likes 0 ·
mariowagner avatar image mariowagner fcriado commented ·

i remember: i saw that system: http://smart1easy.eu

but i guess it costs a few bucks ... i'll check with them


0 Likes 0 ·
Ole Saether avatar image
Ole Saether answered ·

Hi!

I have uploaded a few python scripts that control the relays with Modbus or MQTT to github:
https://github.com/osaether/code-snippets/tree/master/victronenergy

Take a look at them to see how you can control the CCGX hardware. Just replace the name/registers with the ones you want to control.

Ole

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.

fcriado avatar image fcriado commented ·

Hi! I saw your post on ModbusTCP in the google group (in fact i asked a question there ;) )

What I have to do now, is to buy a switch, a RPi and upload the code I need.

Thank you!


0 Likes 0 ·

Related Resources

Additional resources still need to be added for this topic