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 WifiService

config = load_runtime_config()
runner = Runner()
wifi = WifiService.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. from_config(config, radio=None, ...) builds it straight from the flat wifi.* keys; extra keywords pass through to the constructor. Auto-detects the runtime adapter at construction time (the CpythonWifiAdapter host stand-in 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 runtime 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 CPython host stand-in that reports success immediately (_adapters/cpython.py); chumicro_wifi.testing.FakeWifiAdapter covers 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. WifiService.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) through the same WifiConfig.from_config(config) loader that also works standalone. 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.10.0

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.10.0
File Size Uploaded
chumicro_wifi_experimental-0.10.0.tar.gz 34.4 kB Details

Built distribution (wheel)

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

Total release size: 50.2 kB

Release files / chumicro_wifi_experimental-0.10.0.tar.gz

Download URL chumicro_wifi_experimental-0.10.0.tar.gz
Size 34.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5659c5a65281751abae33e1ccfd7cd636e98b1f56d629c3b72f236a04769271f
BLAKE2b-256 checksum
How to use checksums
3e5fc973d55ea4bfbc01078e04164b1bef5a86765f47bba5f2ae54f8c6083b22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 9, 2026.

Transparency log

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

Download URL chumicro_wifi_experimental-0.10.0-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
689b1f9370f17f1ebb69ecec3a749b8f0dd1e5728772334f0e72347e533898db
BLAKE2b-256 checksum
How to use checksums
09364920741f9aca009f287e93eb0af5eb76fbfa374d1f1ddf6d5b5c1a132992
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 9, 2026.

Transparency log

Release history Release notifications | RSS feed

0.11.2

2 release files

0.11.1

2 release files

This release

0.10.0 This release

2 release files

0.9.0

2 release files

0.8.2

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