I am trying to interface Seeed Studio’s RS485 shield for Raspberry Pi along with the Python Minimalmodbus library on Raspberry Pi 2B - NOT WORKING!!!

shield : https://www.seeedstudio.com/RS-485-Shield-for-Raspberry-Pi.html

I tested following on Raspberry Pi:

  • It worked fine if I send data using Python serial library. It turns on a relay on a slave device and responds correctly.
  • ser.write(’\xff\x05\x00\x00\xff\x00\x99\xe4’)

  • It is not working if I use Minimalmodbus library for Python
  • instrument.write_bit(0,1,5)
    minimalmodbus.NoResponseError: No communication with the instrument (no answer)

    note: I used the same Minimalmodbus python code using another USB-to-RS485 converter on same RPi and it worked fine.

    Python Code:

    import minimalmodbus
    import time
    import serial 
    instrument = minimalmodbus.Instrument('/dev/ttyAMA0', 255)
    instrument.serial.baudrate = 9600      
    instrument.serial.bytesize = 8
    instrument.serial.stopbits = 1
    instrument.serial.timeout  = 1          
    instrument.mode = minimalmodbus.MODE_RTU  
    instrument.clear_buffers_before_each_transaction = True
    instrument.debug = True
    while 1:
        instrument.write_bit(0,1,5)
        time.sleep(5)
    **error:**  minimalmodbus.NoResponseError: No communication with the instrument (no answer)
    Can anybody help if I can use this specific rs485-shield with Minimalmodbus library? Thank you in advance
    Regards,