Modbus TCP Master

Hello Expert,

I am new in Arduino. I need your help .
I want to read a data register from Modbus tcp slave in Arduino and send it to serial port.
I have Arduino UNO and W5100 ethernet shield.

Please help me.

Modbus TCP has client and server, not slave and master. I query a TCP server without library with simple functions, for example in this project: https://github.com/jandrassy/IsgModbusTcpSG/blob/master/IsgModbusTcpSG/IsgModbusTcpSG.ino

This Code very much difficult to understand. Can you use a library.

So far I have Done the below codeā€¦
Please help me.

#include <SPI.h>
#include <Ethernet.h>
#include <ArduinoModbus.h>

int GrossWeight;

EthernetClient client;

byte mac = {0x90, 0xA2, 0xDA, 0x0E, 0x94, 0xB5 };
IPAddress ip(192, 168, 0, 20);
IPAddress gateway(192, 168, 0, 1);
IPAddress subnet(255, 255, 255, 0);

IPAddress remSlaveIP(192, 168, 0, 21);
int port = 502;

void setup() {
//Initialize Serial
Serial.begin(9600);
// Ethernet setup
Ethernet.begin(mac, ip, gateway, subnet);
// Initialize the connection between Arduino and Data server
if (!client.connected()) {
client.stop();
client.connect(remSlaveIP,port);
}
}

void loop() {

}

fpramanik: This Code very much difficult to understand. Can you use a library.

use the modbusRequest function as a library. copy it at the end of your sketch. you don't have to understand it. see the rest of the sketch as an example on how to use it