title: Modbus RTU on an Raspberry Pi 3b+ as an master
body: <p>My task is to develop an automation system for testing the device.
  I have at my disposal:</p>
  <ul>
  <li>raspberry pi(3b+/4)</li>
  <li>modbus modules: icp con m - 7051D, m - 7055D, m-7061D, and few others.</li>
  </ul>
  <p>At first I want to understand, how I can implement modbus protocol on RPi, how does it work.
  In order to do that, I've used pymodbus library on RPi, which was working as an master, and modbusMAT on an PC, for recieving and decoding instructions from RPi. They were connected via rs-485 - USB adapter.
  I've written some simple code, for writing a coil.
  The RPi is communciating with PC, but the problem is, that the output, doesn't make sense to me.</p>
  <p>Here's the code:</p>
  <pre><code>from pymodbus.client.sync import ModbusSerialClient as ModbusClient
  
  client = ModbusClient(method = 'rtu', port='/dev/ttyUSB0', stopbits=1, bytesize = 8, parity='N', baurdrate = '9600', timeout=0.3)
  connection = client.connect()
  print (connection)
  
  client.write_coils(1, 1, unit=0x01)
  </code></pre>
  <p>Screenshot from modbusMat console</p>
  <p><a href="https://i.stack.imgur.com/gvNxJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gvNxJ.png" alt="enter image description here" /></a></p>
  <p>The output:</p>
  <pre><code>[9C][84][8C][E4][FF]
  [9C][08][8C][B4][FF]
  [9C][84][8C][E4][FF]
  [38][18][18][8C][CA]
  </code></pre>
  <p>The output is related to changes I've made parameters. From top to bottom:</p>
  <pre><code> address=1, values=1, unit=0x01
   address=2, values=1, unit=0x01
   address=1, values=2, unit=0x01
   address=1, values=1, unit=0x02
  </code></pre>
  <p>How I understand is, that if I've set address to 1, then the addres byte on the console should be the same - [01], not [9C].</p>
  <p>I've managed before to successfully send some instructions to the icp modules(turn on, turn off coil) from PC, via RS-485 but not from RPi.</p>