---
title: "How to add W5500 Ethernet to Raspberry Pi Pico (Python) - 2"
url: "https://maker.wiznet.io/WIZnet/projects/how-to-add-w5500-ethernet-to-raspberry-pi-pico-python-2/"
markdown_url: "https://maker.wiznet.io/WIZnet/projects/how-to-add-w5500-ethernet-to-raspberry-pi-pico-python-2/md"
type: "UCC: User Created Content"
author: "Bongjun Hur"
author_url: "https://www.hackster.io/bjnhur/how-to-add-w5500-ethernet-to-raspberry-pi-pico-python-2-77c78c"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "Bongjun Hur"
original_url: "https://www.hackster.io/bjnhur/how-to-add-w5500-ethernet-to-raspberry-pi-pico-python-2-77c78c"
published: "2023-02-09"
language: "en"
hardware: ["WIZnet WIZ850io", "WIZnet W5500"]
likes: 2
views: 369
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# How to add W5500 Ethernet to Raspberry Pi Pico (Python) - 2

> Raspberry Pi Pico + WIZnet W5500 Ethernet + CircuitPython - DHCP + Echo + WebClient (html, JSON) Demo

Original author: Bongjun Hur (source: https://www.hackster.io/bjnhur/how-to-add-w5500-ethernet-to-raspberry-pi-pico-python-2-77c78c)

## Components

- **WIZnet WIZ850io** x 1 ([docs](https://docs.wiznet.io/Product/ioModule/WIZ850io))
- **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/))

## Documents and links

- [Code](https://maker.wiznet.io/_lib/download.asp?path=project/8592&downfile=pico%5Fw5500%5Fdhcp%5Fecho%2Epy) (code)

## Article

## **Story**

### **1. Preview**

Need to install CircuitPython on Raspberry Pi Pico board. because we can use WIZNET5K library for W5500 Ethernet function. For more detail, I already upload 1st project with Raspberry Pi Pico, WIZ850io (W5500), Circuit Python env., Hardware connection, Ping demo example. Please visit the below project first.

- <https://www.hackster.io/bjnhur/how-to-add-w5500-ethernet-to-raspberry-pi-pico-python-1-c7340c>

### **2. DHCP Example**

visit my source repo.

- <https://github.com/bjnhur/pico-W5500>

Download (or fork, copy,…) samples and copy them into your Raspberry Pi Pico board.

**1. copy “lib” folder into your Raspberry Pi Pico board.**

2. **open “Pico_W5500_Echo_Demo.py”** OR get the code **“Pico_W5500_DHCP_Echo”** from below code section in this project.

![Pico W5500 DHCP Demo github repo](https://hackster.imgix.net/uploads/attachments/1284474/pic114_XardEvdJVj.png?auto=compress%2Cformat&w=740&h=555&fit=max)

Pico W5500 DHCP Demo github repo

in the lib, I modified some codes in WIZNET5K library from Adafruit.

- In adafruit_wiznet5k.py – before DHCP, check link status first.

```plaintext
# in the def __init__ function

start_time = time.monotonic()
while True:
    if self.link_status or ((time.monotonic() - start_time) > 5) :
        break
    time.sleep(1)
    if self._debug:
        print("My Link is:", self.link_status)
```

- In adafruit_wiznet5k_dhcp.py – before DHCP message sending, init _BUFF byte array.

```plaintext
def send_dhcp_message(self, state, time_elapsed):
    # before making send packet, should init _BUFF. if not, DHCP sometimes fails, wrong padding, garbage bytes, ...
    for i in range(len(_BUFF)):
        _BUFF[i] = 0
```

Latest code, you can download from

- <https://github.com/bjnhur/pico-W5500/tree/main/lib/adafruit_wiznet5k>

or

- <https://github.com/bjnhur/Adafruit_CircuitPython_Wiznet5k>(fork version)

3. copy all contents into “code.py” on your Pico board.

![copy lib and edit code.py from Pico_W5500_DHCP_Echo demo code](https://hackster.imgix.net/uploads/attachments/1284496/pic115_Qz9w7lFidY.png?auto=compress%2Cformat&w=740&h=555&fit=max)

copy lib and edit code.py from Pico_W5500_DHCP_Echo demo code

4. save “code.py” and open REPL.

### **3. DHCP processing**

my REPL console window log:

![DHCP start](https://hackster.imgix.net/uploads/attachments/1284501/pic116_SRCIiCn3Nc.png?auto=compress%2Cformat&w=740&h=555&fit=max)

DHCP start

DHCP process is ok.

![DHCP Done and listen socket](https://hackster.imgix.net/uploads/attachments/1284503/pic117_Aa7Tx1RmwW.png?auto=compress%2Cformat&w=740&h=555&fit=max)

DHCP Done and listen socket

```plaintext

```

tcp server socket is also opened.

### **4. ECHO Demo**

First I try to ping to the board. no problem.

![ping command](https://hackster.imgix.net/uploads/attachments/1284507/pic118_lBVjKZH4Vb.png?auto=compress%2Cformat&w=740&h=555&fit=max)

ping command

Second, I tried to TCP connect to (as described on our python code) – I used “Hercules” freeware tool for socket test.

- Destination IP – [192.168.0.20](http://192.168.0.20/)

- Port – 50007

- Send data – “12345”

![TCP Echo Demo result](https://hackster.imgix.net/uploads/attachments/1284509/pic119_0q4jDXqHXH.png?auto=compress%2Cformat&w=740&h=555&fit=max)

1 / 2 • TCP Echo Demo result

### **5. WebClient Demo**

You can find WebClient Demo easily from Adafruit WIZNET5K Ethernet library. Let’s try this sample code as well. It’s easy. **Powerful CircuitPython!!**

original example, visit <https://github.com/adafruit/Adafruit_CircuitPython_Wiznet5k/blob/master/examples/wiznet5k_simpletest.py>

I also prepared “Pico_W5500_WebClient_Demo.py” on my repo.

- <https://github.com/bjnhur/pico-W5500/blob/main/Pico_W5500_WebClient_Demo.py>

- or can copy code from “Pico_W5500_WebClient_Demo” in below code section

**Just copy this code (or download, rename, copy) into “code.py” on your Raspberry Pi Pico board,** then save. Done!

you can see the result log in your REPL console window as below.

![Raspberry Pi Pico W5500 Ethernet WebClient Demo result](https://hackster.imgix.net/uploads/attachments/1284523/pic122_RdEWcXxMBB.png?auto=compress%2Cformat&w=740&h=555&fit=max)

Raspberry Pi Pico W5500 Ethernet WebClient Demo result

1. IP lookup [adafruit.com](http://adafruit.com/) result

2. Getting page from “http://wifitest.adafruit.com/testwifi/index.html”

3. Getting JSON data from “http://api.coindesk.com/v1/bpi/currentprice/USD.json”

*) Check again! This example, you need **“adafruit_requests.mpy”** file in lib folder.

![adafruit_requests.mpy location](https://hackster.imgix.net/uploads/attachments/1284524/pic104_l5PtddwJ65.png?auto=compress%2Cformat&w=740&h=555&fit=max)

adafruit_requests.mpy location

### **Resource**

All code, you can find the below repo.

- <https://github.com/bjnhur/pico-W5500>

Happy coding!

![Good V!](https://hackster.imgix.net/uploads/attachments/1284529/20210412_213416_wfAu8MDTpY.jpg?auto=compress%2Cformat&w=740&h=555&fit=max)

Good V!

## **Schematics**

### **Pico_WIZ850io**

![](https://hackster.imgix.net/uploads/attachments/1284476/pic110_i0vOja2PT2.png)

---

Source: https://maker.wiznet.io/WIZnet/projects/how-to-add-w5500-ethernet-to-raspberry-pi-pico-python-2/
