I have a Modbus server setup on a LAN with IP address 192.168.0.111 and Modbus map is this snip below where I am trying read the sensor highlighted yellow:
Can someone give me a tip on how to run a Modbus client script and read the sensor value?
from pymodbus.client import ModbusTcpClient
client = ModbusTcpClient('192.168.0.111')
result = client.read_coils(30500,1)
print(result.bits[0])
client.close()
This will error out:
print(result.bits[0])
AttributeError: 'ExceptionResponse' object has no attribute 'bits'
Experimenting a bit and changing the print to print(result)
this will return without an exception
Exception Response(129, 1, IllegalFunction)