Arduino Library – RS485 Modbus

library iconarduino logo rond

Installatie van Arduino IDE libraries: Arduino info

Informatie (ENG):

Arduino Library – RS485 Modbus (smarmengol)

libmodbus is a library that provides a Serial Modbus implementation for Arduino.

A primary goal was to enable industrial communication for the Arduino in order to link it to industrial devices such as HMIs, CNCs, PLCs, temperature regulators or speed drives.

now you can use software serial with the update from Helium6072!


It is not compatible with ARDUINO LEONARDO and not tested under ARDUINO DUE and newer boards.


Common to Master and Slave:

  1. Implement other Serial settings: parity, stop bits, …
  2. End frame delay, also known as T35
  3. Test it with several Arduino boards: UNO, Mega, etc..
  4. Extend it to Leonardo


  1. Function code 1 and 2 still not implemented
  2. Function code 15 still not implement
  3. Other codes under development

New features by Helium6072 29 July 2016

  1. “port->flush();” changed into “while(port->read() >= 0);”

Since Serial.flush() (port->flush(); in ModbusRtu.h line 287, 337, & 827) no longer empties incoming buffer on 1.6 ( : flush() “Waits for the transmission of outgoing serial data to complete. Prior to Arduino 1.0, this instead removed any buffered incoming serial data.), use “while(port->read() >= 0);” instead.

  1. software serial compatible

New constructor Modbus::Modbus(uint8_t u8id) and method void Modbus::begin(SoftwareSerial *sPort, long u32speed) that makes using software serial possible. Check out sexample “software_serial_simple_master” and learn more!

Download RS485 Modbus bibliotheek (smarmengol) @ GitHub