MODBUS - RTU Implementation Using AVR ATMEGA32A Controllers and RS485

  • Thread starter Kshitij_Lakhani
  • Start date

Thread Starter



I am an intern and I am currently working on the task of implementing MODBUS-RTU protocol with RS485 as the electrical layer.

I have constructed a simple circuit for 1 master and 2 slaves to communicate serially using the RS485 protocol and have tested it successfully.

Now, I wish to implement the MODBUS protocol for this simple circuit and then use that as a base for complex MODBUS implementations involving larger number of participating devices. For this, I have a acquired good idea of the MODBUS - RTU protocol by going through Modbus_Application_Protocol , Modbus_over_serial_line and Modicon Modbus Implementation Reference Guides - all official documents.

However, now that I have started constructing my code for the slave and master, I am unable to do so easily. Hence, I was looking for guidance on the same. If anyone has implemented the same and can help me with guidance in terms of the code, it would be great. I have been on this since a month and I post this now, because after many efforts I feel the need for some well directed guidance.

In case anyone wished to contact me personally, here is my id - [email protected]

Really appreciate the help.
Thank you!
Have a nice day!


Also you can find a Modbus RTU and TCP slave or master implementation in 'C' source code form at

Since the implementation is in ANSI 'C' you can port it easily to PIC too. The vendor also provides ports to a few popular micro controller cores like 8051, ARM, Coldfire etc. including for some RTOS kernels (OS9, MQX, uc-OS). The library is very light weight consuming negligible RAM and ROM space.