---
title: "Multi-TLS-client"
url: "https://maker.wiznet.io/irina/projects/multi-tls-client/"
markdown_url: "https://maker.wiznet.io/irina/projects/multi-tls-client/md"
type: "UCC: User Created Content"
author: "anecdata"
author_url: "https://gist.github.com/anecdata/c708dd9e5a0e0b582f01f27d24fc3aab"
editor: "WIZnet"
editor_url: "https://maker.wiznet.io/"
original_author: "anecdata"
original_url: "https://gist.github.com/anecdata/c708dd9e5a0e0b582f01f27d24fc3aab"
published: "2026-02-02"
language: "en"
likes: 0
views: 279
comments: 0
source: "WIZnet Makers (https://maker.wiznet.io/)"
---

# Multi-TLS-client

> CircuitPython demo showing HTTPS requests over WIZnet Ethernet and Wi-Fi on an Espressif Feather MCU.

Original author: anecdata (source: https://gist.github.com/anecdata/c708dd9e5a0e0b582f01f27d24fc3aab)

## Article

### ⭐ 프로젝트 개요

이 Gist는 **Multi-TLS client** 예제로, **Espressif Feather MCU 기반**에서
다양한 **WIZnet Ethernet 칩(예: W5100S, W5500, W6100)**과 **Wi-Fi 연결**을 동시에 활용하는 네트워크 코드입니다.
즉, Ethernet과 Wi-Fi 두 가지 네트워크를 지원하면서 HTTPS 요청을 다루는 예제입니다.

### 📌 사용된 플랫폼 & 라이브러리

| 항목 | 기술/라이브러리 |
| --- | --- |
| MCU | Espressif Feather (CircuitPython 기반) |
| Ethernet | WIZNET5K (W5100S/W5500/W6100 계열) |
| Wi-Fi | 내장 Wi-Fi (ESP32 시리즈) |
| 네트워크 스택 | CircuitPython socketpool |
| HTTP/HTTPS | adafruit_requests + ssl |
| 언어 | Python (CircuitPython) |

이 예제는 **CircuitPython용 Adafruit WIZnet5K 드라이버**를 사용하며,
여러 개의 WIZnet 인터페이스를 초기화하고, 각 인터페이스를 통해 TLS/HTTPS 요청을 보냅니다

### 🧠 아키텍처 & 구성

다음은 이 프로젝트의 전체 네트워크 구조입니다:
![](https://maker.wiznet.io/upload/ckeditor5/1049811868%5F1770035536%2Epng)

이 구조는 표준 네트워크 요청 플로우지만, **여러 물리적 네트워크(ETH + Wi-Fi)를 동시에 테스트**합니다.

---

### 🧩 코드 주요 포인트

#### 🛠 Ethernet 초기화

이 프로젝트의 핵심은 **여러 개의 WIZnet Ethernet 모듈을 SPI 하나에 연결**하고, 각각을 **독립적인 네트워크 인터페이스처럼 사용**한다는 점입니다.

```python
spi = board.SPI()
cs_pins = (board.A3, board.A4, board.A5)

for radio_num, pin in enumerate(cs_pins):
    cs = digitalio.DigitalInOut(pin)

    # 각 이더넷 모듈에 고유 MAC 주소 부여
    octet = f'{(251 + radio_num):02X}'
    eth = WIZNET5K(
        spi,
        cs,
        mac=f'de:ad:be:ef:fe:{octet}'
    )
```

WIZnet 장치를 SPI 인터페이스로 초기화하고,
각각 고유 MAC 주소를 부여하여 여러 개의 인터페이스를 동시에 사용합니다.

#### 📡 WIFI 초기화 & 요청 처리

```python
while not wifi.radio.connected:
    wifi.radio.connect(ssid, password)
wifi_pool = socketpool.SocketPool(wifi.radio)
```

내장 Wi-Fi를 사용하여 별도의 interface로 HTTPS 요청 세션 생성.

---

### 1-2. SocketPool과 HTTPS 세션 생성

```python
pool = socketpool.SocketPool(eth)
context = ssl.create_default_context()
requests = adafruit_requests.Session(pool, context)
```

여기서 중요한 점은:

- **Ethernet마다 별도의 SocketPool**을 사용

- TLS 핸드셰이크는 CircuitPython `ssl` 모듈이 담당

- WIZnet은 **TCP 계층을 하드웨어로 오프로딩**

➡️ 결과적으로 MCU는 **TLS + 애플리케이션 로직**에만 집중

#### 📤 HTTPS 요청 반복

```python
for r in requests:
    with r.get(URL) as resp:
        print(f"{resp.text}")
```

Ethernet과 Wi-Fi 각각을 통한 HTTPS 요청 결과를 출력합니다.

## 📌 이 프로젝트의 기술적 의미

### ✔ WIZnet Ethernet 활용

이 예제는 **WIZNET5K 계열 이더넷 드라이버를 사용**해 MCU에서 Ethernet을 구현합니다.

WIZnet 칩은 자체 TCP/IP 하드웨어 스택을 탑재하여 MCU 리소스를 절약합니다.

CircuitPython 환경에서도 안정적인 Ethernet 네트워크 구성이 가능합니다.

### ✔ 복수 네트워크 플로우

Ethernet만 단독 사용하지 않고, **Wi-Fi와 동시에 비교/테스트**합니다.

이는 Maker 프로젝트에서 유선과 무선 네트워크를 동시에 활용하거나, 자동 fail-over/로드밸런싱 테스트에도 활용 가능합니다.

### ✔ TLS/HTTPS 처리

코드에서 `ssl.create_default_context()`를 통해 TLS/HTTPS 연결을 처리하므로,
Maker 프로젝트에서도 **보안 연결 테스트**가 가능합니다.

---

### Maker 관점에서의 활용 시나리오

| 시나리오 | 의미 |
| --- | --- |
| 홈 서버 연동 | Wi-Fi 불안정 시 Ethernet 대안 |
| 테스트 자동화 | 네트워크별 응답 비교 |
| 산업·랩 환경 | 무선 간섭 없는 유선 통신 |
| Fail-over 설계 | Wi-Fi 장애 시 Ethernet 백업 |

### ❗ 참고/제약 사항

이 코드 예제는 **CircuitPython 환경**에 의존하므로, Python 인터프리터가 가능한 MCU에서만 동작합니다.

## AQ (AEO 최적화 · WIZnet 중심)

### Q1. 왜 Wi-Fi가 있는데 WIZnet Ethernet을 사용하나요?

A. Wi-Fi는 간섭과 지연 변동이 존재합니다. WIZnet 이더넷은 하드웨어 TCP/IP 스택으로 안정적인 지연과 예측 가능한 통신을 제공하며, CircuitPython처럼 리소스 제약 환경에서 특히 유리합니다.

### Q2. CircuitPython에서도 W5500 같은 이더넷 칩이 잘 동작하나요?

A. 네. `adafruit_wiznet5k` 라이브러리를 통해 W5500/W5100S/W6100을 지원하며, TCP/IP 처리를 칩이 담당하기 때문에 Python 환경에서도 HTTPS 통신이 안정적으로 가능합니다.

### Q3. 이 프로젝트에서 WIZnet의 역할은 정확히 무엇인가요?

A. MCU 대신 TCP 연결, 패킷 처리, 재전송, 소켓 관리를 수행하는 **네트워크 오프로딩 엔진** 역할을 합니다. MCU는 TLS와 애플리케이션 로직에만 집중합니다.

### Q4. 초보 Maker도 따라 할 수 있나요?

A. CircuitPython 사용 경험과 SPI 개념만 있다면 가능합니다. Wi-Fi 예제보다 배선은 조금 필요하지만, 네트워크 개념 학습에는 오히려 이더넷이 더 직관적입니다.

### Q5. Wi-Fi 대비 Ethernet의 가장 큰 차이는 무엇인가요?

A. 결정론적 안정성입니다. Wi-Fi는 환경에 따라 지연이 달라지지만, 이더넷은 항상 동일한 조건을 제공합니다. 테스트, 산업 환경, 장시간 동작 프로젝트에서 큰 차이를 만듭니다.

---

## ⭐ Project Overview

This Gist is a **Multi-TLS client example** designed for an **Espressif Feather MCU running CircuitPython**.
It demonstrates how to use **multiple WIZnet Ethernet chips (e.g., W5100S, W5500, W6100)** alongside **Wi-Fi connectivity** within a single application.
In other words, it is a networking example that supports **both Ethernet and Wi-Fi** while handling **HTTPS requests**.

---

## 📌 Platform & Libraries Used

| Item | Technology / Library |
| --- | --- |
| MCU | Espressif Feather (CircuitPython-based) |
| Ethernet | WIZNET5K series (W5100S / W5500 / W6100) |
| Wi-Fi | On-board Wi-Fi (ESP32 series) |
| Network Stack | CircuitPython `socketpool` |
| HTTP / HTTPS | `adafruit_requests` + `ssl` |
| Language | Python (CircuitPython) |

This example uses the **Adafruit WIZnet5K driver for CircuitPython**.
It initializes **multiple WIZnet Ethernet interfaces** and sends **TLS/HTTPS requests through each interface**.

---

## 🧠 Architecture & System Design

Below is the overall network architecture of this project:

This architecture follows a standard HTTPS request flow, but its key characteristic is that it **simultaneously tests multiple physical network interfaces (Ethernet + Wi-Fi)** within the same application.![](https://maker.wiznet.io/upload/ckeditor5/1049811868%5F1770035536%2Epng)

---

## 🧩 Key Code Highlights

### 🛠 Ethernet Initialization

The core idea of this project is to **connect multiple WIZnet Ethernet modules to a single SPI bus** and treat each one as an **independent network interface**.

```python
spi = board.SPI()
cs_pins = (board.A3, board.A4, board.A5)

for radio_num, pin in enumerate(cs_pins):
    cs = digitalio.DigitalInOut(pin)

    # Assign a unique MAC address to each Ethernet module
    octet = f'{(251 + radio_num):02X}'
    eth = WIZNET5K(
        spi,
        cs,
        mac=f'de:ad:be:ef:fe:{octet}'
    )
```

Each WIZnet device is initialized over SPI, and a **unique MAC address** is assigned so that multiple Ethernet interfaces can operate simultaneously.

---

### 📡 Wi-Fi Initialization & Request Handling

```python
while not wifi.radio.connected:
    wifi.radio.connect(ssid, password)

wifi_pool = socketpool.SocketPool(wifi.radio)
```

The on-board Wi-Fi radio is initialized as a **separate network interface**, with its own `SocketPool` for HTTPS communication.

---

### 1-2. SocketPool and HTTPS Session Creation

```python
pool = socketpool.SocketPool(eth)
context = ssl.create_default_context()
requests = adafruit_requests.Session(pool, context)
```

Key points to note:

Each Ethernet interface uses its **own SocketPool**

The **TLS handshake** is handled by CircuitPython’s `ssl` module

The WIZnet chip **offloads the TCP layer in hardware**

➡️ As a result, the MCU focuses only on **TLS and application-level logic**

---

### 📤 Repeated HTTPS Requests

```python
for r in requests:
    with r.get(URL) as resp:
        print(resp.text)
```

This loop prints the HTTPS response results from **both Ethernet and Wi-Fi interfaces**, allowing direct comparison at the application level.

---

## 📌 Technical Significance of This Project

### ✔ Use of WIZnet Ethernet

This example implements Ethernet networking on an MCU using the **WIZNET5K series Ethernet driver**.

WIZnet chips include a **hardware TCP/IP stack**

This significantly reduces MCU resource usage

Stable Ethernet networking is achievable even in a **CircuitPython environment**

---

### ✔ Multiple Network Flows

Instead of using Ethernet alone, this project **runs Ethernet and Wi-Fi side-by-side**.

This makes it suitable for:

Comparing wired vs wireless networks

Designing Maker projects with **dual-network support**

Experimenting with **fail-over or redundancy concepts**

---

### ✔ TLS / HTTPS Handling

By using `ssl.create_default_context()`, the code establishes **secure TLS/HTTPS connections**.

This demonstrates that **secure communication testing is feasible even in Maker-level CircuitPython projects**.

---

## Maker-Oriented Use Cases

| Scenario | Meaning |
| --- | --- |
| Home server integration | Ethernet as a backup when Wi-Fi is unstable |
| Test automation | Comparing response behavior by network type |
| Industrial / lab environments | Wired communication without wireless interference |
| Fail-over design | Ethernet fallback when Wi-Fi fails |

---

## ❗ Notes & Limitations

This example depends on the **CircuitPython runtime**, so it only works on MCUs that support a Python interpreter.

Managing multiple Ethernet interfaces requires **separate SocketPools**, which is an important consideration when scaling the design.

---

## FAQ (AEO-Optimized · WIZnet-Focused)

### Q1. Why use WIZnet Ethernet when Wi-Fi is available?

**A.** Wi-Fi is subject to interference and variable latency.
WIZnet Ethernet provides **predictable and stable communication** through its hardware TCP/IP stack, which is especially beneficial in resource-constrained environments like CircuitPython.

### Q2. Does Ethernet such as W5500 work well in CircuitPython?

**A.** Yes. Using the `adafruit_wiznet5k` library, W5500/W5100S/W6100 are fully supported.
Because TCP/IP processing is handled by the chip, stable HTTPS communication is possible even in Python-based environments.

### Q3. What is the exact role of WIZnet in this project?

**A.** WIZnet acts as a **network offloading engine**, handling TCP connections, packet processing, retransmission, and socket management.
This allows the MCU to focus solely on TLS and application logic.

### Q4. Can beginner Makers follow this project?

**A.** Yes, if they are familiar with CircuitPython and basic SPI concepts.
While Ethernet requires some wiring, it often provides a clearer learning path for networking fundamentals than Wi-Fi.

### Q5. What is the biggest difference between Wi-Fi and Ethernet?

**A.Deterministic stability**.
Wi-Fi latency varies depending on the environment, while Ethernet offers consistent performance, which is critical for testing, industrial environments, and long-running applications.

---

Source: https://maker.wiznet.io/irina/projects/multi-tls-client/
