These sections will guide you through a series of steps from configuring development environment to running ethernet examples using the WIZnet's ethernet products.
- Ethernet Example Getting Started
- Hardware requirements
- Development environment configuration
- Wiznet5K Library
- Ethernet example structure
- Documentation
The ethernet examples use Raspberry Pi Pico and WIZnet Ethernet HAT ethernet I/O module built on WIZnet's W5100S ethernet chip or W5100S-EVB-Pico ethernet I/O module built on RP2040 and WIZnet's W5100S ethernet chip or W5500-EVB-Pico ethernet I/O module built on RP2040 and WIZnet's W5500 ethernet chip.
Image | Name | Etc |
---|---|---|
Raspberry Pi Pico | Pico Document | |
![]() |
WIZnet Ethernet HAT | Ethernet HAT Datasheet |
![]() |
WIZnet W5100S-EVB-Pico | W5100S-EVB-Pico Datasheet |
![]() |
WIZnet W5500-EVB-Pico | W5500-EVB-Pico Datasheet |
WIZnet Ethernet HAT
Ethernet-HAT has the same pin arrangement and pin spacing as Raspberry Pi Pico. The W5100S and RJ45 are built-in, Ethernet can be used by plugging into the Raspberry pi pico. One thing to note when using HAT is to look carefully at the direction and plug it in. There is a USB shape marked, and this direction and the USB direction of Pico must be the same.
WIZnet W5100S-EVB-Pico
In the W5100S-EVB-Pico board, GPIO pins are connected the same as the Raspberry Pi Pico board. If Pico uses Ethernet, PIO16, GPIO17, GPIO18, GPIO19, GPIO20, and GPIO21 pins cannot be used. It is a pin used inside the RP2040 board.
I/O | Pin Name | Description |
---|---|---|
I | GPIO16 | Connected to MISO on W5100S |
O | GPIO17 | Connected to CSn on W5100S |
O | GPIO18 | Connected to SCLK on W5100S |
O | GPIO19 | Connected to MOSI on W5100S |
O | GPIO20 | Connected to RSTn on W5100S |
I | GPIO21 | Connected to INTn on W5100S |
I | GPIO24 | VBUS sense - high if VBUS is present, else low |
O | GPIO25 | Connected to user LED |
I | GPIO29 | Used in ADC mode (ADC3) to measure VSYS/3 |
To test the ethernet examples, the development environment must be configured to use Raspberry Pi Pico.
- Required development environment
- CMake (more then ver 3.12 )
- Thonny (that makes it easier to use micropython)
- If you must be need to compile the micropython ,your pc should be use Linux or Unix environment.
- Download If the ethernet examples are cloned, the library set as a submodule is an empty directory. Therefore, if you want to download the library set as a submodule together, clone the ethernet examples with the following Git command.
/* Change directory */
// change to the directory to clone
cd [user path]
// e.g.
cd D:/RP2040
/* Clone */
git clone https://github.com/Wiznet/RP2040-HAT-MicroPython.git
With Visual Studio Code, the library set as a submodule is automatically downloaded, so it doesn't matter whether the library set as a submodule is an empty directory or not, so refer to it.
- Patch
With Visual Studio Code, each library set as a submodule is automatically patched, but if you do not use Visual Studio Code, each library set as a submodule must be manually patched with the Git commands below in each library directory.
Below is a brief description of the patch file
0001-Added-WIZnet-Chip-library.patch : about Ethernet(WIZnet Chip)
0002-Added-AXTLSlibrary.patch : about SSL/TLS(AXTLS)
- Micropython
// e.g. cd D:/RP2040/RP2040-HAT-MicroPython
cd [user path(=github source code setup path)]
/* Patch and submodule */
cmake CMakeLists.txt
- compile
cd libraries/ports/rp2
vi Makefile
If you enter this path, you can see the below code.
durning patch , if occur the fail, you can't see the below code in the Makefile.
MICROPY_PY_WIZNET5K ?= 5105
//and
CMAKE_ARGS += -DMICROPY_PY_WIZNET5K=$(MICROPY_PY_WIZNET5K)
If you want to use the w5100s and rp2040, you can just use like below code.
make
If you want to use the w5500 and rp2040, you can just use like below code.
make MICROPY_PY_WIZNET5K=5500
After that, you can visit the micropython link below and check it
https://docs.micropython.org/en/latest/develop/gettingstarted.html#compile-and-build-the-code
Install Thonny IDE
on Raspberry Pi Pico by referring to the link above.:point_down:
If MicroPython is already installed then the bootloader can be entered by executing import machine; machine.bootloader()
at the REPL
.
If you want to use the firmware without build, you can use the below firmware.
- Latest Releases : https://github.com/Wiznet/RP2040-HAT-MicroPython/releases
Firmware can be deployed to the device by putting it into bootloader mode (hold down BOOTSEL
while powering on or resetting) and then copying rp2_xxxx_date_ver.uf2
to the USB mass storage device that appears.
How To Use Thonny
-
The drive will be called RPI-RP2 on all RP2040 boards. Download the UF2(firmware.uf2) file from the link below and put the file in Pico.
-
You can also access the firmware installation menu if you click on MicroPython (Raspberry Pi Pico) in the status bar and choose ‘Configure interpreter …’.
- The interpreter settings will open. Click on Install or update firmware.
- You will be prompted to plug in your Raspberry Pi Pico while you hold the BOOTSEL button.
- Then you can click Install. Wait for the installation to complete and click Close.
- Look at the Shell panel at the bottom of the Thonny editor. You should see something like this:
The following samples can be easily run on the board, then cut-and-pasting the sample code into the Thonny Tool, then executing the code with Ctrl-D and F5.
This ping test is to check the network environment using static ip and wiznet chip.
This is the code to set the IP of 192.168.1.20
I hope that the PC also has an environment that communicates with 192.168.1.xxx.
from machine import Pin,SPI
import network
import time
led = Pin(25, Pin.OUT)
#W5x00 chip init
def w5x00_init():
spi=SPI(0,2_000_000, mosi=Pin(19),miso=Pin(16),sck=Pin(18))
nic = network.WIZNET5K(spi,Pin(17),Pin(20)) #spi,cs,reset pin
nic.active(True)
nic.ifconfig(('192.168.1.20','255.255.255.0','192.168.1.1','8.8.8.8'))
while not nic.isconnected():
time.sleep(1)
print(nic.regs())
print(nic.ifconfig())
def main():
w5x00_init()
while True:
led.value(1)
time.sleep(1)
led.value(0)
time.sleep(1)
if __name__ == "__main__":
main()
- Press the
Win+R
key to enter cmd and press Enter or OK to execute the command prompt.
- When the command prompt window appears, type the ping command and press Enter.
ping 192.168.1.20 (-option)
- Ping tests begin as packets are exchanged between hosts. If you look at the time and loss rate among the statistical results, you can find out the status of the Internet network.
Ethernet examples are available at RP2040-HAT-MicroPython/examples directory. As of now, following examples are provided.
Documentation for WIZnet Ethernet HAT and Raspberry pi pico board
Raspberry Pi Pico Datasheet : An RP2040-based microcontroller board
Getting started with Raspberry Pi Pico : C/C++ development with Raspberry Pi Pico and other RP2040-based microcontroller boards
WIZnet Ethernet HAT W5100S-EVB-Pico W5500-EVB-Pico
Please refer to 'README.md' in each examples directory to find detail guide for testing ethernet examples.