Skip to main content

Programmatically generate Raspberry Pi GPIO connection diagrams

Project description

PinViz

PinViz Logo

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

Programmatically generate beautiful GPIO connection diagrams for Raspberry Pi and ESP32/ESP8266 boards in SVG format.

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

Example Diagram

BH1750 Light Sensor Wiring Diagram

→ See more examples

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, ESP32, ESP8266) and common devices
  • 🐍 Python API: Create diagrams programmatically with Python code
  • 🤖 MCP Server: Generate diagrams from natural language with AI assistants
  • 🌙 Dark Mode: Built-in light and dark themes for better visibility
  • 📦 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

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
ESP32 DevKit V1 esp32_devkit_v1, esp32, esp32_devkit 30-pin (dual-sided) ESP32 development board with WiFi/Bluetooth
ESP8266 NodeMCU esp8266_nodemcu, esp8266, nodemcu 30-pin (dual-sided) ESP8266 WiFi development board
Wemos D1 Mini wemos_d1_mini, d1mini, wemos 16-pin (dual-sided) Compact ESP8266 development board

All boards include full pin definitions with GPIO numbers, I2C, SPI, UART, and PWM support.

Installation

Homebrew (macOS)

brew tap nordstad/pinviz
brew install pinviz

pip / uv (cross-platform)

uv tool install pinviz
pip install pinviz

Or as a project dependency:

uv add pinviz

Quick Start

PinViz Quick Demo

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"
    color: "turquoise"  # Named color support (or use hex: "#50E3C2")

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.

→ 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/adding-devices.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.17.2.tar.gz (451.3 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.17.2-py3-none-any.whl (494.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pinviz-0.17.2.tar.gz
  • Upload date:
  • Size: 451.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","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.17.2.tar.gz
Algorithm Hash digest
SHA256 a8383f75d0ae879d26e0db78b4b4e423b82e2d173801e04e729a3d117775980e
MD5 b3f4581ba305134c4ba375298789d740
BLAKE2b-256 ebfced709fc4521d42d2b9fc9947742be9717f5a5da6e5314bb7b90d1685c471

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pinviz-0.17.2-py3-none-any.whl
  • Upload date:
  • Size: 494.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","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.17.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a5e38da67a23477f0ac285e4bc6917f7dc1ded0502ebb84e12c84d29d0d5c665
MD5 39c14ba88e16248f9fbc463fa25110ba
BLAKE2b-256 98380eb55e2e81ea7dc8b7b6245580fb6b8ed4deda0e23b36ccbeb62a9ac951d

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