This project is a way to control an Arduino or my Arduino atmega644/1284 clone via a PC or a human-machine interface connected to the Arduino Ethernet shield. You will create a SCADA system to control your system from a long distance.

Why I created this clone of Arduino? Just to have more inputs/outputs pins to control more complicated systems. These are the correlation between Arduino uno pins and my atmega644/1284 clone pins:

D2 – Ethernet interrupt (optional with solder bridge “INT”) (clone pin D10)
D4 – SD SPI CS (clone pin D0 )

D10 – Ethernet SPI CS (clone pin D4 )

D11 – Not connected (but should be SPI MOSI) (clone pin D5)

D12 – Not connected (but should be SPI MISO) ( clone pin D6)

D13 – SPI SCK ( clone pin D7 )

A0 – SD Write Protect (clone pin A0)

A1 – SD Detect (clone pin A1)

These pins are used for the communication between the clone and the ethernet, so you do not have to use it for anything else.

Why using MODBUS TCP communication? Because it’s an easy and secure way to communicate with distant systems. The open source and free project AdvancedHmi has a driver which provide this communication and Arduino library to use is the “mudbus library” only. The others don’t work because AdvancedHMI provides a MODBUS TCP not a MODBUS RTU OVER TCP nor a MODBUS RTU (serial com, but now with the new version of advancedHMI, not tested here). For more information on MODBUS go on

The site for mudbus library:

The site for AdvancedHMI, a very catchy HMI go on:

(you need to install Visual Basic Express 2010 or higher before running AdvancedHMI)

This project will allow driving an Arduino Uno or Arduino atmega644 / 1284 clone that I made in a previous article using a PC or HMI interface via an ethernet shield under the MODBUS TCP protocol. This will allow for a supervisory system or SCADA. Why do it on this clone? The board Arduino Uno has a number of inputs/outputs but adding the Ethernet shield still mobilizes terminals that are unusable for other applications. These terminals are for the Arduino UNO (correspondence of the Arduino atmega644 / 1284 clone in parenthesis):


D2 – Ethernet interrupt (optional with solder bridge “INT”) (D10 du clone)
D4 – SD SPI CS (D0 du clone)

D10 – Ethernet SPI CS (D4 du clone)

D11 – Not connected (but should be SPI MOSI) (D5 du clone)

D12 – Not connected (but should be SPI MISO) (D6 du clone)

D13 – SPI SCK (D7 du clone)

A0 – SD Write Protect (A0 du clone)

A1 – SD Detect (A1 du clone)

The Arduino clone with ethernet shield will allow me to benefit from more inputs/outputs. These terminals cannot be used for other things. Why use TCP modbus? It is a communication protocol that is easy to implement, robust and widely used in the industry. The interface of the project advancedHMI has a driver that manages this protocol, while the Arduino recognizes the frames thanks to the library “mudbus” to download. Warning: this is not modbus RTU over TCP (consult the following documentation:

The website of the mudbus library for Arduino 1.0.5:

The AdvancedHMI site (you must first install the free Visual Basic Express 2010 software):010):

Step 1: The Program De Arduino Atmega644 / 1284 Clone





The modbus TCP communication is done by reading registers and written registers of 16 bits each that you have to create under the mudbus library in the Arduino program like this:

Mb.R[0] to Mb.R[255] for example (for 16 bits registers)
Mb.C[0] to Mb.C[255] for example (for 1 bit registers)

You can use the register you want Mb.R[i] or Mb.C[i].

You can’t reach directly the input or output pin of the clone so you need to use these registers.

In the programme supplied for the clone, you need to know there is a different pin addressing between the Arduino uno and the clone:

Example: Arduino Uno pin D8: connexion pin 20 of the atmega644/1284 clone: so address 14 (D14) (see the previous table in my Arduino clone project).

In my simple program, you ‘ve got the way to use these register with inputs and outputs.

With the ethernet, remenber that you need to give an IP adresse to the shield. In my exemple:

uint8_t ip[] = { 192, 168, 1, 244};
uint8_t gateway[] = { 192, 168, 1, 1 };

uint8_t subnet[] = { 255, 255, 255, 0 };

See the supplied example.

Next, the link between Arduino clone registers and AdvancedHMI widgets.

Modbus TCP communication will be via 16-bit read or write register created by the Arduino mudbus library and bearing the names of Mb.R [0] to Mb.R [255] for example Mb.C [0] to Mb.C [255] for example One or other of these registers can be used interchangeably. The inputs/outputs of the Arduino cannot be directly controlled or supervised. It is obligatory to go through these registers. In the program provided for the Arduino clone think to take into account the change of pine: Arduino Uno pins D8: pin connection 20 atmega644 / 1284: hence address 14 (D14). The example provided gives you the basic structure to use to manage these communication registers. To configure the ethernet shield, you only have to modify the following topics according to your network:

uint8_t ip[] = { 192, 168, 1, 244};
uint8_t gateway[] = { 192, 168, 1, 1 };

uint8_t subnet[] = { 255, 255, 255, 0 };

I join the example.

modbusTCPetherShield.inomodbusTCPetherShield.ino       Download

Step 2: Aspect De L’interface AdvancedHMI





In this prototype HMI or SCADA, I just used:

-a switch button to control pin D8 Arduino uno (or pin D14 atmega644/1284 clone). This output is control via the register Mb.R[8] (for example) and the link with the AdvancedHMI widget is the address 40009 (for Arduino uno) or 40015 (for atmega644/1284 clone).

-a 4 digits display with displays the value of the Mb.R[5] (for example) in the Arduino program and the link with the AdvancedHMI widget is the address 40006 (for Arduino uno or for atmega644/1284 clone).

In AdvancedHMI remember you have to give to the ModbusTcpCom1 driver the IP address of the Arduino Ethernet shield so in my example.

I just contented myself: a 4-digit display displaying the value of the register Mb.R [5] (arbitrarily chosen) on the Arduino side and whose correspondence is the address 40006 seen by the HMI. Remember to set the ModbusTcpCom1 driver with the address of your shield (set by your program under Arduino 1.0.5).


Step 3: Modification De La Librairie Mudbus Pour Atmega 644p Et 1284p



WARNING: to adapt the mudbus library to the atmega644/1284 clone you need to modify the file arduino/libraries/Ethernet/utility/w5100.h and add this line:

… || defined(__AVR_ATmega1284P__) || defined (__AVR_ATmega644P__)

Now it’s up to you.

WARNING: if you use the mudbus library for the Arduino atmega644 / 1284 clone you must modify the file Arduino / libraries / Ethernet/utility / w5100.h otherwise nothing will work. Just add the following lines at a time in the program: … || defined (__ AVR_ATmega1284P__) || defined (__AVR_ATmega644P__) Now you can try.

Step 4: Acknowledgments And Perspectives:


Very big thanks to:…

I don’t have tested the SD card using the moment. I tested another HMI called UNIGO free version under the android tab or phone and it runs very well on my SCADA controlled systems of my company.

some important link here:

I have not tested the use of the SD card. I tested the MODBUS slave library for Arduino trying to have the communication between advancedHMI and Arduino via a TCP / serial RS232 module but it is modbus RTU and it does not work. That would have freed me from the Ethernet shield. On the other hand, this communication worked very well with the application UNIGO for Android which it proposes MODBUS TCP or MODBUS RTU over TCP. I look forward to the new version of the project advancedHMI which I hope will integrate this feature.

Author:  manu4371

original Source:


Please Login to comment
Notify of