Skip to main content

Programmatically generate Raspberry Pi GPIO connection diagrams

Project description

PinViz

PinViz Logo

CI Documentation License: MIT Python 3.12+ PyPI version PyPI Downloads

Programmatically generate beautiful Raspberry Pi GPIO connection diagrams in SVG format.

PinViz makes it easy to create clear, professional wiring diagrams for your Raspberry Pi projects. Define your connections using simple YAML/JSON files or Python code, and automatically generate publication-ready SVG diagrams.

PinViz Quick Demo

Example Diagram

BH1750 Light Sensor Wiring Diagram

Features

  • 📝 Declarative Configuration: Define diagrams using YAML or JSON files
  • 🎨 Automatic Wire Routing: Smart wire routing with configurable styles (orthogonal, curved, mixed)
  • 🎯 Color-Coded Wires: Automatic color assignment based on pin function (I2C, SPI, power, ground, etc.)
  • Inline Components: Add resistors, capacitors, and diodes directly on wires
  • 🔌 Built-in Templates: Pre-configured boards (Raspberry Pi 4, 5 & Pico) and common devices
  • 🐍 Python API: Create diagrams programmatically with Python code
  • 🤖 MCP Server: Generate diagrams from natural language with AI assistants
  • 📦 SVG Output: Scalable, high-quality vector graphics
  • Modern CLI: Rich terminal output with progress indicators and colored messages
  • 🔧 JSON Output: Machine-readable output for CI/CD integration
  • ⚙️ Configuration Management: TOML config file support with precedence rules
  • 🚀 Shell Completion: Auto-complete for bash, zsh, and fish shells

Installation

Install as a standalone tool with global CLI access:

uv tool install pinviz

Or as a project dependency:

# Using uv
uv add pinviz

# Using pip
pip install pinviz

Quick Start

Try a Built-in Example

# Generate a BH1750 light sensor wiring diagram
pinviz example bh1750 -o bh1750.svg

# See all available examples
pinviz list

Create Your Own Diagram

Create a YAML configuration file (my-diagram.yaml):

title: "BH1750 Light Sensor Wiring"
board: "raspberry_pi_5"

devices:
  - type: "bh1750"
    name: "BH1750"

connections:
  - board_pin: 1     # 3V3
    device: "BH1750"
    device_pin: "VCC"

  - board_pin: 6     # GND
    device: "BH1750"
    device_pin: "GND"

  - board_pin: 5     # GPIO3 (I2C SCL)
    device: "BH1750"
    device_pin: "SCL"

  - board_pin: 3     # GPIO2 (I2C SDA)
    device: "BH1750"
    device_pin: "SDA"

Generate your diagram:

pinviz render my-diagram.yaml -o output.svg

Python API

from pinviz import boards, devices, Connection, Diagram, SVGRenderer

board = boards.raspberry_pi_5()
sensor = devices.bh1750_light_sensor()

connections = [
    Connection(1, "BH1750", "VCC"),  # 3V3 to VCC
    Connection(6, "BH1750", "GND"),  # GND to GND
    Connection(5, "BH1750", "SCL"),  # GPIO3/SCL to SCL
    Connection(3, "BH1750", "SDA"),  # GPIO2/SDA to SDA
]

diagram = Diagram(
    title="BH1750 Light Sensor",
    board=board,
    devices=[sensor],
    connections=connections
)

renderer = SVGRenderer()
renderer.render(diagram, "output.svg")

CLI Commands

PinViz provides a modern CLI with rich terminal output and machine-readable JSON support.

Rendering Diagrams

# Generate diagram from YAML config
pinviz render examples/bh1750.yaml -o output.svg

# With JSON output for CI/CD
pinviz render examples/bh1750.yaml --json
# Output: {"status": "success", "output_path": "output.svg", "validation": {...}}

Validation

# Validate diagram configuration
pinviz validate examples/bh1750.yaml

# Strict mode (warnings as errors)
pinviz validate examples/bh1750.yaml --strict

# Machine-readable output
pinviz validate examples/bh1750.yaml --json

List Templates

# List all boards, devices, and examples
pinviz list

# JSON output for programmatic use
pinviz list --json

Configuration Management

# Create config file (~/.config/pinviz/config.toml)
pinviz config init

# View current configuration
pinviz config show

# Edit config file
pinviz config edit

Shell Completion

# Install shell completion (bash, zsh, fish)
pinviz completion install

# Show completion script
pinviz completion show

Global Options

All commands support these global options:

--log-level [DEBUG|INFO|WARNING|ERROR]  # Set logging verbosity
--log-format [console|json]            # Log output format
--version                              # Show version
--help                                 # Show help

MCP Server (AI-Powered)

PinViz includes an MCP (Model Context Protocol) server that enables natural language diagram generation through AI assistants like Claude Desktop. Generate diagrams with prompts like "Connect a BME280 temperature sensor to my Raspberry Pi 5" with intelligent pin assignment, automatic I2C bus sharing, and conflict detection.

→ Full MCP documentation

Documentation

Full documentation: nordstad.github.io/PinViz

Contributing

Contributions are welcome! Please see our Contributing Guide for details.

Adding new devices: See guides/DEVICE_CONFIG_GUIDE.md for device configuration details.

License

MIT License - See LICENSE file for details

Credits

Board and GPIO pin SVG assets courtesy of Wikimedia Commons

Author

Even Nordstad

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

pinviz-0.9.2.tar.gz (378.1 kB view details)

Uploaded Source

Built Distribution

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

pinviz-0.9.2-py3-none-any.whl (403.8 kB view details)

Uploaded Python 3

File details

Details for the file pinviz-0.9.2.tar.gz.

File metadata

  • Download URL: pinviz-0.9.2.tar.gz
  • Upload date:
  • Size: 378.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pinviz-0.9.2.tar.gz
Algorithm Hash digest
SHA256 09bbf0314e569f95d14ac42e47d8de76d6d2c29a787b3127a7de4ace2b67ad7e
MD5 d459d76b16e6ee3907ec16a643cb7e76
BLAKE2b-256 a2532d9c4f09a39702b62846d49cf393c8b26243d3aa3624a81937ac3982a2de

See more details on using hashes here.

File details

Details for the file pinviz-0.9.2-py3-none-any.whl.

File metadata

  • Download URL: pinviz-0.9.2-py3-none-any.whl
  • Upload date:
  • Size: 403.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for pinviz-0.9.2-py3-none-any.whl
Algorithm Hash digest
SHA256 801eaf59f28bec4e9be8f9d57d941c7844de1758915b9ca43b9eda8a6a9077a7
MD5 aec3146153f8ab6cf6400bd72cfff793
BLAKE2b-256 d6529d6b2c300b5dc8560f5228a8bb177e75a150bd50f116349981991d7b0588

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