Labs / MicroPython tutorials / 13 ETH Ethernet - Document Tutorial Draft

Wiznet Ethernet Module Enables Online Dynamic Library Installation and Automatic Dependency Setup – Using the uPyPI Package Management Platform

Author: Li Zisheng · Source: FreakStudio open documentation, v1.0 · License: CC BY 4.0

Contents

Introduction

If you're doing MicroPython embedded development, are you tormented by these problems every day? The code you wrote throws an error as soon as you run it, and after searching for ages you find that a dependency file is missing ; what's even more frustrating is that one library comes with several supporting files, and missing any one of them renders everything useless.
Here, we first need to introduce the concept ofdependency library. In MicroPython development, the official definition of a dependency library is very clear:

Your main function code / main library cannot run properly on its own, and must call the. py code files provided by other independent functions, classes, hardware interfaces, and algorithm logic; these external code files being called are the dependency libraries.

Here is a real embedded system case: driving the MAX30102 sensor with a microcontroller to implement heart rate and blood oxygen detection

Heart Rate Main Program → Must call Sensor Driver + Filtering Algorithm to run. Without these two dependency libraries, your heart rate code will throw an error directly and cannot run at all.

Let's extend to a real development scenario: using the Wiznet EVB-PICO development board to implement via the Wiznet network module TCP Client communication (the most commonly used network function, which adapts to the core features of the development board):

\TCP Client main program\ → must call \Wiznet network driver\ + \socket utility library\ to run. Without these two dependency libraries, your network communication code will report errors directly, the Wiznet module cannot be initialized, and it will not run at all.

Let me share another real-world development scenario:

Question

Beginner’s Soul-Searching Question: Why can’t I just copy-paste all the code and cram it into a single. py file?

This is a pitfall that 99% of beginners fall into. Combining with the practical work of embedded development, I will tell you 4 core reasons why you must never do this:

  1. Dependent libraries will undergo version upgrades, and will be completely unable to be updated after merging
  1. A dependency library is a general-purpose tool that can be reused in countless projects.
  1. Nested dependencies can send your code completely spiraling out of control

A heart rate feature may rely on 2 libraries, each of which in turn depends on 2 underlying libraries; the final dependency chain will be: the main code → 4 dependent libraries. If all of them are merged into a single file, the code will reach thousands or even tens of thousands of lines, making it impossible to locate the root cause once an error occurs.

  1. development and maintenance cost explosion

Embedded development mostly involves multi-person collaboration: Engineer A writes the sensor driver, Engineer B develops the algorithm, and Engineer C codes the main function. When the code is separated (in a dependency library mode), everyone works without interfering with each other; if the code is merged into a single file where all developers modify the same file directly, conflicts will arise and the code will end up scrapped.

This is exactly why we have to leverage the Wiznet Ethernet module to implement:
Python pip-like online automatic installation + automatic dependency loading: with a single line of code, it automatically installs the main library + all dependent libraries + nested dependencies, and handles version upgrades automatically!

Core Solution: uPyPi + mip

92

The uPyPi we developed is the **PyPI (official Python package repository)** for the MicroPython ecosystem. Together with the mip (mip installs packages) tool built into official MicroPython, it enables the following:

Hands-on from Scratch: Implement Dynamic Dependency Installation via Wiznet Ethernet in 3 Steps

For instructions on how to download and upload driver packages, please refer to the wiki: https://freakstudio.cn/node/019c992e-2994-7180-b570-12199db1a7cb

Wiznet Ethernet Module Enables Online Dynamic Library Installation and Automatic Dependency Setup – Using the uPyPI Package Management Platform

Step 1: Create the third-party dependency package math_utils

This is a pure software toolkit that contains no hardware code and serves as a dependency of the main package.

The folder structure is as follows:

2026 4 13 31 1KB 2 17 29

code/math_utils.py The code is as follows:

Wiznet Ethernet Module Enables Online Dynamic Library Installation and Automatic Dependency Setup – Using the uPyPI Package Management Platform

The complete configuration of package.json is as follows:

{
  "name": "math_utils",
  "version": "1.0.1",
  "description": "Pure third-party software dependency package (no hardware, for testing)",
  "author": "test",
  "license": "MIT",
  "chips": "all",
  "fw": "all",
  "_comments": {
    "chips": "Chip models supported by this package; all means no chip restriction",
    "fw": "Specific firmware this package depends on, such as ulab, lvgl; all means no firmware dependency"
  },
  "urls": [
    [
      "math_utils.py",
      "code/math_utils.py"
    ]
  ]
}
​

Package the folder, upload it to the uPyPi platform, and obtain the package address:

1.6.1

Step 2: Create the main test suite test_core

The main package depends on the math_utils above; users only need to install the main package, and mip will automatically install the dependencies.
Folder structure:

2026/4/4 13 45 1 2026/4/2 17 41

The code in code/test_core.py is as follows:

Wiznet Ethernet Module Enables Online Dynamic Library Installation and Automatic Dependency Setup – Using the uPyPI Package Management Platform

The complete configuration of package.json is as follows:

"name": "test_core",
  "version": "1.0.4",
  "description": "Pure software test main package (no hardware, depends on third-party packages)",
  "author": "test",
  "license": "MIT",
  "chips": "all",
  "fw": "all",
  "_comments": {
    "chips": "Chip models supported by this package; all means no chip restriction",
    "fw": "Specific firmware this package depends on, such as ulab, lvgl; all means no firmware dependency"
  },
  "urls": [
    [
      "test_core.py",
      "code/test_core.py"
    ]
  ],
  "deps": [
    ["https://upypi.net/pkgs/math_utils/1.0.1", "latest"]
  ]
}
​

Here, we declare in the deps field the uPyPi address of the main package dependency math_utils; when mip installs the main package, it will automatically install dependent packages via recursion, requiring no intervention from the user at all. It supports multiple dependencies and nested dependencies, with mip automatically handling all dependency chains.

Package the folder, upload it to the uPyPi platform, and obtain the address of the main package:

1.0.4

Step 3: One-click Installation and Test of Wiznet EVB-PICO

The complete code is as follows:

# ==================== Wiznet EVB-PICO Ethernet pure software test (no hardware coupling) ====================
# Python env   : MicroPython v1.23.0 on Wiznet W5500
# -*- coding: utf-8 -*-        
# @Time    : 2024/8/7 9:12 PM
# @Author  : Li Qingshui
# @File    : main.py       
# @Description : Wiznet Ethernet + uPyPi automatic dependency installation, pure test code

import time
import network
import mip
from machine import Pin, SPI

# ==================== Configuration ====================
# Ethernet static IP configuration (Wiznet EVB-PICO)
ETH_IP = '192.168.1.20'
ETH_SUBNET = '255.255.255.0'
ETH_GATEWAY = '192.168.1.1'
ETH_DNS = '8.8.8.8'
# uPyPi main test package address (replace with the upypi address)
MAIN_PACKAGE = "https://upypi.net/pkgs/test_core/1.0.4"

# ==================== Ethernet connection (only modify this part!) ====================
def connect():
    try:
        print("Initializing Wiznet Ethernet...")
        # W5500 SPI initialization (EVB-PICO standard pins)
        spi = SPI(0, 2000000, mosi=Pin(19), miso=Pin(16), sck=Pin(18))
        nic = network.WIZNET5K(spi, Pin(17), Pin(20))
        nic.active(True)
        # Configure static IP
        nic.ifconfig((ETH_IP, ETH_SUBNET, ETH_GATEWAY, ETH_DNS))
        
        # Wait for the Ethernet connection
        timeout = 10
        while not nic.isconnected() and timeout > 0:
            timeout -= 1
            time.sleep(1)
        
        if nic.isconnected():
            print("Ethernet connected successfully! IP:", nic.ifconfig()[0])
            return True
        else:
            print("Ethernet connection failed!")
            return False
    except Exception as e:
        print("Ethernet initialization failed:", e)
        return False

# ==================== Remote installation (automatically install third-party software dependencies) [completely unchanged] ====================
def install():
    print("Starting installation: main package + third-party pure-software dependencies...")
    mip.install(MAIN_PACKAGE)
    print("✅ Installation complete! No hardware dependencies")

# ==================== Pure software test (no hardware) [completely unchanged] ====================
def test():
    # Import the installed pure software package
    from test_core import TestCore
    test = TestCore()
    
    # Run the test
    print("\n===== Pure-software test results =====")
    print(test.test_add(10, 20))
    print(test.test_multiply(10, 20))
    print("=========================\n")
    print("🎉 Test passed! Dependencies installed correctly")

# ==================== Main program [completely unchanged] ====================
if __name__ == "__main__":
    if connect():
        install()
        test()

​

The operation results are as follows:

192.168.10.124

We can also use the local installation method:

Wiznet Ethernet Module Enables Online Dynamic Library Installation and Automatic Dependency Setup – Using the uPyPI Package Management Platform

As can be seen: Wiznet has successfully implemented Python-like mip tool to realize the online dynamic installation capability similar to Python pip. After the device connects to WiFi, it automatically pulls and deploys the main test suite test_core.py and its third-party dependency packages math_utils.py to the /lib directory.
Subsequent pure software tests verified that the main package can normally call the dependency libraries, and the results of addition and multiplication operations are completely correct. This solution fully implements online library installation, automatic dependency management and function verification on the embedded device side, thoroughly addresses the development pain points of traditional manual file copying and missing dependency installation, and delivers a standardized package management experience consistent with Python development on the PC side.

tcs34725_color_driver

Version History

Version Number

Revision Date

Modifier

Modified Content

v1.0

2026-04-04

Lee Eoryong

Initialization version.