---
title: "How to Implement OpenPLC on STM32 with W5500 Ethernet and Modbus TCP"
url: "https://maker.wiznet.io/jakelee/projects/how-to-implement-openplc-on-stm32-with-w5500-ethernet-and-modbus-tcp/"
markdown_url: "https://maker.wiznet.io/jakelee/projects/how-to-implement-openplc-on-stm32-with-w5500-ethernet-and-modbus-tcp/md"
type: "UCC: User Created Content"
author: "Pablo Jean"
author_url: "https://openplc.discussion.community/post/implementing-the-openplc-on-a-stm32-microcontroller-with-a-tcp-modbus-13613656"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "Pablo Jean"
original_url: "https://openplc.discussion.community/post/implementing-the-openplc-on-a-stm32-microcontroller-with-a-tcp-modbus-13613656"
published: "2026-06-29"
language: "en"
hardware: ["Espressif ENC28J60", "WIZnet W5500"]
likes: 0
views: 363
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# How to Implement OpenPLC on STM32 with W5500 Ethernet and Modbus TCP

> OpenPLC natively supports W5100 and W5500 Ethernet controllers, enabling Modbus TCP on STM32 using the Arduino Ethernet API.

Original author: Pablo Jean (source: https://openplc.discussion.community/post/implementing-the-openplc-on-a-stm32-microcontroller-with-a-tcp-modbus-13613656)

## Components

- **Espressif ENC28J60** x 1
- **WIZnet W5500** x 1 ([docs](https://docs.wiznet.io/Product/Chip/Ethernet/W5500))

WIZnet parts: W5500 ([Datasheet](https://docs.wiznet.io/Product/Chip/Ethernet/W5500/datasheet?utm_source=maker&utm_medium=project&utm_campaign=w5500), [product hub](https://maker.wiznet.io/products/w5500/))

## Article

## Step 1: Understanding the Hardware

This discussion explores implementing OpenPLC Runtime on an STM32 microcontroller with Ethernet connectivity for Modbus TCP communication.

The developer considered using either:

- WIZnet W5500

- WIZnet W5100

- ENC28J60

However, the OpenPLC project maintainer confirmed that the current runtime **already supports W5100 and W5500**, while ENC28J60 would require a custom Ethernet driver.

Typical hardware includes:

- STM32 microcontroller

- W5500 Ethernet controller

- SPI interface

- OpenPLC Runtime

- Modbus TCP communication

The W5500 provides:

- Hardwired TCP/IP stack

- Integrated Ethernet MAC + PHY

- 8 independent hardware sockets

- 32 KB internal TX/RX buffer

- SPI interface up to 80 MHz

Using the W5500 allows developers to add industrial Ethernet networking without implementing a software TCP/IP stack.

## Step 2: Native W5500 Support in OpenPLC

One of the most valuable insights from this discussion is that OpenPLC Runtime already includes support for WIZnet Ethernet hardware.

According to the OpenPLC maintainer:

- Modbus TCP can be enabled directly from the upload dialog.

- The runtime supports **W5100 and W5500**.

- Ethernet communication uses the Arduino Ethernet libraries.

- Hardware wiring follows the same approach as a standard Arduino Ethernet Shield.

This means developers can focus on PLC logic rather than low-level Ethernet driver development.

## Step 3: System Architecture

The communication architecture is straightforward:

```plaintext
OpenPLC Runtime
        │
   Arduino Ethernet API
        │
        ▼
      W5500
        │ SPI
        ▼
      STM32 MCU
        │
    PLC Logic
        │
        ▼
  Modbus TCP Clients
```

The W5500 handles:

- TCP/IP processing

- Socket management

- ARP

- ICMP

- UDP

- TCP communication

Meanwhile, the STM32 executes ladder logic and application-specific PLC tasks.

This separation simplifies firmware development and helps maintain deterministic PLC execution.

## Step 4: Firmware Integration

OpenPLC leverages the Arduino Ethernet API, so developers do not need to create a custom Ethernet stack for the W5500.

Conceptual initialization:

```plaintext
// Conceptual example based on WIZnet ioLibrary
// Not project-specific source code

uint8_t tx_size[] = {2,2,2,2,2,2,2,2};
uint8_t rx_size[] = {2,2,2,2,2,2,2,2};

void ethernet_init(void)
{
    wizchip_init(tx_size, rx_size);

    wiz_NetInfo netinfo = {
        .ip = {192,168,1,100},
        .sn = {255,255,255,0},
        .gw = {192,168,1,1}
    };

    wizchip_setnetinfo(&netinfo);
}
```

**Conceptual integration example based on WIZnet ioLibrary (not project-specific).**

The OpenPLC maintainer also notes that developers can reference the Arduino examples included with the OpenPLC editor when adapting the runtime for supported hardware.

## Step 5: Industrial Applications

Combining STM32, W5500, and OpenPLC creates a compact and cost-effective industrial controller suitable for:

- PLC-based machine control

- Factory automation

- Modbus TCP remote I/O

- Industrial gateways

- Building automation

- Process control

- Educational PLC platforms

Because the W5500 offloads Ethernet communication in hardware, the STM32 can dedicate more processing time to real-time PLC execution.

## FAQ

### Q1: Why use W5500 with OpenPLC?

**A:** W5500 is officially supported by the OpenPLC runtime and provides a hardwired TCP/IP stack. This reduces software complexity and allows developers to implement Modbus TCP without writing a custom Ethernet driver.

### Q2: Does OpenPLC support ENC28J60?

**A:** Not natively. According to the OpenPLC maintainer, developers would need to implement their own driver for ENC28J60, whereas W5100 and W5500 are already supported by the runtime.

### Q3: How is the W5500 connected to STM32?

**A:** The W5500 connects via SPI and is accessed using the Arduino Ethernet API. OpenPLC uses this API, so wiring follows the same approach as an Arduino Ethernet Shield.

### Q4: What advantages does W5500 provide for PLC applications?

**A:** The W5500 offloads TCP/IP processing, manages eight hardware sockets, and integrates the Ethernet MAC and PHY. This reduces MCU workload and improves communication reliability in industrial Ethernet applications.

### Q5: What applications are suitable for this architecture?

**A:** Typical applications include industrial control systems, Modbus TCP gateways, educational PLC projects, machine automation, distributed I/O controllers, and Ethernet-enabled process monitoring.

---

Source: https://maker.wiznet.io/jakelee/projects/how-to-implement-openplc-on-stm32-with-w5500-ethernet-and-modbus-tcp/
