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

๐Ÿ”ท MeshPi

Zero-Touch Raspberry Pi Fleet Management

Python PyPI Downloads CI Status Coverage License Code Style

๐Ÿš€ Configure WiFi, SSH, users, hardware peripherals, and manage devices through encrypted mesh networking

Install โ€ข Quick Start โ€ข Features โ€ข Docs โ€ข PyPI


๐Ÿ“‹ Overview

MeshPi eliminates the manual work of configuring Raspberry Pi devices from factory defaults. Whether deploying one device or an entire fleet, MeshPi handles:

  • ๐Ÿ“ถ WiFi credentials - No monitor/keyboard needed
  • ๐Ÿ” SSH keys - Secure remote access out of the box
  • ๐Ÿ‘ค User accounts - Create users, set passwords
  • ๐ŸŒ Locale & timezone - Regional settings applied automatically
  • ๐Ÿ”ง Hardware peripherals - 49+ profiles for displays, sensors, GPIO devices
  • ๐Ÿ“Š Real-time monitoring - CPU, memory, temperature, network status
  • ๐Ÿค– LLM-powered management - Natural language fleet commands

All secured with RSA-2048 + AES-256-GCM encryption. No credentials ever travel in plaintext.


โšก Quick Start

# Install
pip install meshpi

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

# On each CLIENT Raspberry Pi (fresh from factory)
meshpi scan      # Auto-discovers host, configures itself, reboots

๐ŸŽฏ Done! Your Raspberry Pi is now configured and ready.


๐Ÿ“ฑ Client Setup (Raspberry Pi)

๐Ÿ”ง Prerequisites Setup

Before running meshpi scan on your Raspberry Pi, follow these steps:

1. Connect to Internet

# Connect to WiFi using desktop interface or command line
sudo raspi-config
# Navigate to Network Options โ†’ Wi-Fi โ†’ Enter SSID and password

2. Update System

# Update package lists and upgrade system packages
sudo apt update && sudo apt upgrade -y

# Reboot after updates
sudo reboot

3. Install Python pip

# Install pip if not already installed
sudo apt install python3-pip python3-venv -y

# Verify installation
pip3 --version

4. Install MeshPi

# Install MeshPi package
pip3 install meshpi

# Or with LLM support for natural language commands
pip3 install "meshpi[llm]"

5. Run MeshPi Scan

# Discover and connect to MeshPi host
meshpi scan

๐Ÿš€ One-Liner Installation

For experienced users, here's the complete setup in one command:

sudo apt update && sudo apt upgrade -y && sudo apt install python3-pip -y && pip3 install meshpi && meshpi scan

๐Ÿ“‹ What Happens During Scan

When you run meshpi scan, the client will:

  1. ๐Ÿ” Discover Host - Uses mDNS to find MeshPi hosts on your network
  2. ๐Ÿ”‘ Key Exchange - Generates RSA key pair and exchanges with host
  3. ๐Ÿ” Download Config - Receives encrypted configuration
  4. โš™๏ธ Apply Settings - Configures WiFi, SSH, users, locale
  5. ๐Ÿ”„ Reboot - Restarts to apply all changes

๐Ÿ› ๏ธ Troubleshooting

No hosts found?

  • Ensure host machine is running meshpi host
  • Check both devices are on the same network
  • Verify firewall allows mDNS (port 5353)

Installation issues?

# Update pip to latest version
pip3 install --upgrade pip

# Install with specific version
pip3 install meshpi==0.1.14

โœจ Features

๐Ÿ” Encrypted Zero-Touch Provisioning

  • RSA-2048 key exchange + AES-256-GCM encryption
  • No shared secrets, no cleartext on the wire
  • mDNS discovery for automatic host detection

๐Ÿ“ก Real-Time Fleet Management

  • WebSocket-based persistent connections
  • Push config updates instantly
  • Execute shell commands remotely
  • Apply hardware profiles on-the-fly
  • Trigger reboots with delay

๐Ÿ”ง 49+ Hardware Profiles with Group Management

Category Examples
๐Ÿ–ฅ๏ธ Display OLED SSD1306, TFT ILI9341, e-Paper, HDMI 4K
๐ŸŽ›๏ธ GPIO Steppers (A4988), relays, servos (PCA9685), distance sensors
๐ŸŒก๏ธ Sensors BME280, DS18B20, MPU-6050, INA219
๐Ÿ“ท Camera RPi Camera v2/HQ, USB UVC, IR night vision
๐Ÿ”Š Audio HiFiBerry DAC+, I2S MEMS microphone
๐Ÿ“ก Networking CAN, RS-485, LoRa, nRF24L01
๐ŸŽฉ HATs Sense HAT, PiSugar UPS, RTC DS3231
# Quick interactive installation
meshpi hw quick-install --interactive

# Browse hardware catalog
meshpi hw catalog --category sensor --popular

# Apply to device groups
meshpi group create sensors
meshpi group add-device sensors pi@192.168.1.100
meshpi group hw-apply sensors sensor_bme280 sensor_ds18b20

# Remote management via SSH
meshpi ssh hw-apply --target pi@192.168.1.100 hat_sense
meshpi ssh hw-search oled --category display

New Features:

  • ๐ŸŽฏ Quick Install Wizard - Interactive hardware selection and installation
  • ๐Ÿ“‹ Hardware Catalog - Browse and filter 49+ profiles with tags
  • ๐Ÿ‘ฅ Device Groups - Batch operations on multiple devices
  • ๐Ÿ”— SSH Remote Management - Control hardware on remote devices
  • ๐ŸŽจ Custom Profiles - Create and share your own hardware configurations

๐Ÿค– LLM-Powered Agent

pip install "meshpi[llm]"

meshpi agent
> show me all online devices
> what's wrong with rpi-kitchen?
> enable OLED display on rpi-bedroom
> push new WiFi password to all devices

Works with OpenAI, Anthropic, Ollama (local), Azure, Groq, and more.

๐Ÿ“Š Full Diagnostics

meshpi diag

Collects CPU load, memory, temperature, GPIO states, I2C scan, USB devices, WiFi signal, services, logs, and more.

๐Ÿ’พ USB Offline Workflow

For air-gapped environments:

meshpi pendrive seed     # Client: write public key to USB
meshpi pendrive export   # Host: encrypt config to USB
meshpi pendrive apply    # Client: apply config from USB

๐Ÿ“ฆ Installation

# Core package
pip install meshpi

# With LLM agent support
pip install "meshpi[llm]"

# Development dependencies
pip install "meshpi[dev]"

# Everything
pip install "meshpi[all]"

Requirements: Python 3.9+, Linux (host), Raspberry Pi OS (client)


๐Ÿ—๏ธ Architecture

HOST (PC / RPi)                    CLIENT (fresh RPi)
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
meshpi config                      meshpi scan
  โ†’ ~/.meshpi/config.env             โ†’ mDNS discovery
meshpi host                          โ†’ RSA key exchange
  โ†’ FastAPI REST API             โ†   โ†’ Encrypted config
  โ†’ WebSocket /ws/{id}           โ†’   โ†’ Apply & reboot
  โ†’ mDNS advertisement
  โ†’ Dashboard /dashboard
                           โ†•
                    meshpi daemon
                      โ†’ Diagnostics push (60s)
                      โ†’ Real-time commands

๐Ÿ› ๏ธ CLI Reference

Command Description
meshpi config Interactive configuration wizard
meshpi host Start host service (FastAPI + mDNS)
meshpi scan Discover hosts, download config
meshpi daemon Persistent WebSocket connection
meshpi diag Show device diagnostics
meshpi hw list List hardware profiles
meshpi hw apply <id> Apply hardware profile
meshpi agent Launch LLM management agent
meshpi info Show local keys/config state
meshpi pendrive * USB offline workflow

๐Ÿ”ง Environment Variables

MeshPi supports extensive configuration through environment variables. Copy .env.example to .env and customize.

๐Ÿณ Docker & Deployment

# Host service
MESHPI_PORT=7422
MESHPI_BIND=0.0.0.0

# Client configuration
MESHPI_HOST_IP=localhost
MESHPI_HOST_PORT=7422
MESHPI_DEVICE_ID=meshpi-client

๐Ÿ”ง Configuration (MESHPI_CFG_*)

Environment variables with MESHPI_CFG_ prefix are automatically converted to config.env:

# WiFi
MESHPI_CFG_WIFI_SSID="MyNetwork"
MESHPI_CFG_WIFI_PASSWORD="MyPassword"
MESHPI_CFG_WIFI_COUNTRY="PL"

# SSH
MESHPI_CFG_RPI_USER="pi"
MESHPI_CFG_RPI_PASSWORD="raspberry"
MESHPI_CFG_SSH_ENABLE="yes"

# System
MESHPI_CFG_RPI_HOSTNAME="meshpi-node"
MESHPI_CFG_RPI_TIMEZONE="Europe/Warsaw"

๐Ÿค– LLM Agent

# LiteLLM configuration
LITELLM_MODEL=gpt-4o-mini
LITELLM_API_KEY=sk-...
LITELLM_API_BASE=https://api.openai.com/v1

# Alternative providers
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...

๐Ÿ“‹ Complete Reference

See .env.example for all available variables including:

  • Docker & Deployment: Port, binding, client settings
  • Configuration: SSH, WiFi, hostname, hardware interfaces
  • LLM Agent: Multiple provider support
  • Testing: Test devices, SSH keys, timeouts
  • Security: Key paths, crypto settings
  • Monitoring: Log levels, file paths

๐Ÿ“š Standard Documentation

For standardized documentation on device groups and hardware profiles, see:


๐Ÿ“ Repository Organization

meshpi/
โ”œโ”€โ”€ test/                    # Test scripts and utilities
โ”‚   โ”œโ”€โ”€ batch-rpi-test.sh    # Batch testing for multiple RPis
โ”‚   โ”œโ”€โ”€ test-doctor.sh       # Doctor functionality tests
โ”‚   โ”œโ”€โ”€ test-enhanced-cli.sh # CLI feature tests
โ”‚   โ”œโ”€โ”€ test-list.sh         # List functionality tests
โ”‚   โ”œโ”€โ”€ test-restart.sh      # Restart functionality tests
โ”‚   โ”œโ”€โ”€ test-ssh-host.sh     # SSH host tests
โ”‚   โ”œโ”€โ”€ test-ssh-scan-identify.sh # SSH scan tests
โ”‚   โ””โ”€โ”€ run-rpi-tests.sh     # Main Docker test runner
โ”œโ”€โ”€ scripts/                 # Tooling and utility scripts
โ”‚   โ”œโ”€โ”€ diagnose-rpi.sh      # Comprehensive RPi diagnostics
โ”‚   โ”œโ”€โ”€ fix-rpi-meshpi.sh    # Automated common issue fixes
โ”‚   โ”œโ”€โ”€ monitor-repair.py    # Real-time repair status monitor (Python)
โ”‚   โ”œโ”€โ”€ project.py           # Code analysis tool (Python)
โ”‚   โ”œโ”€โ”€ remote-rpi-test.sh   # Remote RPi testing via SSH
โ”‚   โ”œโ”€โ”€ rpi-service-manager.sh # Service management
โ”‚   โ””โ”€โ”€ show-repair-status.py # Visual repair status display (Python)
โ”œโ”€โ”€ meshpi/                  # Core Python package
โ”œโ”€โ”€ docker/                  # Docker configurations
โ”œโ”€โ”€ docs/                    # Documentation
โ””โ”€โ”€ tests/                   # Unit tests

๐Ÿงช Development

# Clone and setup
git clone https://github.com/pyfunc/meshpi.git
cd meshpi
make venv
make dev

# Run tests
make test

# Build package
make build

# Publish to PyPI
make publish

๐Ÿณ Docker

# Build image
docker build -t meshpi .

# Run host
docker run -p 7422:7422 meshpi

# Docker Compose
docker-compose up -d meshpi-host

๐Ÿ“„ License

Apache License 2.0 - see LICENSE for details.


๐Ÿ‘ค Author

Tom Sapletta
๐Ÿ“ง tom@sapletta.com
๐Ÿข Softreck - Embedded systems, IoT automation


๐Ÿ”— Links


โฌ† Back to Top

Made with โค๏ธ for the Raspberry Pi community

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.29.tar.gz (119.4 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.29-py3-none-any.whl (115.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: meshpi-0.1.29.tar.gz
  • Upload date:
  • Size: 119.4 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.29.tar.gz
Algorithm Hash digest
SHA256 b7a03117df9e28705f4a0d009496ca27d5e9eb83a7e30d1186bc4ed7df6222af
MD5 448c191a233b0feff5bfbd889e8c838c
BLAKE2b-256 caa4f72b1d42f4a5f36f59ca487a0b1b6d45b873e3f45f70d044b321e74f0dce

See more details on using hashes here.

File details

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

File metadata

  • Download URL: meshpi-0.1.29-py3-none-any.whl
  • Upload date:
  • Size: 115.8 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.29-py3-none-any.whl
Algorithm Hash digest
SHA256 a96152c3b9faafad0da8a70816a93a655077e63e29e615a020c11ca805b16000
MD5 a2ac6fb6925bc27dd19e2de57fb4b019
BLAKE2b-256 fd73124ac077847a6ac719bfe9bfcc949f99249050425f329982273508f94489

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