---
title: "MicroNet"
url: "https://maker.wiznet.io/lawrence/projects/micronet/"
markdown_url: "https://maker.wiznet.io/lawrence/projects/micronet/md"
type: "UCC: User Created Content"
author: "Thomas O Fredericks"
author_url: "https://github.com/thomasfredericks/MicroNet"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "Thomas O Fredericks"
original_url: "https://github.com/thomasfredericks/MicroNet"
published: "2026-05-10"
language: "en"
tags: ["M5Stack", "ESP32", "Arduino"]
hardware: ["M5Stack Development Board Watch Kit (Not Including Core)", "M5Stack LAN Module with W5500"]
likes: 0
views: 292
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# MicroNet

> MicroNet is a lightweight network connection manager library for Arduino and PlatformIO

Original author: Thomas O Fredericks (source: https://github.com/thomasfredericks/MicroNet)

## Components

- **M5Stack Development Board Watch Kit (Not Including Core)** x 1 ([docs](https://shop.m5stack.com/products/development-board-watch-kit?variant=16804808589402))
- **M5Stack LAN Module with W5500** x 1 ([docs](https://docs.m5stack.com/en/base/lan_base))
- Software: **Arduino IDE** ([docs](https://www.arduino.cc/en/software))
- Software: **PlatformIO Core** ([docs](https://docs.platformio.org/en/latest/core/index.html))

## Article

## MicroNet: Managing Wi-Fi and WIZnet Ethernet with a Single Library on ESP32

---

### Why This Library Exists

Most Ethernet implementations on microcontrollers rely on **lwIP** — a software TCP/IP stack that runs on the MCU itself, consuming CPU cycles for every network operation. WIZnet W5x00-series chips take a fundamentally different approach: a **hardware TCP/IP Offload Engine (TOE)** that processes the entire network stack on-chip, freeing the MCU for application logic.

The challenge has been that Wi-Fi and WIZnet Ethernet have required separate initialization and management code — making it difficult to share a codebase across both transport types, or to migrate from one to the other without significant rewrites.

**MicroNet solves this by providing a unified API layer for both interfaces.** A project that starts as a Wi-Fi prototype can be deployed with WIZnet Ethernet by changing two lines of code. The same firmware binary can manage either transport without modification to application logic.

---

### Who This Is For

**Developers and makers who:**

- Prototype with Wi-Fi on ESP32 and need a clean migration path to wired Ethernet for production

- Maintain a single firmware that runs on both Wi-Fi and WIZnet Ethernet nodes

- Need zero-configuration device discovery (mDNS/Bonjour) without fixed IP addresses

- Work with M5Stack Atom POE or any SPI-connected WIZnet chip on ESP32

**Applications where MicroNet is effective:**

- Wired sensor nodes in factory or warehouse environments (RF interference avoidance, PoE power delivery)

- Distributed IoT systems where multiple devices discover each other via mDNS on a local network

- Demo or education devices in environments with unreliable Wi-Fi

- Development projects planned to transition from Wi-Fi prototype to WIZnet Ethernet product

---

### Compatible Hardware

| Category | Details |
| --- | --- |
| MCU | ESP32 (Arduino Core) |
| Ethernet chips | WIZnet W5100 / W5500 / W6300 (SPI) |
| Verified boards | M5Stack Atom POE (with Atom Lite or Atom S3) |
| Development environment | Arduino IDE, PlatformIO |

Any ESP32 board with a WIZnet chip connected over SPI is supported in generic Ethernet mode. Boards like M5Stack Atom POE are supported via built-in presets that handle SPI initialization automatically.

---

### Architecture

The block diagram above illustrates MicroNet's layered architecture.

![](https://maker.wiznet.io/upload/ckeditor5/998848188%5F1778444700%2Egif)

At the top sits the **application code**, which calls a unified set of API methods without any knowledge of the underlying network interface. Below it, the **MicroNet unified interface** acts as a middleware abstraction layer that routes calls to either `MicroNetWiFi` or `MicroNetEthernet` depending on which class is instantiated.

Each class then delegates to its respective platform library:

- `MicroNetWiFi` → ESP32 Arduino `WiFi.h`, `WiFiManager`, and `mDNS`

- `MicroNetEthernet` → Arduino `Ethernet.h`, and `EthernetBonjour`

At the hardware level, the Wi-Fi path connects to a wireless access point, while the Ethernet path interfaces directly with a **WIZnet W5x00-series chip** (W5100, W5500, or W6300).

---

### Switching Between Wi-Fi and Ethernet

The most important design property of MicroNet is API symmetry. Both `MicroNetWiFi` and `MicroNetEthernet` expose identical method signatures:

```cpp
// Wi-Fi
#include <MicroNetWiFi.h>
MicroNetWiFi myNet;

// Ethernet (swap only this)
#include <MicroNetEthernet.h>
MicroNetEthernet myNet;

void setup() {
    myNet.begin("myDevice");
}
void loop() {
    myNet.update();
}
```

The application-level `setup()` and `loop()` code requires no modification when switching between transports.

Available presets:

- `ATOM_POE_WITH_ATOM_LITE` — M5Stack Atom POE with Atom Lite

- `ATOM_POE_WITH_ATOMS3` — M5Stack Atom POE with Atom S3

With a preset, the `begin()` call handles SPI initialization internally. Without a preset (generic Ethernet), the developer configures the SPI bus manually before calling `begin()`:

```cpp
SPI.begin(22, 23, 33, 19); // SCK, MISO, MOSI, CS for Atom Lite POE
Ethernet.init(19);          // CS pin
myNet.begin("myDevice");
```

**Note:** `Ethernet.begin()` must **not** be called directly. MicroNet handles the DHCP handshake internally within `begin()`.

For generic Ethernet (no preset), configure the SPI bus before calling `begin()`. Do **not** call `Ethernet.begin()` directly — MicroNet handles the DHCP handshake internally.

---

### Full API Reference

| Method | Description |
| --- | --- |
| `begin(name)` | Initializes the interface, obtains DHCP address, registers mDNS hostname. Blocking. |
| `update()` | Runs periodic maintenance tasks (mDNS keepalive). Call every loop iteration. |
| `getIP()` | Returns the current `IPAddress` assigned by DHCP. |
| `resolveName(host)` | Resolves an mDNS hostname to `IPAddress`. Blocking until found. |
| `announceTCPService(name, port)` | Advertises a TCP service over mDNS. |
| `announceUDPService(name, port)` | Advertises a UDP service over mDNS. |
| `copyMac(mac[6])` | Copies the device MAC address into a 6-byte buffer. |
| `appendMacToCString(prefix, maxSize, numBytes)` | Appends MAC bytes to a name prefix for unique device naming. |

---

##### Why This Matters for WIZnet Users

MicroNet directly addresses a common development workflow: **starting a project on Wi-Fi and later migrating to WIZnet Ethernet**.

Wi-Fi is convenient for rapid prototyping — no additional hardware, no cabling. But for deployments requiring reliability, deterministic latency, PoE power delivery, or RF-clean environments, WIZnet Ethernet is the right choice.

Without MicroNet, this migration typically requires a significant rewrite of the network initialization and management layer. With MicroNet, it reduces to a header swap and a class name change.

Additionally, the `EthernetBonjour` integration means that WIZnet-connected devices participate in zero-configuration networking — something usually associated only with Wi-Fi IoT devices. This makes WIZnet-based nodes equally discoverable on a LAN without requiring fixed IP addresses or manual DNS entries.

##### Tested Hardware

- **MCU:** ESP32

- **Ethernet:** WIZnet Ethernet controller chips (W5x00 series)

- **Board:** M5Stack Atom POE

##### Dependencies

- `WiFiManager` (for Wi-Fi captive portal)

- `EthernetBonjour` (for Ethernet mDNS)

- Arduino `Ethernet.h` (standard library)

- ESP32 Arduino Core

##### Repository

<https://github.com/thomasfredericks/MicroNet>
License: MIT | Platform: ESP32 | Latest: v0.1.2

---

### QnA

**Q: What is MicroNet for Arduino?** MicroNet is a network connection manager library for Arduino and PlatformIO that provides a unified API for both Wi-Fi and WIZnet Ethernet on ESP32. It handles DHCP, mDNS/Bonjour, and Wi-Fi captive portal configuration through a consistent set of methods, regardless of the underlying network interface.

---

**Q: Can I use Wi-Fi and WIZnet Ethernet with the same code on ESP32?** Yes. MicroNet provides identical method signatures for both `MicroNetWiFi` and `MicroNetEthernet`. To switch between them, only the include header and the class instantiation need to change. All application logic in `setup()` and `loop()` remains the same.

---

**Q: Which WIZnet chips are supported by MicroNet?** MicroNet supports WIZnet W5x00-series chips including the W5100, W5500, and W6300, connected to an ESP32 via SPI. The M5Stack Atom POE (which uses a WIZnet chip) has been tested and has a built-in board preset.

---

**Q: What is the difference between lwIP and WIZnet TOE in embedded Ethernet?** lwIP is a software TCP/IP stack that runs on the MCU, consuming CPU cycles for every network operation. WIZnet chips implement a hardware TCP/IP Offload Engine (TOE), meaning the full TCP/IP stack is processed on-chip. This offloads the MCU from network processing, which is particularly valuable on resource-constrained devices like the ESP32.

---

**Q: Does MicroNet support mDNS on WIZnet Ethernet?** Yes. MicroNet integrates `EthernetBonjour` on the Ethernet path, providing full mDNS/Bonjour support including hostname registration, hostname resolution (`resolveName()`), and TCP/UDP service advertisement (`announceTCPService()`, `announceUDPService()`). This allows WIZnet-connected devices to participate in zero-configuration networking on a local network.

---

Source: https://maker.wiznet.io/lawrence/projects/micronet/
