Programmatically generate Raspberry Pi GPIO connection diagrams
Project description
PinViz
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.
Example 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
Multi-Level Device Support ✨
New in v0.11.0: PinViz now supports device-to-device connections, enabling complex multi-level wiring diagrams!
What's New
- Connect devices to other devices (not just to the board)
- Automatic horizontal tier layout based on connection depth
- Supports power distribution chains, sensor chains, motor controllers, and more
- Backward compatible with existing configurations
Example: Power Distribution Chain
connections:
# Board to regulator
- from: {board_pin: 2}
to: {device: "Regulator", device_pin: "VIN"}
# Regulator to LED (device-to-device!)
- from: {device: "Regulator", device_pin: "VOUT"}
to: {device: "LED", device_pin: "VCC"}
See examples/multi_level_simple.yaml for a complete example.
Supported Boards
| Board | Aliases | GPIO Pins | Description |
|---|---|---|---|
| Raspberry Pi 5 | raspberry_pi_5, rpi5, rpi |
40-pin | Latest Raspberry Pi with improved GPIO capabilities |
| Raspberry Pi 4 | raspberry_pi_4, rpi4 |
40-pin | Popular Raspberry Pi model with full GPIO header |
| Raspberry Pi Pico | raspberry_pi_pico, pico |
40-pin (dual-sided) | RP2040-based microcontroller board |
All boards include full pin definitions with GPIO numbers, I2C, SPI, UART, and PWM support.
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 Examples
PinViz provides a modern CLI
Rendering Diagrams
# Generate diagram from YAML config
pinviz render examples/bh1750.yaml -o output.svg
Validation
# Validate diagram configuration
pinviz validate examples/bh1750.yaml
List Templates
# List all boards, devices, and examples
pinviz list
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.
Documentation
Full documentation: nordstad.github.io/PinViz
- Installation Guide - Detailed installation instructions
- Quick Start Tutorial - Step-by-step getting started guide
- CLI Usage - Command-line interface reference
- YAML Configuration - Complete YAML configuration guide
- Python API - Programmatic API reference
- Examples Gallery - More example diagrams and configurations
- API Reference - Complete API documentation
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
- GitHub: @nordstad
- Project: PinViz
- Documentation: nordstad.github.io/PinViz
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pinviz-0.11.0.tar.gz.
File metadata
- Download URL: pinviz-0.11.0.tar.gz
- Upload date:
- Size: 393.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bc376b7c33313ccc1276af968132a6256bbc67af66835ddd785b8ba739b5f1a1
|
|
| MD5 |
07e6fa090042b48b8da1a3f0fb4a9bef
|
|
| BLAKE2b-256 |
420a2e54ef09dad9ac77dd38a91bed5072c31caee84795e7b9777802efdd6e24
|
File details
Details for the file pinviz-0.11.0-py3-none-any.whl.
File metadata
- Download URL: pinviz-0.11.0-py3-none-any.whl
- Upload date:
- Size: 418.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d9cf95ab24b35d38d24a66bf7168f084dcf9ace85a1506dbb2605205517b09ed
|
|
| MD5 |
d77eccb2fd02eb0ff2c0aa9cdd73856d
|
|
| BLAKE2b-256 |
2bd4b6bfe8361b8c54ccf21c4d1cc202d1345de3de4db1d096f03f981e50288a
|