---
title: "W5500 Ethernet module on Raspberry Pi Zero"
url: "https://maker.wiznet.io/matthew/projects/w5500-ethernet-module-on-raspberry-pi-zero/"
markdown_url: "https://maker.wiznet.io/matthew/projects/w5500-ethernet-module-on-raspberry-pi-zero/md"
type: "UCC: User Created Content"
author: "Petr Klosko"
author_url: "https://www.klosko.net/blog/=clanek=ethernet-modul-w5500-na-raspberry-pi-zero"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "Petr Klosko"
original_url: "https://www.klosko.net/blog/=clanek=ethernet-modul-w5500-na-raspberry-pi-zero"
published: "2024-01-03"
language: "en"
hardware: ["WIZnet W5500"]
likes: 0
views: 4064
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# W5500 Ethernet module on Raspberry Pi Zero

> For the base station (gateway) for LoRa thermometers,

Original author: Petr Klosko (source: https://www.klosko.net/blog/=clanek=ethernet-modul-w5500-na-raspberry-pi-zero)

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

Raspberry Pi Zero

For the base station (gateway) for LoRa thermometers, I decided to use a Raspberry Pi Zero.
Due to unstable WiFi in one of the installation locations, the Raspberry Pi Zero W cannot be used, but a connection via LAN is required.

The Raspberry Pi can use some "USB LAN" or "HAT" (which still wants the USB). But this solution breaks the aesthetic appearance of the box – it blocks one USB connector.

Therefore, I decided to use an ethernet module that connects via SPI directly to the GPIO header of the raspberry. The choice fell on the "Mini Ethernet module W5500" - because it is in stock and at a good price on the [Czech DIY Aliexpress](https://www.laskakit.cz/mini-ethernet-modul-w5500/). In addition, there is already a tutorial for Instructables - [How to Use Ethernet on Raspberry Pi Zero W](https://www.instructables.com/How-to-Use-Ethernet-on-Raspberry-Pi-Zero-W/)

, so this article is basically just a quick summary so I don't have to look for it next time. In addition, I have added a [fixed HW MAC address](https://www.klosko.net/blog/=clanek=ethernet-modul-w5500-na-raspberry-pi-zero#MAC)

setting, connection The connection

of the W5500 to the Raspberry Pi is according to the diagram below. Realization of a "cut brace", er, IDE connecting flat cable. GND and 3.3V can be used with any of the pins from the GPIO header.

[![Connecting RPi and W5500](https://www.klosko.net/img/blog/RPiZeroW5500/W5500-RPi_wiring.png)](https://www.klosko.net/img/blog/imgdetail.php?src=RPiZeroW5500/detail_W5500-RPi_wiring.png&title=Propojen%ED+RPi+a+W5500) [![W5500 pinout](https://www.klosko.net/img/blog/RPiZeroW5500/W5500-RPi_conn.png)](https://www.klosko.net/img/blog/imgdetail.php?src=RPiZeroW5500/detail_W5500-RPi_conn.png&title=W5500+pinout)

Raspberry Pi
configuration
It can be clicked in raspi-config, but by editing /boot/config.txt it's faster. Just add two options – enable SPI and load the appropriate module at boot

For
other parameters (int_pin, speed, Chip Select) see [README](https://raw.githubusercontent.com/raspberrypi/firmware/master/boot/overlays/README)
Reboot and check if there is another network adapter present – ifconfig ...

```plaintext
sudo nano /boot/config.txt

dtparam=spi=on
dtoverlay=w5500
```

Fixed MAC address The MAC address

of the module is generated on every reboot, which makes a mess in DHCP, DNS and so on - because raspberry has a different IP every time.
This can be worked around by adding rules/service for systemd and a script that hard-codes the interface with a MAC.

The script itself generates a MAC address from the serial number of the Raspberry Pi. Alternatively, you can hack it hard.

Do not forget about rights and automatic start/enable of the service

A similar procedure can be applied to modules with LAN8720, just load another module. (I haven't tried)

```plaintext
sudo nano /lib/systemd/system/setmac.service

[Unit]
Description=DSet the MAC address for the W5500 net adapter at eth0
Wants=network-pre.target
Before=network-pre.target
BindsTo=sys-subsystem-net-devices-eth0.device
After=sys-subsystem-net-devices-eth0.device

[Service]
Type=oneshot
ExecStart=/path/to/setmac.sh

[Install]
WantedBy=multi-user.target
```

```plaintext
sudo nano /path/to/setmac.sh

sudo /sbin/ip link set dev eth0 address `/bin/sed -n "s/Serial.*: 00000000..(..)(..)(..)/b8:27:eb:1:2:3/p" /proc/cpuinfo`
```

```plaintext
sudo systemctl enable setmac.service

sudo chmod +x /path/to/setmac.sh
```

---

Source: https://maker.wiznet.io/matthew/projects/w5500-ethernet-module-on-raspberry-pi-zero/
