Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    Pycom modbus

    Scheduled Pinned Locked Moved Discussion
    2 Posts 1 Posters 41 Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Offline
      Andreas Tollånes
      last edited by

      I'm testing out the official modbus library as, modbus is a critical component of the product we're developing. We're currently based on the ESP32 and RFM95x and the Lopy4 looks like a reasonable replacement with a good ecosystem for managing the devices.

      However, I can't get the regular modbus library to work with the RX485 XY-017 module for testing purposes.

      from uModBus.serial import Serial
      import machine
      
      ######################### RTU SERIAL MODBUS #########################
      uart_id = 0x01
      modbus_obj = Serial(uart_id, pins=('P3', 'P4'))
      
      
      ###################### READ HOLDING REGISTERS ##################
      slave_addr=0x0001
      starting_address=0x0156
      register_quantity=4
      signed=True
      
      register_value = modbus_obj.read_input_registers(slave_addr, starting_address, register_quantity, signed)
      print('Input register value: ' + ' '.join('{:d}'.format(x) for x in register_value))
      

      I'm trying to read the value of slave ID 1 on an eastron modbus meter. Not sure where to start looking even, the info for the library seems very sparse. The XY-017 RX is connected to P3, and TX connected to P4

      The error message:

      Traceback (most recent call last):
        File "main.py", line 25, in <module>
        File "uModBus/serial.py", line 144, in read_input_registers
        File "uModBus/serial.py", line 95, in _send_receive
        File "uModBus/serial.py", line 100, in _validate_resp_hdr
      OSError: no data received from slave
      

      The PDF alluded to in the documentation itself, where is it?
      "For more information on the MODBUS RTU see the following PDF File . Information on the MODBUS TCP can be found Here ."

      1 Reply Last reply Reply Quote 0
      • A Offline
        Andreas Tollånes
        last edited by

        I seem to be unable to edit my message, I wanted to add another question to it: is there perhaps another library that could work well for Lopy that is not the official one? Still not gotten it to work.

        1 Reply Last reply Reply Quote 0

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • 1 / 1
        • First post
          Last post

        Pycom on Twitter

        Pycom