---
title: "WIZnet W5300-TOE Loopback server (micropython)"
url: "https://maker.wiznet.io/scarlet/projects/wiznet-w5300-toe-loopback-server-micropython/"
markdown_url: "https://maker.wiznet.io/scarlet/projects/wiznet-w5300-toe-loopback-server-micropython/md"
type: "UCC: User Created Content"
author: "scarlet"
original_author: "scarlet"
original_url: "https://github.com/Wiznet/W5300-TOE-MicroPython/tree/main/example/Loopback/server"
published: "2023-02-14"
language: "en"
tags: ["AIoT", "toe-design-contest-ref"]
hardware: ["WIZnet W5300"]
likes: 6
views: 3712
comments: 1
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# WIZnet W5300-TOE Loopback server (micropython)

> WIZnet W5300-TOE Loopback server with Nucleo-f429zi

Original author: scarlet (source: https://github.com/Wiznet/W5300-TOE-MicroPython/tree/main/example/Loopback/server)

## Components

- **WIZnet W5300** x 1 ([docs](https://docs.wiznet.io/Product/Chip/Ethernet/W5300))
- Software: **MicroPython** ([docs](http://micropython.org/))

## Documents and links

- [WIZNET5K FW for W5300 with STM32F4xx](https://github.com/Wiznet/W5300-TOE-MicroPython/releases/tag/Release_1_0) (code)
- [W5300-TOE Loopback example in offisial site](https://github.com/Wiznet/W5300-TOE-MicroPython/tree/main/example/Loopback/server) (code)

## Article

These sections will guide you through a series of steps from configuring development environment to running ethernet examples using the STM32f429zi (nuleo-f429zi) with W5300-TOE

Please refer to the 'Getting Started' guide for the basic settings

https://github.com/Wiznet/W5300-TOE-MicroPython/blob/main/static/GettingStart.md

### **Hardware requirements**

The ethernet examples use **NUCLEO-F429ZI** build on STM32 MCU with WIZnet's [**W5300**](https://docs.wiznet.io/Product/iEthernet/W5300) ethernet chip. If you use other STM board, supported board of STMicroelectronics micropython in [**LIST**](https://micropython.org/stm32/) and check that the board supports FMC 16bit data pin

### **W5300-TOE**

* W5300-TOE shield's product page is not surported yet, I will add it when it is provided.

W5300 product page is [Here](https://docs.wiznet.io/Product/iEthernet/W5300)

### **NUCLEO-F429ZI**

`**STM32F429ZI**` This document is based on STM32F429ZI. If you use other STM board, Please edit it to your HW configuration.

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

- FMC Data pin (0-8 or 0-16)

- FMC Address pin (0-10)

- FMC Control GPIO pin (NE, NWE, NOE)

- WIZChip Control GPIO pin (INT, RST)

- UART3 pin(connect to ST-LINK) -- Be changed for use the FMC on the Nucleoboard. Pin D8, D9 -> Pin C10, C11

===================================================================

### **Wiznet5K (micropython Library for wiznet product)**

W5300 is not included in the FW provided by microthon. So you have to use the FW provided by WIZnet.

Please refer to the getting start on the official site for downloading and editing of W5300 WIZNET5K FW ([Click Here)](https://github.com/Wiznet/W5300-TOE-MicroPython/blob/main/static/GettingStart.md)

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

**Step 1: Prepare Software**

The following serial terminal program is required for **Loopback** test, download and install from below links.

- [**Thonny**](https://thonny.org/)

- [**Hercules**](https://www.hw-group.com/software/hercules-setup-utility)

### **Step 2: Prepare hardware**

- Combine WIZnet W5300-TOE Ethernet Shield and NUCLEO-F429ZI STM Board

- Connect ethernet cable to W5300-TOE ethernet port.

- Connect NUCLEO-F429ZI to desktop or laptop using 5 pin micro USB cable.

### **Step 3: Setup Loopback Example**

To test the **Loopback example**, minor settings shall be done in code.

- Check COMport in [‘Configure interpreter …] and then open **Thonny** Python IDE.

![](https://hackster.imgix.net/uploads/attachments/1557089/thonny-setup_example.png?auto=compress%2Cformat&w=740&h=555&fit=max)

Initialize ethernet interface and configuration. Open the example code to set **[Network Information]**

> nic.ifconfig(('IP Address', 'Netmask', 'Gateway', 'DNS'))

```plaintext
from wiznet_conf import wiznet5k_w5300
		...

def main():
    w5300=wiznet5k_w5300()
    w5300.w5300_set_ip('192.168.11.104','255.255.255.0','192.168.11.1','8.8.8.8')
    ...
```

- How to operate as a **Loopback Server**.

```plaintext
def server_loop(): 
    s = socket()
    s.bind(('192.168.1.20', 5000)) #Source IP Address
    s.listen(5)
            
    conn, addr = s.accept()
    print("Connect to:", conn, "address:", addr) 
    print("Loopback server Open!")
    while True:
        data = conn.recv(2048)
        print(data.decode('utf-8'))
        if data != 'NULL':
            conn.send(data)
```

### **Step 4: Upload and Run**

### **Loopback Server Mode**

- The Loopback is executed and the server waits in Listen state.

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

Open the Hercules program to set client mode **[IP Address]** and **[PORT number]** and Connect to the Server.

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

If you send the phrase Loopback Test, you can see that you are sending and receiving data.

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

---

Source: https://maker.wiznet.io/scarlet/projects/wiznet-w5300-toe-loopback-server-micropython/
