Wiznet makers

Aimee0

Published January 30, 2026 ©

54 UCC

18 WCC

13 VAR

0 Contests

0 Followers

0 Following

ioNIC Loopback C Example

Configures the W55RP20-S2E as a TCP server/TCP client/UDP via UART/SP and relays UART/SPI data from the module back to it transparently

COMPONENTS Hardware components

WIZnet - W55RP20-EVB-Pico

x 1


PROJECT DESCRIPTION

How to Loopback Example

This example demonstrates how the Raspberry Pi Pico transmits AT commands to the W55RP20 S2E board via UART or SPI to configure it as a TCP Server, TCP Client, or UDP device.

Furthermore, when the W55RP20 S2E board receives Ethernet data from a PC and passes it to the Raspberry Pi Pico over UART or SPI, the Raspberry Pi Pico simply relays the data by retransmitting it without modification.

Step 1: Prepare software

The following serial terminal programs are required for AT command example test, download and install from below links.

Step 2: Prepare hardware

1. Connect GPIO13 according to the selected UART/SPI mode of the W55RP20 EVB Pico, as illustrated below.

GPIO13 Pin Desc
LOW(GND)UART mode (default)
HIGH(3.3V)SPI mode

2. Connect the Raspberry Pi Pico and the W55RP20 EVB Pico using jumper wires as shown below, depending on the selected UART/SPI mode.

If UART mode :

Raspberry Pi PicoW55RP20 EVB Pico
GPIO4 (UART_TX)GPIO5 (UART_RX)
GPIO5 (UART_RX)GPIO4 (UART_TX)
GNDGND

If SPI mode :

Raspberry Pi PicoW55RP20 EVB Pico
GPIO2 (SPI_CLK)GPIO2 (SPI_CLK)
GPIO3 (SPI_TX)GPIO4 (SPI_RX)
GPIO4 (SPI_RX)GPIO3 (SPI_TX)
GPIO5 (SPI_CS)GPIO5 (SPI_CS)
GPIO26 (SPI_INT)GPIO26 (SPI_INT)
GNDGND

 

3. Connect the Raspberry Pi Pico to your PC (desktop or laptop) using a 5-pin Micro USB cable.

4. Connect the W55RP20 EVB Pico to your PC (desktop or laptop) using a USB Type-C cable.

Step 3: Setup Loopback Example

Raspberry Pi Pico

Please refer to the link below for setting up the Raspberry Pi Pico development environment.

Getting started with Raspberry Pi Pico

We recommend the following versions for successful build and development:

  • pico-sdk: 2.2.0
  • ARM GCC Toolchain: 14.2.Rel1

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

  • Loopback TCP server

Setup network configuration such as IP and Port etc... in 'loopback_server_uart/spi.c' in 'loopback/server/' directory.

// loopback_server_uart.c

    printf("\n--- Config W55RP20 with AT command(UART) ---\n");
    {
        enter_command_mode();                   // Send +++ command
        factory_reset();                        // Send Factory Reset command
        // If you send Reset or Factory Reset command, W55RP20 will reboot and enter to default gateway mode
        enter_command_mode();                   // Send +++ command 
        at_set("OP", "1");                      // Set W55RP20 TCP server mode
        at_set("LI", "192.168.11.2");           // Set W55RP20's Local IP : 192.168.11.2
        at_set("SM", "255.255.255.0");          // Set W55RP20's Subnet mask : 255.255.255.0
        at_set("GW", "192.168.11.1");           // Set W55RP20's Gateway : 192.168.11.1
        at_set("DS", "8.8.8.8");                // Set W55RP20's DNS Address : 8.8.8.8
        at_set("LP", "5000");                   // Set W55RP20's Local Port : 5000
        at_set("SV", NULL);                     // Send Save command
        sleep_ms(100);
        device_reset();                         // Send Reset command
    }
// loopback_server_spi.c

    printf("\n--- Config W55RP20 with AT command(SPI) ---\n");
    {
        at_set("FR", NULL);                             // Send Factory Reset command
        printf("W55RP20 is Rebooting...\n"); 
        sleep_ms(3000); 
        at_set("OP", "1");                              // Set W55RP20 TCP server mode
        at_set("LI", "192.168.11.2");                   // Set W55RP20's Local IP : 192.168.11.2
        at_set("SM", "255.255.255.0");                  // Set W55RP20's Subnet mask : 255.255.255.0
        at_set("GW", "192.168.11.1");                   // Set W55RP20's Gateway : 192.168.11.1
        at_set("DS", "8.8.8.8");                        // Set W55RP20's DNS Address : 8.8.8.8
        at_set("LP", "5000");                           // Set W55RP20's Local Port : 5000
        at_set("SV", NULL);                             // Send Save command
        at_set("RT", NULL);                             // Send Reset command
        printf("W55RP20 is Rebooting...\n"); 
        sleep_ms(3000); 
    }
  • Loopback TCP client

Setup network configuration such as IP and Port etc... in 'loopback_client_uart/spi.c' in 'loopback/client/' directory.

// loopback_client_uart.c

    printf("\n--- Config W55RP20 with AT command(UART) ---\n");
    {
        enter_command_mode();                   // Send +++ command
        factory_reset();                        // Send Factory Reset command
        // If you send Reset or Factory Reset command, W55RP20 will reboot and enter to default gateway mode
        enter_command_mode();                   // Send +++ command 
        at_set("OP", "0");                      // Set W55RP20 TCP client mode
        at_set("LI", "192.168.11.2");           // Set W55RP20's Local IP : 192.168.11.2
        at_set("SM", "255.255.255.0");          // Set W55RP20's Subnet mask : 255.255.255.0
        at_set("GW", "192.168.11.1");           // Set W55RP20's Gateway : 192.168.11.1
        at_set("DS", "8.8.8.8");                // Set W55RP20's DNS Address : 8.8.8.8
        at_set("LP", "5000");                   // Set W55RP20's Local Port : 5000
        at_set("RH", "192.168.11.100");         // Set Remote IP(ex. PC) : 192.168.11.100
        at_set("RP", "5000");                   // Set Remote Port(ex. PC) : 5000
        at_set("SV", NULL);                     // Send Save command
        sleep_ms(100);
        device_reset();                         // Send Reset command
    }
// loopback_client_spi.c

    printf("\n--- Config W55RP20 with AT command(SPI) ---\n");
    {
        at_set("FR", NULL);                     // Send Factory Reset command
        printf("W55RP20 is Rebooting...\n"); 
        sleep_ms(3000); 
        at_set("OP", "0");                      // Set W55RP20 TCP client mode
        at_set("LI", "192.168.11.2");           // Set W55RP20's Local IP : 192.168.11.2
        at_set("SM", "255.255.255.0");          // Set W55RP20's Subnet mask : 255.255.255.0
        at_set("GW", "192.168.11.1");           // Set W55RP20's Gateway : 192.168.11.1
        at_set("DS", "8.8.8.8");                // Set W55RP20's DNS Address : 8.8.8.8
        at_set("LP", "5000");                   // Set W55RP20's Local Port : 5000
        at_set("RH", "192.168.11.100");         // Set Remote IP(ex. PC) : 192.168.11.100
        at_set("RP", "5000");                   // Set Remote Port(ex. PC) : 5000
        at_set("SV", NULL);                     // Send Save command
        at_set("RT", NULL);                     // Send Reset command
        printf("W55RP20 is Rebooting...\n"); 
        sleep_ms(3000); 
    }
  • Loopback UDP

Setup network configuration such as IP and Port etc... in 'loopback_udp_uart/spi.c' in 'loopback/udp/' directory.

// loopback_udp_uart.c

    printf("\n--- Config W55RP20 with AT command(UART) ---\n");
    {
        enter_command_mode();                   // Send +++ command
        factory_reset();                        // Send Factory Reset command
        // If you send Reset or Factory Reset command, W55RP20 will reboot and enter to default gateway mode
        enter_command_mode();                   // Send +++ command 
        at_set("OP", "3");                      // Set W55RP20 UDP mode
        at_set("LI", "192.168.11.2");           // Set W55RP20's Local IP : 192.168.11.2
        at_set("SM", "255.255.255.0");          // Set W55RP20's Subnet mask : 255.255.255.0
        at_set("GW", "192.168.11.1");           // Set W55RP20's Gateway : 192.168.11.1
        at_set("DS", "8.8.8.8");                // Set W55RP20's DNS Address : 8.8.8.8
        at_set("LP", "4002");                   // Set W55RP20's Local Port : 4002
        at_set("RH", "192.168.11.100");         // Set Remote IP(ex. PC) : 192.168.11.100
        at_set("RP", "4001");                   // Set Remote Port(ex. PC) : 4001
        at_set("SV", NULL);                     // Send Save command
        sleep_ms(100);
        device_reset();                         // Send Reset command
    }
// loopback_udp_spi.c

    printf("\n--- Config W55RP20 with AT command(SPI) ---\n");
    {
        at_set("FR", NULL);                     // Send Factory Reset command
        printf("W55RP20 is Rebooting...\n"); 
        sleep_ms(3000); 
        at_set("OP", "3");                      // Set W55RP20 UDP mode
        at_set("LI", "192.168.11.2");           // Set W55RP20's Local IP : 192.168.11.2
        at_set("SM", "255.255.255.0");          // Set W55RP20's Subnet mask : 255.255.255.0
        at_set("GW", "192.168.11.1");           // Set W55RP20's Gateway : 192.168.11.1
        at_set("DS", "8.8.8.8");                // Set W55RP20's DNS Address : 8.8.8.8
        at_set("LP", "4002");                   // Set W55RP20's Local Port : 4002
        at_set("RH", "192.168.11.100");         // Set Remote IP(ex. PC) : 192.168.11.100
        at_set("RP", "4001");                   // Set Remote Port(ex. PC) : 4001
        at_set("SV", NULL);                     // Send Save command
        at_set("RT", NULL);                     // Send Reset command
        printf("W55RP20 is Rebooting...\n"); 
        sleep_ms(3000); 
    }

W55RP20 EVB Pico

Please refer to the link below for instructions on how to use the W55RP20 S2E.

Getting started with W55RP20 EVB Pico

Step 4: Build and Download

Raspberry Pi Pico

To build the project in Visual Studio Code, select one of the three methods below:

1. Click Build in the bottom status bar

2. Press F7 on your keyboard

3. Run the following command in the Visual Studio Code terminal

$ mkdir build
$ cd ./build
$ cmake -G "NMake Makefiles" ..
$ nmake

When the build is completed, the '{example_name}_uart.uf2' file is generated for UART mode, and the '{example_name}_spi.uf2' file is generated for SPI mode in the {Repository}/build/loopback/ directory. Download the UF2 file to the Raspberry Pi Pico.

W55RP20 EVB Pico

Following Step 3 in the Getting Started Guide, program the W55RP20 EVB Pico with the UF2 file and write the MAC address to complete the setup.

Step 5: Run

Connect to the serial COM port of the Raspberry Pi Pico using Tera Term.

Step 5.1: UART mode

TCP Server

1. Configuring the W55RP20 S2E as a TCP Server and Setting Up the Network with AT command.

2. Open a TCP client using the Hercules program on the PC and connect to the W55RP20 S2E.

3. When the PC (TCP Client) sends Ethernet data to the W55RP20 S2E (TCP Server), the W55RP20 S2E transmits the received data to the Raspberry Pi Pico through the UART interface.

The Raspberry Pi Pico loops back the UART data exactly as received, without any modification, and sends it back to the W55RP20 S2E.

After that, the W55RP20 S2E (TCP Server) converts the UART data received from the Pico into Ethernet data and retransmits it to the PC (TCP Client).

TCP Client

1. Configuring the W55RP20 S2E as a TCP Client and Setting Up the Network with AT command.

2. Open a TCP server using the Hercules program on the PC and connect to the W55RP20 S2E.

3. When the PC (TCP Server) sends Ethernet data to the W55RP20 S2E (TCP Client), the W55RP20 S2E transmits the received data to the Raspberry Pi Pico through the UART interface.

The Raspberry Pi Pico loops back the UART data exactly as received, without any modification, and sends it back to the W55RP20 S2E.

After that, the W55RP20 S2E (TCP Client) converts the UART data received from the Pico into Ethernet data and retransmits it to the PC (TCP Server).

 

UDP

1. Configuring the W55RP20 S2E as a UDP and Setting Up the Network with AT command.

2. Open a UDP using the Hercules program on the PC and connect to the W55RP20 S2E.

3. When the PC sends Ethernet data to the W55RP20 S2E, the W55RP20 S2E transmits the received data to the Raspberry Pi Pico through the UART interface.

The Raspberry Pi Pico loops back the UART data exactly as received, without any modification, and sends it back to the W55RP20 S2E.

After that, the W55RP20 S2E converts the UART data received from the Pico into Ethernet data and retransmits it to the PC.

 

Step 5.2: SPI mode

TCP Server

 

 

TCP Client

 

 

UDP

 

 

 

 

 

 

Documents
  • ioNIC Loopback C example

Comments Write