question

willeert avatar image

Anyone reading CCGS modbus registers with an Arduino?

I am new to the Victron community and this brand of equipment. I need to read / write the modbus registers of the CCGX using an Arduino for an AC Coupled off grid system I am planning. I am familiar with Modbus RTU but not TCP and have a diversion control operating for my existing DC coupled system using Arduino and the Midnite Classic. My question is: Is anyone already communicating with the CCGX using Arduino to Read / Write the CCGX Modbus registers? Any help or info will be much appreciated. Thank you.

Will

Modbus TCP
2 |3000 characters needed characters left characters exceeded

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

8 Answers
shaneyake avatar image
shaneyake answered ·

You will need an ethernet shield but this is a good place to start.
https://www.arduino.cc/en/ArduinoModbus/ArduinoModbus

2 |3000 characters needed characters left characters exceeded

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

willeert avatar image
willeert answered ·

Thank you for your reply. I have located a Modbus Master TCP library and loaded them in my IDE. I have looked at the examples and thought about them. It seems to me that I need, as you suggest, an ethernet shield. I am guessing theat the CCGX will need to have a modem or some form of wireless broadcasting device connected to it's port. A difficulty I see is that the TCP libraries do not seem to have a place to enter the unit ID # unless this is what this line of code signifys: " ModbusTCP node(1)" // unit identifier. Also the one library I can find that configures the Arduino as a TCP master has large delays in it. There must be something better - I just have not found it yet.

I have also learned that any Victron ....GX device will do Modbus TCP communications so the question becomes:


Does anyone use an Arduino to communicate with an Victron GX device?


Will

1 comment
2 |3000 characters needed characters left characters exceeded

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

The unit id is speficed when a read is done like:

holdingRegisterRead(int id, int address);

id is unit id
address is register address.

You can connect a ethernet cable directly from the Arduino to the CCGX ethernet port, no need for a router. You then give both devices static ip address.

kevgermany avatar image
kevgermany answered ·

Not sure if you realise that the ccgx has RJ45/ethernet ports.

Somewhere in the maze of victron documentation is all the modbus stuff. From memory, what Victron call VE bus is straightforward ethernet.

What you also need to watch is that if you go wireless, many of the current dongles don't work.

I thought about going down the Arduino route, decided not to. If I look at it again, I'll use a Raspberry Pi.

2 comments
2 |3000 characters needed characters left characters exceeded

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

The CCGX has an ethernet port, only 1. The rest are VE.BUS which is not ethernet at all, closer to RS485 but is proprietary. The other ports are CAN bus.

Modbus is only available via Ethernet or Wifi.

Thanks for the correction
Jean-Luc avatar image
Jean-Luc answered ·

Hello World, I am new too on this forum ;-) ... with quasi exactly the same request...

Since august I am trying to link an Arduino MKR 1010 + ETH shield to a Cerbo GX that manage my Victron power system on my motorhome.

I used TCP link, and Modbus library.

It is working properly by WIFI or Ethernet cable (straight or inverted) with router. I can read or write registers as I want, except one (on my Multiplus).

But impossible to connect Ethernet directly without router!! Shaneyake seems to say it is possible, if i understand correctly... I cannot reach the Modbus connection. With or without inverted RJ45 cable. Nethertheless, it works properly with the two cables, with my laptop... )-;

I tried Ethernet connection with DHCP Arduino code and static IP adress. Even I identify local adress on the Cerbo GX with my latop on the Ethernet connexion, (in menu), and put it in the Arduino code, it does'nt work... The local IP of the Cerbo change immediately... and no connexion.

Tomorow, I will extract the Arduino code in my motorhome, with router, and I will post it here for Will...

Jean-Luc

PS: sorry for my poor english. (moreover without orthographic online corrector on this frame forum)

2 |3000 characters needed characters left characters exceeded

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

Jean-Luc avatar image
Jean-Luc answered ·

AuxETH_wifi_5a.zip

This ZIP contain Arduino code for MKR 1010 linked with WIFI on Cerbo GX registers, via router.

You need to adapt ID and pass in the arduino_secrets.h file.

You must adapt too your IP cerbo adress, taken in the Cerbo interface (as delivered by the router DHCP). At least, please adapt number of your Modbus ID of Victron components of YOUR system.

You have to control the register adress as described in the XLS file given by Victron on its website (see Cerbo GX downloads).
For the version with Ethernet link via RJ45 cable, I have to check the compilation on an other computer... Some instructions has to be complied with the good libray...


auxeth-wifi-5a.zip (2.6 KiB)
2 |3000 characters needed characters left characters exceeded

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

Jean-Luc avatar image
Jean-Luc answered ·

AuxETH9a.txt must be rename toAuxETH.ino to use with arduino MKR + shield ETH with Ethernet cable. This version works only with router, connected to the Cerbo GX.

@shaneyake says that it is possible to connect directly to Cerbo... But how?? I didn't have success...

@Willeert , you have like this the two syntax (via ethernet or via wifi) to connect GX... enjoy! Be carrefull to libraries.


auxeth9a.txt (5.7 KiB)
2 comments
2 |3000 characters needed characters left characters exceeded

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

Did you set the Cerbo to a static IP address? As well as the arduino? Once that is done it will work, like any other IP network.
Jean-Luc avatar image Jean-Luc shaneyake ·
I don't know how to set the Cerbo in order to manage IP adress... Where is this option in the console menu?

(I don't imagine to use a static adress for the Cerbo in the router, as I don't want to use the Router)

Perhaps you use a PC linked by Ethernet directly, configure the Cerbo as Static adress in Params-Ethernet-Config IP? (by memory, I hasn't the Cerbo tonight). Plug the Arduino at PC's place and connect to the Cerbo with this IP.
Jean-Luc avatar image
Jean-Luc answered ·

I tried to set static adress on Cerbo by menu-Params-Ethernet-Config IP-manual: 169. 254.1.2 for the server (Cerbo)... it displays 'Lier l'adresse locale' just below : 169. 254.55.169. (seen on wifi console)

I used this last adr to connect Arduino to Cerbo, as followed;

Ethernet.begin(mac,ip);
with : IPAddress ip(169, 254, 55.169 ); and byte mac[] = {0xA8, 0x61, 0x0A, 0xAE, 0x45, 0x2D} //Arduino ETHERNET MKR shied

I can see on wifi console on my laptop, that the local adress has moved on the Cerbo to ...169.254. 160.105 ... and it didn't connect...

Idea on what's wrong?

2 |3000 characters needed characters left characters exceeded

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

willeert avatar image
willeert answered ·

HI Jean-Luc,

Thank you form all your work replying to my question. I have been away for few days and am just looking at this topic now. I will download and look at your code - Thank you very much and will post a reply as soon as I can.

Best Regards,

Will



2 |3000 characters needed characters left characters exceeded

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