This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Modbus connect with Victron Venus GX controller
#1
Good morning !
I'm trying to read battery State Of Charge from a Victron Venus GX controller with that LUA script :

Code:
require('luamodbus')
mb = luamodbus.tcp()
mb:open('192.168.1.149', 502)
mb:connect()
r1 = mb:readregisters(843)
log (r1)
mb:close()

I think the connection is not working, because I get the following message in log :
Venus GX 21.05.2019 09:56:05
* nil

Modbus TCP communication of the Venux GX is working well from my Mac with that Python script :

Code:
#!/usr/bin/env python
from pymodbus.constants import Defaults
from pymodbus.constants import Endian
from pymodbus.client.sync import ModbusTcpClient as ModbusClient
from pymodbus.payload import BinaryPayloadDecoder

Defaults.Timeout = 25
Defaults.Retries = 5
client = ModbusClient('192.168.1.149', port='502')
result = client.read_input_registers(843,2)
decoder = BinaryPayloadDecoder.fromRegisters(result.registers, byteorder=Endian.Big)
r1=decoder.decode_16bit_uint()
print("Battery SOC : %d" % (r1))

It's my first time with Modbus TCP on LogicMachine .. so I should have miss something ..
Any help is welcome !
Thanks 

PS/ Here are the Modbus register adresses and types from Victron documentation :

[Image: modbus.jpg]
Reply


Messages In This Thread
Modbus connect with Victron Venus GX controller - by mooselight - 21.05.2019, 08:22

Forum Jump: