Skip to content

chumicro-wifi

Wifi that auto-reconnects without freezing your loop.

One wifi service across CircuitPython on Adafruit boards and MicroPython on both ESP32 and Pi Pico W. Register it with chumicro-runner and your LED keeps blinking through every connect, drop, and reconnect. This library owns the radio (no CIRCUITPY_WIFI_* settings, no firmware-level auto-reconnect competing with you). On CPython there is no radio to drive, so the service runs against a host stand-in adapter that reports success immediately, and your host tests exercise the same state machine.

Install

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

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

# CPython
pip install chumicro-wifi

No board running yet? Start here goes from a new board to your own code running on it. Installing libraries covers registering the bundle, the experimental channel, and the pre-compiled .mpy packages.

Quick example

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

config = load_runtime_config()
wifi = WifiService.from_config(config)

runner = Runner()
runner.add(wifi)

while True:
    now_ms = runner.tick()   # every registered service takes one small step
    runner.wait(now_ms)      # then the CPU parks until the next event or deadline

Documentation

  • User Guide: the connect and reconnect state machine, reading IP and errors, state-change notifications, configuration, and runner integration
  • API Reference: WifiService, WifiConfig, and the WifiState constants
  • Testing Helpers: using FakeWifi in your tests