21.05.2019, 08:22
Good morning !
I'm trying to read battery State Of Charge from a Victron Venus GX controller with that LUA script :
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 :
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 :
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 :