Modbus on a PI using Python works, but only empty results

71 views Asked by At

In my first Modbus experiment on a PI, I can connect to the device. But all values I get returned are zero. As you can see from my code, I am new to this. What am I doing wrong?

from pymodbus.client.sync import ModbusSerialClient
client = ModbusSerialClient("rtu", port="/dev/ttyUSB1", baudrate=115200, timeout=1)
for i in range(5000):
      s=client.read_holding_registers(r,2, unit=33).registers[0]
print(i,s)
0

There are 0 answers