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

#!/usr/bin/env python3

# Modbus
from pymodbus.constants import Defaults
from pymodbus.constants import Endian
from pymodbus.client.sync import ModbusTcpClient as ModbusClient
from pymodbus.payload import BinaryPayloadDecoder
from pymodbus.payload import BinaryPayloadBuilder
from time import sleep

#===================================

# GX Device I.P Address
ip = '192.168.20.156'
client = ModbusClient(ip, port='502')

#===================================

# ModBus Unit ID
SolarCharger_1_ID = 226
SolarCharger_2_ID = 224
SolarCharger_3_ID = 239
MultiPlus_ID      = 227
Bmv_ID            = 223
VEsystem_ID       = 100

#===================================

def modbus_register(address, unit):
    msg     = client.read_input_registers(address, unit=unit)
    decoder = BinaryPayloadDecoder.fromRegisters(msg.registers, byteorder=Endian.Big)
    msg     = decoder.decode_16bit_int()
    return msg

while True:

    # Battery Section
    BatterySOC       = modbus_register(266,Bmv_ID) / 10
    BatteryWatts     = modbus_register(842,VEsystem_ID)
    BatteryAmps      = modbus_register(261,Bmv_ID) / 10
    BatteryVolts     = modbus_register(259,Bmv_ID) / 100
    BatteryState     = modbus_register(844,VEsystem_ID) # Battery System State 0=idle 1=charging 2=discharging
    ChargeCycles     = modbus_register(284,Bmv_ID)
    BatteryTTG       = modbus_register(846,VEsystem_ID) / .01
    ConsumedAH       = modbus_register(265,Bmv_ID) / -10
    
    if BatteryState == 0:
        BatteryState = "Idle"
    elif BatteryState == 1:
        BatteryState = "Charging"
    elif BatteryState == 2:
        BatteryState = "Discharging"


    print(f"Battery SOC: {BatterySOC} %")
    print(f"Battery Watts: {BatteryWatts}")
    print(f"Battery Amps: {BatteryAmps}")
    print(f"Battery Volts: {BatteryVolts}")
    print(f"Battery State: {BatteryState}")
    print(f"Battery Charge Cycles: {ChargeCycles}")
    print(f"Battery TTG: {BatteryTTG}")
    print(f"Battery Consimed AH: {ConsumedAH}")
    print(f"=======================================")
    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

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