question

mikeseaman3000 avatar image
mikeseaman3000 asked

Modbus with Cerbo gx and quattro

Hi Everyone,


I need a little help with Modbus Control. I have a Cerbo gx and quattro unit with pylontech batteries. It is all working perfectly however i am looking to interface to my home automation system.


Does anyone have experience with Modbus TCP registers on here?

I am looking to enable and disable charge plus also have the option to maximise the output of the inverter so that I am able to to discharge to grid where possible. Any help with some configurations of the Modbus.

So basically any help with modbus config is great. I have got the communication working perfectly and able to read values from the cerbo gx, i.e. SOC of batteries.


Appreciate any help.


Thanks

Mike

MultiPlus Quattro Inverter Chargercerbo gxModbus TCP
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
mikeseaman3000 avatar image
mikeseaman3000 answered ·

Any help would be appreciated!

Thanks

Mike

2 |3000

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

paul-fairlight avatar image
paul-fairlight answered ·

Sorry no answers here but it looks like we're both looking for the same or similar thing. I'm using VB6 and I want a MODBUS command string to get the MultiPlus to return the value, SOC, Solar Voltage and more but an answer on how to read just one register from someone out there would be great!

2 |3000

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

elvis avatar image
elvis answered ·

This will print out the status of the Battery.

wait two seconds and print it again.

Change the Unit ID and IP address to match your equipment (Only the BMV and the System ID are used in this example)

To install

pip install pymodbus

  1. #!/usr/bin/env python3
  2.  
  3. # Modbus
  4. from pymodbus.constants import Defaults
  5. from pymodbus.constants import Endian
  6. from pymodbus.client.sync import ModbusTcpClient as ModbusClient
  7. from pymodbus.payload import BinaryPayloadDecoder
  8. from pymodbus.payload import BinaryPayloadBuilder
  9. from time import sleep
  10.  
  11. #===================================
  12.  
  13. # GX Device I.P Address
  14. ip = '192.168.20.156'
  15. client = ModbusClient(ip, port='502')
  16.  
  17. #===================================
  18.  
  19. # ModBus Unit ID
  20. SolarCharger_1_ID = 226
  21. SolarCharger_2_ID = 224
  22. SolarCharger_3_ID = 239
  23. MultiPlus_ID = 227
  24. Bmv_ID = 223
  25. VEsystem_ID = 100
  26.  
  27. #===================================
  28.  
  29. def modbus_register(address, unit):
  30. msg = client.read_input_registers(address, unit=unit)
  31. decoder = BinaryPayloadDecoder.fromRegisters(msg.registers, byteorder=Endian.Big)
  32. msg = decoder.decode_16bit_int()
  33. return msg
  34.  
  35. while True:
  36.  
  37. # Battery Section
  38. BatterySOC = modbus_register(266,Bmv_ID) / 10
  39. BatteryWatts = modbus_register(842,VEsystem_ID)
  40. BatteryAmps = modbus_register(261,Bmv_ID) / 10
  41. BatteryVolts = modbus_register(259,Bmv_ID) / 100
  42. BatteryState = modbus_register(844,VEsystem_ID) # Battery System State 0=idle 1=charging 2=discharging
  43. ChargeCycles = modbus_register(284,Bmv_ID)
  44. BatteryTTG = modbus_register(846,VEsystem_ID) / .01
  45. ConsumedAH = modbus_register(265,Bmv_ID) / -10
  46. if BatteryState == 0:
  47. BatteryState = "Idle"
  48. elif BatteryState == 1:
  49. BatteryState = "Charging"
  50. elif BatteryState == 2:
  51. BatteryState = "Discharging"
  52.  
  53.  
  54. print(f"Battery SOC: {BatterySOC} %")
  55. print(f"Battery Watts: {BatteryWatts}")
  56. print(f"Battery Amps: {BatteryAmps}")
  57. print(f"Battery Volts: {BatteryVolts}")
  58. print(f"Battery State: {BatteryState}")
  59. print(f"Battery Charge Cycles: {ChargeCycles}")
  60. print(f"Battery TTG: {BatteryTTG}")
  61. print(f"Battery Consimed AH: {ConsumedAH}")
  62. print(f"=======================================")
  63. sleep(2)


Here is another handy tool from victron for ModBus

https://github.com/victronenergy/dbus_modbustcp/blob/master/examples/ModbusCli.py

You will still need to

pip install pymodbus

  1. ./ModbusCli -d 192.168.20.156 -r 284 -s 223

This will request the #284 register for the BMV amount of charge cycles


and here is the Victron ModBus manual

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


and


Here is the most recent version of the register XLS file

https://github.com/victronenergy/dbus_modbustcp/blob/master/CCGX-Modbus-TCP-register-list.xlsx

You also may be able to get an idea about some modbus project you may have from here.

https://github.com/optio50/Victron_Modbus_TCP



2 |3000

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