Skip to main content

๐Ÿš€ Zero-touch provisioning for Raspberry Pi fleets - Configure WiFi, SSH, users, hardware peripherals, and manage devices through encrypted mesh networking

Project description


title: "MeshPi โ€” Zero-Touch Raspberry Pi Fleet Management" date: 2025-02-24 categories: [open-source, iot, raspberry-pi, python] tags: [meshpi, rpi, automation, llm, gpio, hardware-profiles, fleet-management] status: active version: "0.2.0" repo: https://github.com/pyfunc/meshpi license: Apache-2.0

MeshPi โ€” Zero-Touch Raspberry Pi Fleet Management

PyPI version CI Status Code coverage License Python versions Issues

๐Ÿš€ Zero-touch provisioning for Raspberry Pi fleets
Configure WiFi, SSH, users, hardware peripherals, and manage devices โ€” all through encrypted mesh networking

Installation โ€ข Quick Start โ€ข Features โ€ข Documentation

What is MeshPi?

MeshPi is an open-source Python package that eliminates the manual work of configuring Raspberry Pi devices from factory defaults. Whether you are deploying one device or an entire fleet, MeshPi handles WiFi credentials, SSH keys, user accounts, locale settings, hardware peripherals, and ongoing management โ€” all through a single CLI and an encrypted, zero-trust network protocol.

The project is built for embedded systems developers, IoT integrators, and hardware prototyping labs who regularly provision Raspberry Pi hardware and need a repeatable, secure, and automated workflow.


โœจ Quick Start

# Install MeshPi
pip install meshpi

# On HOST machine (your PC or a dedicated RPi)
meshpi config    # One-time configuration wizard
meshpi host      # Start the host service

# On each CLIENT Raspberry Pi (fresh from factory)
meshpi scan      # Auto-discover host, configure itself, and reboot

๐ŸŽฏ That's it! Your Raspberry Pi is now configured with WiFi, SSH access, user accounts, and ready for hardware automation.


๐Ÿ—๏ธ Architecture

MeshPi uses a hostโ€“client model with end-to-end RSA+AES-GCM encryption. No credentials ever travel in plaintext.

HOST (PC / RPi)                     CLIENT (fresh RPi)
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
meshpi config                       meshpi scan
  โ†’ ~/.meshpi/config.env              โ†’ mDNS discovery
meshpi host                           โ†’ sends RSA public key
  โ†’ FastAPI + mDNS               โ†  host encrypts config
  โ†’ WebSocket /ws/{id}           โ†’  client decrypts & applies
  โ†’ Dashboard /dashboard              โ†’ WiFi, SSH, user, locale
                                      โ†’ reboots
                              โ†•
                         meshpi daemon
                           โ†’ persistent WebSocket
                           โ†’ diagnostics push (60s)
                           โ†’ executes remote commands

The host also exposes a real-time web dashboard at /dashboard and a full REST API with Swagger UI at /docs.


๐Ÿš€ Key Features

๐Ÿ” Encrypted Zero-Touch Provisioning

Configuration is encrypted with AES-256-GCM. The session key is wrapped with the client's RSA-2048 public key. No shared secrets. No cleartext on the wire.

๐Ÿ“ก Real-Time Fleet Management

Once a device runs meshpi daemon, the host can push configuration changes, execute shell commands, apply hardware profiles, and trigger reboots โ€” all through the WebSocket channel. The REST endpoint POST /devices/{id}/push_config delivers updates instantly without re-provisioning.

๐Ÿ”ง 49+ Hardware Profiles

MeshPi ships with ready-to-apply profiles covering a wide range of peripherals:

Category Examples
display OLED SSD1306 I2C, TFT ILI9341 SPI, e-Paper Waveshare, HDMI 1080p/4K, DSI Touchscreen
gpio A4988/ARM69AK steppers, relay boards, PCA9685 servo controller, HC-SR04 distance sensor
sensor BME280 (temp/humidity/pressure), DS18B20 (1-Wire), MPU-6050 (IMU), INA219 (power monitor)
camera RPi Camera v2 & HQ, USB UVC, IR night vision
audio HiFiBerry DAC+, I2S MEMS microphone
networking CAN MCP2515, RS-485/Modbus, LoRa SX127x, nRF24L01
hat Sense HAT, PiSugar UPS, RTC DS3231, PoE+
storage USB boot, NFS, Samba

Each profile installs apt packages, loads kernel modules, patches /boot/config.txt, and runs post-install commands โ€” all in one step:

meshpi hw apply oled_ssd1306_i2c sensor_bme280 gpio_stepper_arm69ak

๐Ÿค– LLM-Powered Management Agent

The optional meshpi[llm] extra installs LiteLLM, enabling a conversational agent that understands natural language fleet management commands:

You: co jest nie tak z rpi-kuchnia?
Agent: [fetches diagnostics] CPU temperature is 84ยฐC โ€” above safe threshold.
       The throttled flag is set. Recommend improving airflow or adding a heatsink.
       Services: wpa_supplicant is inactive โ€” WiFi may have dropped.
       Suggest: restart wpa_supplicant and check SSID config.

You: zrestartuj usล‚ugฤ™ WiFi na rpi-kuchnia
Agent: [pushes command] โœ“ systemctl restart wpa_supplicant sent to rpi-kuchnia

Works with any LiteLLM-compatible provider: OpenAI, Anthropic, Ollama (local), Azure, Groq, and more.

๐Ÿ’พ USB Pendrive Offline Workflow

For air-gapped environments or devices without network access at first boot:

# On CLIENT โ€” seed USB with public key
meshpi pendrive seed

# On HOST โ€” encrypt config onto USB  
meshpi pendrive export

# On CLIENT โ€” apply and reboot
meshpi pendrive apply

๐Ÿ“Š Full Device Diagnostics

meshpi diag collects CPU load, memory, temperature, GPIO pin states, I2C device scan, SPI status, USB devices, WiFi signal, running services, failed systemd units, recent error logs, top processes, and power/voltage status. All metrics are also pushed to the host automatically by the daemon.

โš™๏ธ Systemd Integration

Both the host service and client daemon can be installed as systemd services with a single flag:

meshpi host --install        # installs meshpi-host.service
meshpi daemon --install      # installs meshpi-daemon.service

๐Ÿ“ฆ Installation

pip install meshpi                    # core
pip install "meshpi[llm]"             # + LiteLLM NLP agent

Python 3.9+ required. Works on any Linux system (host) and Raspberry Pi OS (client).


๐Ÿ›๏ธ Project Structure

meshpi/
โ”œโ”€โ”€ meshpi/
โ”‚   โ”œโ”€โ”€ cli.py          # Click CLI (config/host/scan/daemon/hw/agent/pendrive/info)
โ”‚   โ”œโ”€โ”€ config.py       # Interactive wizard โ†’ config.env
โ”‚   โ”œโ”€โ”€ crypto.py       # RSA-2048 + AES-256-GCM
โ”‚   โ”œโ”€โ”€ host.py         # FastAPI + WebSocket + mDNS + dashboard
โ”‚   โ”œโ”€โ”€ client.py       # mDNS scanner + WS daemon + config applier
โ”‚   โ”œโ”€โ”€ applier.py      # System configurator (user/WiFi/SSH/locale)
โ”‚   โ”œโ”€โ”€ diagnostics.py  # Full RPi system diagnostics collector
โ”‚   โ”œโ”€โ”€ registry.py     # Persistent device registry (JSON)
โ”‚   โ”œโ”€โ”€ llm_agent.py    # LiteLLM function-calling agent
โ”‚   โ”œโ”€โ”€ systemd.py      # Systemd service installer
โ”‚   โ”œโ”€โ”€ pendrive.py     # USB offline workflow
โ”‚   โ””โ”€โ”€ hardware/
โ”‚       โ”œโ”€โ”€ profiles.py # 49 hardware profiles
โ”‚       โ””โ”€โ”€ applier.py  # Profile applicator (apt/modprobe/config.txt)
โ”œโ”€โ”€ tests/
โ”‚   โ””โ”€โ”€ test_meshpi.py  # 59 tests (pytest) โ€” 100% passing
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ LICENSE             # Apache 2.0
โ””โ”€โ”€ README.md

๐Ÿงช Test Coverage

The v0.2.0 release ships with 59 automated tests covering:

  • Cryptographic primitives (RSA keygen, encrypt/decrypt roundtrip, cross-key isolation)
  • Config file parsing and .env writing
  • Device registry CRUD operations
  • All 49 hardware profile definitions and filters
  • System diagnostics collection
  • All REST API endpoints (TestClient, no real network needed)
  • CLI commands and option handling
pytest tests/ -v   # 59 passed in ~8s

๐Ÿณ Docker Support

MeshPi includes Docker support for testing and deployment:

# Build the image
docker build -t meshpi .

# Run host service
docker run -p 7422:7422 meshpi meshpi host --bind 0.0.0.0

# Or use docker-compose for full test environment
docker-compose up -d meshpi-host
docker-compose up meshpi-client  # runs scan in dry-run mode

๐Ÿ—บ๏ธ Roadmap

The following features are planned for upcoming releases:

  • v0.3 โ€” Web dashboard configuration editor (edit config.env from browser), device grouping and bulk commands
  • v0.4 โ€” Prometheus/Grafana metrics export, webhook notifications on device events
  • v0.5 โ€” OTA update management (apt upgrade via host), config versioning with rollback
  • v1.0 โ€” Stable REST API, PyPI publish, Docker host image

๐Ÿ”— Links

๐Ÿ“„ License

Apache License 2.0 - see LICENSE for details.

๐Ÿ‘ค Author

Created by Tom Sapletta - tom@sapletta.com

License

Apache License 2.0 - see LICENSE for details.

Author

Created by Tom Sapletta - tom@sapletta.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

meshpi-0.1.11.tar.gz (60.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

meshpi-0.1.11-py3-none-any.whl (56.4 kB view details)

Uploaded Python 3

File details

Details for the file meshpi-0.1.11.tar.gz.

File metadata

  • Download URL: meshpi-0.1.11.tar.gz
  • Upload date:
  • Size: 60.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for meshpi-0.1.11.tar.gz
Algorithm Hash digest
SHA256 36d80a8dd39083e6e8f09327b43733718acbe200c8d63967dc1f7b83200a0e2f
MD5 12ab0a42e08fdd52be954a0ecaf994ea
BLAKE2b-256 bc0bfaabe564632c6920458c3b0d6ed28a75fdad4a442231dee2bae067efe1ca

See more details on using hashes here.

File details

Details for the file meshpi-0.1.11-py3-none-any.whl.

File metadata

  • Download URL: meshpi-0.1.11-py3-none-any.whl
  • Upload date:
  • Size: 56.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for meshpi-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 76a7865b46830db617a52fdb4019981a18495e3b954dc6d5b9927e636de41fe3
MD5 b2a847f24dd44d9804ffaf9919cf9903
BLAKE2b-256 63513611772852bc632978d063927e08b5238d98290b483a019ed5b362c6e090

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page