I'm trying to setup the rs485 on the hat and the documentation says to install a jumper but it's not marked on the board clearly?
Also how do I determine the comport , I'm looking at using the following python code example for now to try get it talking:
Also how do I determine the comport , I'm looking at using the following python code example for now to try get it talking:
Python:
from pymodbus.client.sync import ModbusSerialClient as ModbusClient
from pymodbus.exceptions import ModbusException
client = ModbusClient(method='rtu', port='COM PORT ??', baudrate=9600, stopbits=1, parity='N', bytesize=8, timeout=1)
try:
if not client.connect():
print("Unable to connect to the Modbus server")
exit()
slave_address = 1
register_address = 0
response = client.read_holding_registers(register_address, 1, unit=slave_address)
if not response.isError():
print(response.registers)
else:
print("Error reading data: ", response)
except ModbusException as e:
print("Modbus error: ", str(e))
except Exception as e:
print("Unexpected error: ", str(e))
finally:
client.close()