Wiznet makers

TheoIm

Published June 12, 2026 ©

99 UCC

27 WCC

7 VAR

0 Contests

0 Followers

0 Following

Original Link

mirea-rp2040

RP2040 + W5500 OPC UA server using FreeRTOS, ioLibrary, MQTT, DHCP, and open62541 — demonstrating Industrial IoT connectivity on a resource-constrained MCU.

COMPONENTS Hardware components

WIZnet - W5500

x 1


PROJECT DESCRIPTION

What the Project Does

Most W5500 examples focus on basic Ethernet functions such as TCP echo servers, web servers, or MQTT clients. This project goes significantly further by integrating an OPC UA server alongside traditional IoT networking components.

The software stack includes:

Generated By Chat GPT

After booting, the system initializes the W5500, acquires network configuration through DHCP, and starts application services. MQTT examples demonstrate cloud-style messaging, while the OPC UA server exposes structured industrial data to OPC UA clients such as UaExpert.

Unlike simple socket demonstrations, this project implements a complete OPC UA address space that can be browsed, read, and written from standard industrial software tools.


Why This Project Matters

The most interesting aspect is not MQTT.

The real value is the OPC UA implementation.

OPC UA has become one of the most widely adopted protocols in:

  • Smart factories
  • Industrial automation
  • Edge gateways
  • SCADA systems
  • Machine monitoring systems

Many developers assume OPC UA requires Linux-class hardware because of its protocol complexity.

This project demonstrates that an RP2040 combined with a W5500 can host an OPC UA server by leveraging:

  • W5500 hardware TCP/IP offloading
  • FreeRTOS task scheduling
  • open62541 embedded OPC UA stack

The result is a compact Industrial IoT reference architecture suitable for experimentation and prototyping.


Where W5500 Fits

The W5500 acts as the Ethernet transport layer for the entire system.

 
Application Layer
 ├─ OPC UA
 ├─ MQTT
 └─ DHCP
       │
       ▼
WIZnet Socket API
       │
       ▼
     W5500
       │
       ▼
 Ethernet
 

Instead of implementing Ethernet communication directly inside the RP2040, the project routes network traffic through the W5500 socket interface.

This approach is attractive because the W5500 provides:

  • Hardware TCP/IP processing
  • Eight independent sockets
  • 32 KB internal buffer memory
  • SPI interface up to 80 MHz

As a result, the RP2040 can focus on application logic while the Ethernet controller manages packet handling.


Development Highlights

FreeRTOS-Based Networking

The project uses FreeRTOS rather than a traditional polling loop.

Different network services operate in separate tasks:

 
DHCP Task
      │
      ▼
Network Ready
      │
      ├── MQTT Publish Task
      ├── MQTT Yield Task
      └── OPC UA Task
 

This structure resembles real Industrial IoT firmware more closely than typical maker demonstrations.

MQTT Reference Implementation

The DHCP/MQTT example shows:

  • Dynamic IP acquisition
  • Broker connection
  • Publish/Subscribe handling
  • Callback processing
  • RTOS synchronization

Developers building cloud-connected devices can use this section as a reference.

OPC UA Network Porting Layer

One of the most valuable files in the project is:

 
src/opcua62541/w5x00_open62541_net.c
 

This layer bridges:

 
open62541
      │
      ▼
WIZnet Socket API
      │
      ▼
W5500
 

The implementation demonstrates how a large middleware stack can be adapted to WIZnet socket interfaces.

For engineers attempting to port Modbus TCP, EtherNet/IP, BACnet/IP, or custom middleware to W5500 hardware, this file provides an excellent reference architecture.


OPC UA Demonstration

The server exposes several nodes that can be accessed using standard OPC UA clients.

Example address space:

 
Objects
 └─ RP2040
      ├─ TestValue
      ├─ UptimeMs
      ├─ LedState
      └─ ResetTestValue
 

Typical tests include:

  • Browse server nodes
  • Read values
  • Write values
  • Toggle board LEDs
  • Execute OPC UA methods
  • Monitor live data changes

Using UaExpert, developers can immediately verify interoperability with standard OPC UA tools.


Practical Tips / Pitfalls

  • Verify W5500 SPI clock settings before enabling OPC UA services.
  • Monitor FreeRTOS stack usage because OPC UA consumes more memory than MQTT.
  • Consider static IP assignment during initial debugging.
  • Validate socket recovery after Ethernet cable disconnect events.
  • Review heap allocation settings when enabling additional OPC UA features.
  • The current implementation uses demo-level security settings and should not be deployed directly to production systems.
  • Long-term stability testing is recommended before industrial deployment.

FAQ

Why use W5500 for OPC UA?

OPC UA generates significantly more protocol traffic than simple TCP examples. W5500 provides hardware TCP/IP processing, allowing the RP2040 to focus on application-level OPC UA handling.

How does W5500 connect to RP2040?

The W5500 connects through SPI and appears as a socket-based Ethernet interface. The application accesses Ethernet through the WIZnet ioLibrary rather than implementing a full software TCP/IP stack.

What role does W5500 play in this project?

W5500 serves as the Ethernet transport layer for DHCP, MQTT, and OPC UA communications. All network traffic passes through the WIZnet socket API.

Is this project suitable for beginners?

Not really. Developers should already understand Pico SDK, FreeRTOS, networking fundamentals, and embedded C development before attempting to modify the OPC UA implementation.

Why is OPC UA more interesting than MQTT here?

MQTT examples are already common across many embedded platforms. Running an open62541 OPC UA server on RP2040 with a W5500-based transport layer is far less common and provides stronger Industrial IoT reference value.

Source

Original Project: RP2040 + WIZnet W5500 FreeRTOS/MQTT/OPC UA Demo Repository

License: Refer to the original repository and included third-party licenses for open62541, FreeRTOS, and WIZnet ioLibrary components.

Tags

#W5500 #RP2040 #OPCUA #open62541 #FreeRTOS #MQTT #IndustrialIoT #Ethernet #HardwareTCPIP #WIZnet #RaspberryPiPico #EmbeddedNetworking

Documents
Comments Write