In compliance with high industry standards

Browse our Blog. You will find multiple applications, solutions, code examples. Navigate using the tag cloud or search using specific criteria

Echo TCP Server on Arduino based PLC


On this post is showed how to create a server TCP on an Arduino based PLC. 


Ethernet or 20 I/Os PLC:      Ethernet PLC     20 I/Os PLC    

Industrial Shields boards:   Industrial Shields Boards


Once the server is running, any client can connect to the server. On this example it is used an M-Duino to generate the server. The example of TCP client showed before could be one of the clients.


Next it is showed the Arduino IDE code:

// use Ethernet.h if you have a M-Duino V7 version
#include <Ethernet2.h>

// mac address for M-Duino
byte mac[] = { 0xBE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// Ip address for M-Duino
byte ip[] = { 192, 168, 1, 100 };
int tcp_port = 5566;

EthernetServer server = EthernetServer(5566);

void setup()
  // initialize the ethernet device
  Ethernet.begin(mac, ip);

  // start server for listenign for clients

void loop()
  // if an incoming client connects, there will be bytes available to read:
  EthernetClient client = server.available();
  if (client.available()) {
    // read bytes from the incoming client and write them back
    // to the same client connected to the server


Once the sketch is running on Arduino based PLC any client can connect with this echo server.

For more information see on Arduino web site the TCP functions Ethernet / Ethernet 2 library

Looking for your ideal PLC?

Take a look at this product comparison with other industrial controllers Arduino.

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.

Industrial PLC controller comparison >>

Do you want more information?

Just fill the form!

Tell me more!