Hits: 38564

Reading some forum and blog about  some Modbus implementation for Arduino I feel my curiosity grow up about that..then I decided to test it on my on Arduino Mega 2560 board. I have to admit I've been successfully surprised! In few steps I saw a full running system that could represent a good source point to practice with Modbus Scada (as Proview). Following I wrote the steps I've done:

HW used:

  1. Arduino Mega 2560 
  2. Arduino Ethernet Shield R3

Software used:

  1. Arduino IDE 1.5.5 (free download  from Arduino main website)
  2. Arduino Modbus TCP server (Mudbus.h v.1.0)


Into Arduino IDE, first of all it's necessary to import the Mudbus.h library by "import library" command:



Then just type the following Sketch:


 Into the sketch I've got:

  1. Mb.R[0]=Mb.R[1];                     mapping Modbus register 1 to register 0 (I wrote register 1 from an external client (ex. Modbus Poll)
  2. Mb.C[0]=digitalRead(In22);      mapping Digital Input 22 to Modbus Coil 0


Looking at Wireshark  log, it shows the Modbus (Modbus Poll) Client Interrogation by FC03 "read Holding Register" (10 Register starting from addr 1). Client IP = --> Destination (Arduino) =


And this is the Arduino Modbus Server answer (Source --> Destination192.168.1.100)



The Mudbus.h lib can manage just 2 data type: coil (r/w) and  register (r/w)

This is the note from Google Code website:

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 and a website at

Here following some useful link: