Pycom modbus



  • 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 ."



  • 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.


Log in to reply
 

Pycom on Twitter