Jan-22-2022, 12:40 PM
Using the async_modbus library (built on the top of umodbus https://pypi.org/project/async-modbus/) it works very well. I have used this library with success. Please find below the syntax,
Reading holding registers ADAM3066
reply: [65535 65535 65535 65535 289 65535 65535 65535]
The ADAM 3066 is a RS-485 MODBUS RTU 1-WIRE interface connected to a MODBUS TCP gateway at 192.168.1.200, I have one sensor connected on the input 5 of ADAM 3066 which return a temperature of 28.9 degrees C
async def get_var_modbus(loop): reader, writer = await asyncio.open_connection('192.168.1.200', 502) client = AsyncTCPClient((reader, writer))loop=loop, port=502, timeout=20, unit=3) while True: print("Reading holding registers ADAM3066") reply = await client.read_holding_registers(slave_id=3, starting_address=0, quantity=8) print("reply:",reply) await asyncio.sleep(1)OUTPUT:
Reading holding registers ADAM3066
reply: [65535 65535 65535 65535 289 65535 65535 65535]
The ADAM 3066 is a RS-485 MODBUS RTU 1-WIRE interface connected to a MODBUS TCP gateway at 192.168.1.200, I have one sensor connected on the input 5 of ADAM 3066 which return a temperature of 28.9 degrees C