Ethernet connection with an ESP32 PLC or an M-Duino PLC

How to configure and test Ethernet on Industrial Shields PLCs using the Arduino Ethernet library
June 12, 2026 by
Ethernet connection with an ESP32 PLC or an M-Duino PLC
Boot & Work Corp. S.L, Queralt del Águila Munté

In this blog post, we explain how to configure and test Ethernet connectivity on any ESP32 PLC or M-Duino PLC from Industrial Shields, using the Arduino Ethernet library.

The example sketch connects the PLC to the internet via DHCP, identifies the Ethernet hardware chip, verifies the local IP address, and attempts a TCP connection to a remote host. Once uploaded through Arduino IDE, you can confirm that the Ethernet port is working correctly.

Connecting the Ethernet port

Connect an Ethernet cable from the PLC to any Ethernet port on your network (switch, router, or PC). No additional wiring is required.

For connector pinout and hardware details, check the Technical Features page for your model.

Ethernet test sketch for Arduino IDE

The sketch uses the Ethernet.h library. Download the following code as a test_ethernet.ino file, verify the board and model, select the correct port, and upload it using Arduino IDE.

#include <Ethernet.h>

#define REMOTE "www.google.com"

const uint16_t port = 80;
uint8_t mac[] = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0x01};

EthernetClient c;

void setup() {
  Serial.begin(9600L);
  Serial.println("ethernet started");
  test();
}

void loop() {
  if (!c.connected()) {
    Serial.println("Disconnected");
    test();
  }
  delay(1000);
}

void test() {
  Ethernet.begin(mac);

  switch (Ethernet.hardwareStatus()) {
    case EthernetW5100: Serial.println("W5100 found"); break;
    case EthernetW5200: Serial.println("W5200 found"); break;
    case EthernetW5500: Serial.println("W5500 found"); break;
    default: Serial.println("Unknown hardware"); break;
  }

  uint8_t MAC[6];
  Ethernet.MACAddress(MAC);
  for (int i = 0; i < 6; ++i) {
    if (i > 0) Serial.print(':');
    Serial.print(MAC[i], HEX);
  }
  Serial.println();

  Serial.println(Ethernet.localIP());
  if (Ethernet.localIP() == IPAddress({0,0,0,0})) {
    Serial.println("Local IP FAIL");
  } else {
    Serial.println("Local IP OK");
    if (c.connect(REMOTE, port)) {
      Serial.println("Remote connection OK");
    } else {
      Serial.println("Remote connection FAIL");
    }
  }
}

Verifying the Ethernet connection

After uploading, open the Serial Monitor. If the Ethernet port is working correctly, you should see output similar to this:

ethernet started
W5500 found
AA:BB:CC:DD:EE:1
10.42.0.226
Local IP OK
Remote connection OK

​Search in our Blog

Ethernet connection with an ESP32 PLC or an M-Duino PLC
Boot & Work Corp. S.L, Queralt del Águila Munté June 12, 2026
Share this post
Tags

Looking for your ideal Programmable Logic Controller?

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

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

PLC Comparison