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 [MicroPython]
- 🔨Hardware requirements
- 💡Development environment configuration
- 📂Ethernet example structure
- 📌Ethernet example testing
- 📚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.
Image | Name | Etc |
---|---|---|
Raspberry Pi Pico | Pico Document | |
![]() |
WIZnet Ethernet HAT | Ethernet HAT Datasheet |
![]() |
WIZnet W5100S-EVB-Pico | W5100S-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.
If you want to use the firmware without compile, you can use the below firmware.
Latest Releases : https://github.com/Wiznet/RP2040-HAT-MicroPython/releases
V1.0.4 : ▲ W5100s_v1.0.4.uf2 ▲ W5500_v1.0.4.uf2
- 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:
-
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:
First, import the library of the function you want to use from the library to your PC. To uploading a file to using Thonny IDE, follow these next steps.
You can access the umqttsimple library code in 👇
https://github.com/micropython/micropython-lib/blob/master/micropython/umqtt.simple/umqtt/simple.py
You can access the urequest library code in 👇
https://github.com/micropython/micropython-lib/blob/master/python-ecosys/urequests/urequests.py
- Create a new file, Save it in your computer with the exact name that you want, for example “(your library name).py”
- Go to Open > This computer
- The file should be saved on RPi Pico with the name “(your library name).py”
- Go to File > Save as > Raspberry Pi Pico
Ethernet examples are available at 'RP2040-HAT-MicroPython/examples/' directory. As of now, following examples are provided.
Check if the network is connected normally and if the data is sent to each other.
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.
- Copy the content to code.py on your RPi Pico and run.
- 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.
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
Please refer to 'README.md' in each examples directory to find detail guide for testing ethernet examples.