---
title: "STM32 Ethernet Communication Tutorial using Wiznet W5500 Module"
url: "https://maker.wiznet.io/scott/projects/stm32-ethernet-communication-tutorial-using-wiznet-w5500-module/"
markdown_url: "https://maker.wiznet.io/scott/projects/stm32-ethernet-communication-tutorial-using-wiznet-w5500-module/md"
type: "UCC: User Created Content"
author: "Mainul Islam"
author_url: "https://embeddedthere.com/stm32-ethernet-communication-tutorial-using-w5500-module/"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "Mainul Islam"
original_url: "https://embeddedthere.com/stm32-ethernet-communication-tutorial-using-w5500-module/"
published: "2025-10-29"
language: "en"
hardware: ["WIZnet W5500"]
likes: 0
views: 2125
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# STM32 Ethernet Communication Tutorial using Wiznet W5500 Module

> STM32 Ethernet Communication Tutorial using Wiznet W5500 Module

Original author: Mainul Islam (source: https://embeddedthere.com/stm32-ethernet-communication-tutorial-using-w5500-module/)

## Components

- **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

The article *“Ethernet Communication using STM32 Microcontroller and Wiznet (Interrupt Mode)”* from **EmbeddedThere** demonstrates how to build a TCP-based Ethernet communication system using the **STM32F103C8T6 (Bluepill)** and **WIZnet W5500** Ethernet module.
The project focuses on implementing **interrupt-driven TCP communication**, leveraging the W5500’s hardware TCP/IP stack for **non-blocking, efficient, and reliable** data transfer.

---

## Hardware Setup

- **Microcontroller:** STM32F103C8T6 (Bluepill)

- **Ethernet Controller:** WIZnet W5500

- **Interface:** SPI (PA4–PA7)

- **Interrupt Pin:** PB1 (Falling Edge)

- **Reset Pin:** PB0

- **LED Indicator:** PB9

- **Power Supply:** External 3.3V (recommended for W5500 stability)

This setup provides a simple yet effective hardware base for anyone looking to add wired Ethernet connectivity to embedded systems or IoT devices.

---

## Project Workflow

- Create and configure the project using **STM32CubeIDE**

- Set up **SPI1** and **GPIO interrupt pin (PB1)**

- Add the **WIZnet driver library** to the project

- Initialize and open a **TCP server socket** (default port 8080)

- Communicate with a PC client (e.g., using **Hercules**) over Ethernet

When a message “Hello” is received from the PC, the MCU toggles an LED and replies with a confirmation message — “Received from [socket]”.
This simple interaction effectively demonstrates how STM32 communicates through the W5500 hardware stack.

---

## Software Architecture

- `W5500Init()`
  - Registers SPI and control callbacks
  - Performs hardware reset on the chip
  - Allocates internal buffer memory
  - Configures static network parameters (MAC, IP, gateway, subnet)

- `W5500_Enable_Interrupts()`
  - Enables global and socket-level interrupts
  - Monitors **CON**, **DISCON**, **RECV**, and **TIMEOUT** events for all sockets

- `HAL_GPIO_EXTI_Callback()`
  - Triggered when W5500 pulls the INT pin low
  - Calls `W5500_InterruptHandler()` to read and clear interrupt flags

- `W5500_Handle_Events()`
  - Iterates through sockets and checks event flags
  - Invokes the appropriate handler (`handle_connection`, `handle_received`, etc.)
  - Manages socket state transitions like reconnecting or closing

- `main.c` Loop
  - Periodically calls `W5500_Handle_Events()`
  - Detects “Hello” messages in the receive buffer, toggles the LED, and responds with acknowledgment

---

## Key Features

- **Interrupt-driven communication:**
  Efficient event handling with low CPU usage compared to polling.

- **Hardware TCP/IP processing:**
  W5500 manages the entire network protocol stack internally, freeing MCU resources.

- **STM32CubeIDE-based configuration:**
  Clean setup for SPI, EXTI, and GPIO via CubeMX graphical interface.

---

## Conclusion

This project serves as a **practical introduction to Ethernet communication** using STM32 and WIZnet’s W5500 in interrupt mode.
By offloading TCP/IP tasks to the W5500 chip, developers can achieve **stable and responsive network communication** even on resource-limited microcontrollers.

It’s an excellent starting point for embedded engineers building IoT or industrial Ethernet applications with STM32.

**🔗 **[**EmbeddedThere Homepage**](https://embeddedthere.com/)

**🔗 **[**EmbeddedThere Youtube**](https://www.youtube.com/@embeddedthere6432/featured)

**🔗 **[**EmbeddedThere Linkedin**](https://www.linkedin.com/company/embeddedthere)

---

Source: https://maker.wiznet.io/scott/projects/stm32-ethernet-communication-tutorial-using-wiznet-w5500-module/
