Python middleware that bridges NFC spool scanning to your 3D printer. Receives tag data from SpoolSense Scanner via MQTT and orchestrates Klipper, Spoolman, and Home Assistant.
SpoolSense Scanner → MQTT → Middleware → Klipper / Spoolman / Home Assistant
- Scanner reads an NFC tag on a filament spool
- Tag data is published to MQTT as a JSON payload
- Middleware receives the scan and routes it based on the scanner's configured action
- If Spoolman is configured, the spool is looked up or created and synced
- Spool data (color, material, weight) is sent to Klipper — with or without Spoolman
- For shared scanner modes (
afc_stage,toolhead_stage), tag data is cached until a lane loads or a tool is picked up
Each scanner is configured with an action that determines how scans are routed:
| Action | Description |
|---|---|
afc_stage |
Shared scanner for AFC (BoxTurtle, NightOwl). Scan a spool, load into any lane — AFC assigns automatically. One scanner for all lanes. |
afc_lane |
Dedicated scanner per AFC lane. Locks scanner until lane is cleared. |
toolhead_stage |
Shared scanner for toolchanger printers (klipper-toolchanger). Scan a spool, pick up any tool — spool auto-assigns. One scanner for all toolheads. |
toolhead |
Dedicated scanner per toolhead. Sets active spool and saves to Klipper variables. |
single |
One scanner, one extruder. Spool activates on scan. |
Mixed configs are supported — for example, afc_stage for BoxTurtle lanes and toolhead for direct toolheads on the same printer.
- Per-scanner action routing — each scanner independently routes to AFC lanes, toolheads, or shared staging
- Works with or without Spoolman — tag data (color, material, weight) is sent directly when Spoolman is not configured
- Slicer integration — publish spool data (color, material, weight, nozzle/bed temps) to Moonraker's
lane_datadatabase. Orca Slicer and other slicers auto-populate tool info. Opt-in viapublish_lane_data: true. For users without AFC or Happy Hare (they already provide this). - Extensible publisher architecture — spool activation output is decoupled from Klipper/Moonraker. Adding support for new printer platforms (Prusa, Bambu, etc.) requires one new file.
- Automatic spool lookup and registration in Spoolman (when configured)
- Klipper spool activation (SET_ACTIVE_SPOOL, SET_SPOOL_ID, SET_NEXT_SPOOL_ID)
- AFC lane state sync via Moonraker API polling — no file watcher dependency
- Toolchanger state sync via Moonraker — detects tool pickups for
toolhead_stage - Low spool detection with LED breathing effect
- Spool ID persistence across reboots via Klipper save_variables
- Legacy config auto-migration — old
toolhead_mode+scanner_lane_mapconfigs are converted automatically - Home Assistant online/offline status via MQTT Last Will
- Moonraker update_manager compatible for automatic updates
curl -sL https://raw.githubusercontent.com/SpoolSense/spoolsense-installer/main/install.sh -o /tmp/install.sh && bash /tmp/install.shThe installer handles cloning, config generation, dependency installation, and systemd service setup.
See docs/middleware-setup.md for step-by-step manual installation.
Config lives in ~/SpoolSense/config.yaml (never overwritten by updates). Templates for each mode:
middleware/config.example.single.yamlmiddleware/config.example.toolchanger.yamlmiddleware/config.example.afc.yaml
Validate your config without starting the service:
python3 ~/SpoolSense/middleware/spoolsense.py --check-configAdd to your moonraker.conf:
[update_manager spoolsense]
type: git_repo
path: ~/SpoolSense
origin: https://github.com/SpoolSense/spoolsense_middleware.git
primary_branch: master
managed_services: spoolsense- Python 3.6+
- MQTT broker (e.g. Mosquitto — Home Assistant users typically have this already)
- Klipper + Moonraker
- Spoolman (optional but recommended)
- SpoolSense Scanner hardware
See the docs/ folder for setup guides:
- Middleware Setup — manual installation and configuration
- Klipper Setup — macros, spool persistence, toolhead config
- Spoolman Setup — extra fields, low spool warnings
- AFC Setup — BoxTurtle lane scanning and LED colors
- spoolsense_scanner — ESP32 NFC scanner firmware
- spoolsense-installer — Interactive setup CLI
