Skip to main content

chumicro-wifi

Wifi that auto-reconnects so your app code doesn't have to.

One WiFi service across CircuitPython (Adafruit boards) and MicroPython on both ESP32 and Pi Pico W. Owns the radio (no CIRCUITPY_WIFI_* settings, no firmware-level auto-reconnect competing with you), surfaces state transitions as events you can wire into the rest of your app via chumicro-runner, and reads its config section via chumicro-config. CircuitPython's substrate-level connect() is blocking. See Platform support for what that means in practice.


Part of the ChuMicro family: small, focused Python libraries for microcontrollers and laptops. Browse all libraries.

Install

# CircuitPython (after `circup bundle-add ChuMicro/ChuMicro-Bundle-Experimental`)
circup install chumicro_wifi

# MicroPython
mpremote mip install github:ChuMicro/ChuMicro-Bundle-Experimental/chumicro_wifi

# CPython
pip install chumicro-wifi-experimental

For bundle setup, pre-compiled .mpy bundles, the experimental channel, and details on PyPI naming, see the chumicro INSTALL guide.

Quick example

User-app pattern (the 4-line bring-up):

from chumicro_config import load_runtime_config
from chumicro_runner import Runner
from chumicro_wifi import WifiConfig, WifiService

config = load_runtime_config()
runner = Runner()
wifi = WifiService(WifiConfig.from_config(config))
runner.add(wifi)

State + IP introspection any time:

wifi.state          # "disconnected" | "connecting" | "connected" | "reconnecting" | "failed"
wifi.connected
wifi.ip
wifi.last_error
wifi.on_state_change(lambda old, new: print(f"{old} -> {new}"))

What's included

Symbol What it does
WifiConfig Typed connection settings (ssid, password, hostname, timeouts, reconnect tuning). from_config(config) reads the flat wifi.* keys; try_from_config(config) returns None when the section isn't deployed.
WifiService State machine + reconnect supervisor; implements Runner.add()-compatible check/handle. Auto-detects the runtime adapter at construction time (FakeWifiAdapter on CPython, CpWifiAdapter on CircuitPython, substrate-aware MpWifiAdapter on MicroPython, handling ESP-IDF + CYW43 transparently).
WifiState String-sentinel state names: DISCONNECTED, CONNECTING, CONNECTED, RECONNECTING, FAILED.
chumicro_wifi.testing.FakeWifi Drop-in WifiService wrapping a FakeWifiAdapter with set_connect_outcome, drop_link, calls hooks for downstream library tests.

Where this fits

Depends on chumicro-config for its config section and registers with chumicro-runner for its tick contract. Provides the radio the networking layers sit on top of: chumicro-sockets on CircuitPython, with the HTTP / MQTT / WebSocket / NTP libraries downstream of that.

Platform support

Works on CPython, MicroPython, and CircuitPython. Ships three adapters: CircuitPython wifi.radio (_adapters/cp.py), MicroPython network.WLAN covering both ESP-IDF (ESP32 family) and CYW43 (Pi Pico W) stacks (_adapters/mp.py), and a FakeWifiAdapter for host-side tests. The right adapter is selected at runtime via sys.implementation.name; the MP adapter then auto-detects ESP-IDF vs CYW43 by matching sys.implementation._machine against a positive whitelist of known CYW43 boards.

CircuitPython connect is blocking (read this if you're shipping to CP)

CircuitPython's substrate-level wifi.radio.connect() is blocking. There is no non-blocking variant exposed by the firmware. While WifiService is CONNECTING or RECONNECTING on a CircuitPython board, handle() stalls for up to connect_timeout_ms (default 15 000 ms). Other services in the same Runner (your LED heartbeat, an HTTP request, an MQTT keep-alive) pause for that window. Once the state reaches CONNECTED, the loop runs at full speed again and stays there until the link drops.

MicroPython's wlan.connect() is genuinely non-blocking on both ESP32 and Pi Pico W substrates: association happens in the background and handle() returns immediately. If non-blocking connect is load-bearing for your app, prefer MicroPython on RP2040 / RP2350 or ESP32-family boards.

Examples

Example What it shows
connect_to_ap.py Connect to a real AP, print state transitions, observe IP, reading wifi.ssid / wifi.password from runtime_config.msgpack.

Wiring wifi credentials

The library never reads TOML itself: it takes a WifiConfig and connects. WifiConfig.from_config(config) is the construction path the standard pipeline uses, reading credentials from your project's runtime config under the wifi.* keys (wifi.ssid, wifi.password). To get those credentials onto the device, deploy them as part of a workspace-based deploy or a raw single-file deploy. The bundled connect_to_ap.py example and the on-device acceptance test both read the credentials this way and skip silently when none are configured.

Contributing

Issues, bug reports, and pull requests are welcome, and so is "I ran it on this board and here's what happened", some of the most useful feedback a hardware project can get. Development happens in the ChuMicro repository, whose contributing guide covers setup and the test workflow.

Docs

📖 Stable docs · Experimental docs

Find this library

License

MIT

Metadata

Release files for chumicro-wifi-experimental 0.8.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for chumicro-wifi-experimental 0.8.2
File Size Uploaded
chumicro_wifi_experimental-0.8.2.tar.gz 32.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for chumicro-wifi-experimental 0.8.2
File Interpreter ABI Platform
chumicro_wifi_experimental-0.8.2-py3-none-any.whl Python 3 none any Details

Total release size: 46.6 kB

Release files / chumicro_wifi_experimental-0.8.2.tar.gz

Download URL chumicro_wifi_experimental-0.8.2.tar.gz
Size 32.5 kB
Tags Source
SHA-256 checksum
How to use checksums
78155f5f4ff499b647344386232a148ba1ca850e02176334392d6b7a5308f305
BLAKE2b-256 checksum
How to use checksums
4fb0e3fc32e7f97240def4143ce061e6123252590027ef63773a23381e31f6db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.

Transparency log

Release files / chumicro_wifi_experimental-0.8.2-py3-none-any.whl

Download URL chumicro_wifi_experimental-0.8.2-py3-none-any.whl
Size 14.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d86322f4e2e3fa192dc6e8ac2b8118e58dd4de39d1776cd4d6362ce444a4743
BLAKE2b-256 checksum
How to use checksums
e6b6867d084611570d0df432cf1a0dd975412de9647f9c12cde93d4e1c14a05e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 7, 2026.

Transparency log

Release history Release notifications | RSS feed

0.11.2

2 release files

0.11.1

2 release files

0.9.0

2 release files

This release

0.8.2 This release

2 release files

0.8.1

2 release files

0.8.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page