Python Forum
Simple syntax to asynchronously get access to MODBUS register
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple syntax to asynchronously get access to MODBUS register
#2
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,
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
Reply


Messages In This Thread
RE: Simple syntax to asynchronously get access to MODBUS register - by orion67 - Jan-22-2022, 12:40 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Pymodbus Write value to register stsxbel 10 8,316 Aug-18-2022, 01:42 PM
Last Post: DeaD_EyE
  Modbus-tk library catching modbus-tk exception zazas321 1 2,126 Nov-10-2020, 03:06 PM
Last Post: Larz60+
  simple f-string expressions to access a dictionary Skaperen 0 1,541 Jul-15-2020, 05:04 AM
Last Post: Skaperen
  Login and Register system finndude 1 2,430 Apr-24-2020, 10:05 PM
Last Post: deanhystad
  AttributeError: 'Register' object has no attribute 'bit_7' colt 1 2,016 Dec-12-2019, 09:39 PM
Last Post: micseydel
  simple syntax question speedskis777 7 3,659 Mar-11-2019, 02:26 AM
Last Post: snippsat
  How to implement class register? AlekseyPython 0 2,012 Feb-14-2019, 06:19 AM
Last Post: AlekseyPython
  simple register code aocii 2 2,651 Dec-22-2018, 11:15 AM
Last Post: aocii
  Segmentation fault when connecting to modbus device with Libmodbus alice 0 2,476 Dec-18-2018, 04:03 PM
Last Post: alice
  Python script runs on startup but does not register keystrokes. mericanpi 3 3,479 Sep-07-2018, 02:58 PM
Last Post: mericanpi

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020