Arduino Library – Modbus

library iconarduino logo rond

Modbus bibliotheken

Installatie van Arduino IDE libraries: Arduino info


Modbus RTU (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!

KNOWN ISSUES

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

TODO List

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

Master:

  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 (Arduino.cc : 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


Modbus RTU (SimpleModbus NG)

SimpleModbus is a collection of Arduino libraries that enables you to communicate serially using the Modicon Modbus RTU protocol.

This project was born as an updated version of http://code.google.com/p/simple-modbus/ by Bester Juan because it lacks support for commands other than 3 and 16. More important the code is now on github, so you can contribute more easily.

This projects is actively maintained, so feel free to ask for features or reporting bugs!

Features

This library adds support for command 6 and provides a more extensive support for arduino pins. The goal of the project is to support all usable MODBUS commands on arduino and expose all arduino pins so you can use an arduino as an advanced automation controller for both analog/digital in/out.

NEW: Support for SoftwareSerial, really useful on AtTiny85. You can find both library and an example that works reliable on attiny85 microcontroller.

Usage

Simply copy the SimpleModbusMaster or SimpleModbusSlave or both into your Arduino IDE libraries folder. Than restart the ide and open the corresponding example into the example_master or example_slave folder.

Download RS485 Modbus bibliotheek (SimpleModbus NG) @ GitHub


Modbus TCP/IP – Mudbus (luizcantoni)

A minimal Modbus TCP slave for Arduino. It has function codes 1(read coils), 3(read registers), 5(write coil), and 6(write register). It is set up to use as a library, so the Modbus related stuff is separate from the main sketch. The register and coil data is held as Mb.R[0-125] signed int and Mb.C[0-128] bool

Martin Pettersson Has furnished some changes for compatibility with Arduino 1.0. He also has a git repository at

Download @ Github


Modbus TCP/IP – MgsModbus

This page is holds my ModbusTCP library for the Arduino. The library gives the program the possibility to be a master, a slave or both on a TCP network.
The Modbus functions 1, 2, 3, 4, 5, 6 15 and 16 are implemented. The port 502 is used as standard.
Please report bugs to me to improve the library.

The library uses a single data space for all the Modbus data. This means that all the Modbus data spaces are overlapping and all starting with 0 (zero). This means that several Modbus functions can reach the same data. The user must assign the correct Modbus address to the data.

This library is started as a spinoff of the Mudbus.h slave library from Dee Wykoff from 2011.

Download @ myarduinoprojects.com


Modbus RTU & TCP/IP (andresarmento)

This library allows your Arduino to communicate via Modbus protocol. The Modbus is a master-slave protocol used in industrial automation and can be used in other areas, such as home automation.

The Modbus generally uses serial RS-232 or RS-485 as physical layer (then called Modbus Serial) and TCP/IP via Ethernet or WiFi (Modbus IP).

In the current version the library allows the Arduino operate as a slave, supporting Modbus Serial and Modbus over IP.

Author’s note (motivation and thanks):
It all started when I found the Modbus RTU Arduino library of Juan Pablo Zometa. I had extend the library to support other Modbus functions.

After researching several other Modbus libraries I realized strengths and weaknesses in all of them. I also thought it would be cool have a base library for Modbus and derive it for each type of physical layer used.

I appreciate the work of all the authors of the other libraries, of which I used several ideas to compose the modbus-arduino. At the end of this document is a list of libraries and their authors.

Features

  • Operates as a slave (master mode in development)
  • Supports Modbus Serial (RS-232 or RS485) and Modbus IP (TCP)
  • Reply exception messages for all supported functions
  • Modbus functions supported:
    • 0x01 – Read Coils
    • 0x02 – Read Input Status (Read Discrete Inputs)
    • 0x03 – Read Holding Registers
    • 0x04 – Read Input Registers
    • 0x05 – Write Single Coil
    • 0x06 – Write Single Register
    • 0x0F – Write Multiple Coils
    • 0x10 – Write Multiple Registers

Download @ Github * andresarmento


Downloads