This Arduino library allows you to implement the Modbus RTU protocol on any Arduino-supported microcontroller board. It supports both client and server modes. The library depends on the CSE_ArduinoRS485 library from CIRCUITSTATE Electronics. You can use both hardware and software serial ports for communication.
This library is in pre-release stage and any feedback is welcome.
This library is available from the official Arduino Library Manager. Open the Arduino IDE, search for CSE_ModbusRTU and install the latest version of the library.
Additionally, you can download the latest release package from the GitHub repository and install it manually. To do so, open the Arduino IDE, go to Sketch > Include Library > Add .ZIP Library… and select the downloaded file.
Another method is to clone the GitHub repository directly into your libraries folder. The development branch will have the latest features, bug fixes and other changes. To do so, navigate to your libraries folder (usually located at Documents/Arduino/libraries on Windows and ~/Documents/Arduino/libraries on macOS) and execute the following command:
git clone https://github.com/CIRCUITSTATE/CSE_ModbusRTU.git
The library can also be installed via PlatformIO. All officially listed Arduino listed libraries are automatically fetched by PlatformIO. Use the lib_deps
search option to install the library.
Two examples are included with this library:
-
ModbusRTU_Client_LED - Acts as a Modbus RTU Client and sends periodic requests to a Modbus RTU Server to control an LED via Coil data.
-
ModbusRTU_Server_LED - Acts as a Modbus RTU Server and responds to requests from a Modbus RTU Client to control an LED using Coil data.
You can find the complete API reference for this library at API.md.