Skip to the content
2 layers232 × 110 mmRelay8, the printed circuit board in 3D

Three KiCad 10 PCBs designed entirely as Python code with layered verification

Size
232 × 110 mm
Copper layers
2
Thickness
1.6 mm
Parts
65
Nets
65
Pads
254
Tracks, vias
532, 57
Pours
12
Routed
Yes
KiCad
KiCad 10.0 (file 20260206)
Created
9 Oct 2026
Updated
5 Nov 2026

Overview

Relay8 is an open-source printed circuit board by YORROY123, from the YORROY123/kicad-scripted-pcb repository on GitHub, published under the MIT licence. It is a 2-layer board of 232 × 110 mm with 65 parts on 65 nets, routed with 532 tracks and 57 vias.

It is built around the ESP32-C3-WROOM-02-N4, HLK-10M05 and LP38693MP-3.3, with the ULN2803A, SRD-05VDC-SL-C and SS34 among its other parts. Its parts include 16 resistors, 12 diodes, 11 connectors, 10 switches and 8 capacitors. It belongs with the ESP32 and RISC-V boards of this library.

Main components

9

README

README.md

kicad-scripted-pcb

繁體中文

Three KiCad 10 boards designed entirely as code: Python scripts produce the schematic, the PCB placement, the routing (via freerouting) and the copper pours, and each board rebuilds from scratch with one command. The KiCad GUI is never opened.

The point is verification. Every build runs several independent checks, because each one is blind to errors the others catch. Some of those errors turned up while these boards were being built and are listed below.

BoardResult
usbc-ldousbc-ldo: USB-C 5 V → 3.3 V LDO → LED. 40 × 24 mm, 2 layers. Includes an ngspice power-path simulation.ERC 0, DRC 0, schematic parity
esp32c3esp32c3: ESP32-C3 minimal board with native USB, LP38693 LDO, RESET/BOOT, LEDs and an 8-pin header. 32 × 49 mm.ERC 0, DRC 0, schematic parity, pin-by-pin netlist check
relay8relay8: ESP32-C3 + ULN2803 driving 8 mains relays from one mains cable: on-board HLK-10M05 AC-DC (100–240 VAC), T8A fuse, varistor, L/N bus traces, per-channel NO · N · NC terminals, isolation slots and custom mains clearance rules. 232 × 110 mm. Not safety-certified.ERC 0, DRC errors 0 (40 silkscreen-clipped-by-slot/edge warnings listed), schematic parity

Each ESP32 board has a FIRMWARE.md with the pin map, flashing steps, a first program, and, for relay8, the mains wiring.

Pipeline

text
gen/board.py ──► .kicad_sch ──► ERC ──► netlist ──► netlist check (vs expected_nets.json)
                                                     │
                                                     ▼
                                     design review (lib/review.py, datasheet rules)
                                                     │
gen/pcb.py ◄─────────────────────────────────────────┘   place footprints, board outline,
   │                                                     net classes, placement self-check
   ▼
.kicad_pcb ──► Specctra DSN ──► freerouting ──► SES ──► import + GND pour ──► DRC (+ schematic parity)
                                                                                   │
                     lcsc.json ──► lib/lcsc.py (online, run by hand) ──► lcsc-check.json
                                                                                   │
                                                       lib/fab.py ◄────────────────┘
                                     Gerber + drill zip, JLCPCB BOM / CPL, hand-solder list

Every step stops the build on failure; nothing is passed downstream with a known error.

kicad-cli has no "update PCB from schematic" command, so lib/pcbgen.py builds the board from the exported netlist with pcbnew.

What each check catches, and what it missed

CheckCatchesMissed here (caught by something else)
schgen.crossing_pins() / overlapping_wires()a wire running across a pin (silent short), two nets merged by overlapping wires—
KiCad ERCunconnected pins, undriven powerLED wired backwards (two passive pins, ERC is fine with it). Found by reading the netlist while building the PCB.
check_netlist.py vs expected_nets.jsonwrong pin→net, single-pin netsERC ignores "global label appears only once" by default, so a label typo creates an isolated net with no ERC error. Proven with a deliberate typo (mutation test).
placement self-checkpad nets vs netlist, footprints off-board, courtyard overlapUses real courtyard polygons. The ESP32 module's courtyard is T-shaped, and bounding boxes reject legal positions.
DRC + --schematic-parityclearance, track width, edge clearance, schematic vs PCB—
custom DRC rules (relay8.kicad_dru)mains ↔ low voltage ≥ 3.0 mm, mains ↔ mains ≥ 2.4 mmCreepage around the slots is not checked by DRC. Needs a human.
ngspice simulation (usbc-ldo/sim)design marginsThe first board's 1.1 V-dropout LDO falls out of regulation at USB's 4.40 V minimum, and its input capacitance injects ~124 µC on hot-plug (USB 2.0 limit: 50 µC). All three boards now use LP38693 (12 V input rating): esp32c3/sim showed that with only 1 µF on VBUS, hot-plug cable ringing reaches 7.7–8.6 V, above the 6.5 V rating of the AP2112K the ESP32 boards first used.
lib/review.py design review (datasheet rules on the netlist)wrong intent: diode/TVS polarity, LED current from the real Vf range, decoupling and rail ranges per datasheet, USB-C CC pull-downs, ESP32-C3 EN RC / strapping pins / GPIO18-19, relay flyback path and pickup voltage, capacitor voltage and polarity, per-supply current budget, LDO junction temperature, USB VBUS capacitanceusbc-ldo's SMAJ5.0A TVS was wired backwards: anode on +5 V, cathode on GND, a short the moment USB is plugged in. KiCad's symbol names the cathode pin "A1". ERC, DRC, the netlist check and the SPICE model (which had it the right way round) all passed. It also found a blue LED on a 3.3 V GPIO (Vf up to 3.6 V) and green power LEDs at ~0.45 mA. lib/review_test.py breaks the real netlists 20 ways and expects each rule to fire.
lib/lcsc.py + lib/fab.pyLCSC part number vs model, stock, package size, R/C value, LED colour; symbol default footprint vs assigned footprint; drill count; BOM/CPL/board refdesAll three boards used the USBLC6-2P6 symbol (SOT-666) on a SOT-23-6 footprint: same pinout, so nothing else noticed, but a BOM by value buys parts that do not fit. The SMAJ5.0A part number first chosen had zero stock.

Things that cost time (so they don't cost yours)

  • freerouting-cli 2.5.0 crashes on KiCad 10 DSN files (freerouting#957). Use the jar, which needs Java 25.
  • freerouting's automatic neck-down narrows tracks to 0.125 mm beside 0402 pads, below JLCPCB's 0.127 mm minimum. Use --router.automatic_neckdown=false --router.neck_width_um=150.
  • The DSN carries no copper-to-edge rule. Pass --router.copper_to_edge_clearance_um. That setting does not cover internal slots, so put keepouts around slots.
  • Net classes live in .kicad_pro, not .kicad_pcb. Save with pcbnew.SaveBoard(), which writes both.
  • board.Remove(zone) from Python can raise 'SwigPyObject' has no attribute 'thisown' or crash pcbnew (0xC0000005). Use board.Delete().
  • freerouting reports pin-to-pin "violations" inside fine-pitch footprints where KiCad's DRC is clean. The cause is KiCad's DSN exporter inflating every edge of a rounded-rect pad (specctra_export.cpp) by the arc-approximation margin.
  • Windows PowerShell 5.1 reads BOM-less UTF-8 scripts as ANSI. The build scripts here are ASCII-only for that reason.

Requirements

  • Windows (the build scripts are PowerShell; the Python parts are cross-platform)
  • KiCad 10 (uses its bundled Python for pcbnew, and its ngspice). Set KICAD_BIN / KICAD_SHARE if it is not in the default location.
  • Python 3.10+ on PATH for schematic generation and the design review (standard library only). The simulations and the field solver need numpy, scipy and matplotlib.
  • Network access only for lib/lcsc.py (JLCPCB parts API). The build itself runs offline.
  • freerouting 2.5.0 jar + a Java 25 runtime. Run tools\setup-tools.ps1 once; it downloads both into tools\ with pinned SHA-256 checks.

Quick start

powershell
powershell -ExecutionPolicy Bypass -File tools\setup-tools.ps1
powershell -ExecutionPolicy Bypass -File boards\esp32c3\build.ps1
python lib\review_test.py          # design-review mutation tests; needs the boards built once

The build ends with boards/<b>/fab/:

FileUse
<b>-gerber.zipupload to JLCPCB as the PCB
<b>-bom.csv, <b>-cpl.csvupload for SMT assembly (parts LCSC can supply)
hand-solder.csvparts LCSC cannot supply (relay8: mains terminals, fuse holders)
rotation-review.csvevery part's CPL rotation and where it came from. None is hardware-verified: compare each part in JLCPCB's placement preview

Also written to boards/<b>/: review.txt (design review, including the inferred net voltages) and lcsc-check.json (part numbers as checked against JLCPCB, with stock and attributes).

Layout

text
lib/schgen.py, ksym.py, netlabel.py   schematic writer (symbols flattened from the KiCad library)
lib/check_netlist.py                  netlist vs expected_nets.json
lib/review.py, review_test.py         design review rules + mutation tests
lib/pcbgen.py, route.py               PCB builder (BoardSpec), freerouting round trip, GND pour
lib/lcsc.py, fab.py, jlc_rotations.json   part-number check, fabrication outputs
lib/field2d.py, field2d_check.py      2-D field solver for trace impedance + validation
boards/<b>/gen/board.py   the circuit (pin -> net table)
boards/<b>/gen/pcb.py     placement (BoardSpec)
boards/<b>/lcsc.json      hand-written LCSC part numbers ("value|footprint" -> part)
boards/<b>/review-waivers.json   accepted review findings, each with a reason
boards/<b>/build.ps1      one-command build
boards/<b>/sim/           ngspice and field-solver studies
tools/      setup-tools.ps1 (downloads are git-ignored)

Want to add a board or a review rule? See CONTRIBUTING.md.

Code comments are in Chinese. The boards were built while comparing AI-assisted workflows in KiCad and EasyEDA Pro.

Limits

These are two-layer boards with modules and simple power. There is no controlled-impedance routing, no length matching, no BGA and no SI/PI analysis; freerouting does none of these (lib/field2d.py can tell you whether a trace needs it). The fabrication files are complete enough to order, but nobody has built these boards yet: CPL rotations are unverified and the design review is a set of rules, not an engineer. Have a person review before ordering. This applies above all to relay8, which switches mains voltage.

License

MIT. freerouting (GPL-3.0) and the Temurin JRE (GPL-2.0 with Classpath Exception) are downloaded at setup time and are not part of this repository.

Parts

65
QtyValueFootprintReferences
81kResistor_SMD:R_0402_1005MetricR11, R12, R13, R14, R15, R16, R17, R18
8REDLED_SMD:LED_0805_2012MetricD11, D12, D13, D14, D15, D16, D17, D18
8SRD-05VDC-SL-CRelay_THT:Relay_SPDT_SANYOU_SRD_Series_Form_CK1, K2, K3, K4, K5, K6, K7, K8
410kResistor_SMD:R_0402_1005MetricR3, R4, R5, R6
31uFCapacitor_SMD:C_0402_1005MetricC1, C4, C8
2100nFCapacitor_SMD:C_0402_1005MetricC3, C6
25.1kResistor_SMD:R_0402_1005MetricR1, R2
2SS34Diode_SMD:D_SMAD4, D5
1100kResistor_SMD:R_0402_1005MetricR9
1100uFCapacitor_SMD:CP_Elec_6.3x7.7C5
110nFCapacitor_SMD:C_0402_1005MetricC7
110uFCapacitor_SMD:C_0805_2012MetricC2
114D431KVaristor:RV_Disc_D15.5mm_W4.4mm_P7.5mmRV1
1220Resistor_SMD:R_0402_1005MetricR8
1AO3401APackage_TO_SOT_SMD:SOT-23Q1
1BOOTButton_Switch_SMD:SW_Push_1P1T_NO_CK_KMR2SW2
1CH1TerminalBlock_MetzConnect:TerminalBlock_MetzConnect_Type171_RT13703HBWC_1x03_P7.50mm_HorizontalJ11
1CH2TerminalBlock_MetzConnect:TerminalBlock_MetzConnect_Type171_RT13703HBWC_1x03_P7.50mm_HorizontalJ12
1CH3TerminalBlock_MetzConnect:TerminalBlock_MetzConnect_Type171_RT13703HBWC_1x03_P7.50mm_HorizontalJ13
1CH4TerminalBlock_MetzConnect:TerminalBlock_MetzConnect_Type171_RT13703HBWC_1x03_P7.50mm_HorizontalJ14
1CH5TerminalBlock_MetzConnect:TerminalBlock_MetzConnect_Type171_RT13703HBWC_1x03_P7.50mm_HorizontalJ15
1CH6TerminalBlock_MetzConnect:TerminalBlock_MetzConnect_Type171_RT13703HBWC_1x03_P7.50mm_HorizontalJ16
1CH7TerminalBlock_MetzConnect:TerminalBlock_MetzConnect_Type171_RT13703HBWC_1x03_P7.50mm_HorizontalJ17
1CH8TerminalBlock_MetzConnect:TerminalBlock_MetzConnect_Type171_RT13703HBWC_1x03_P7.50mm_HorizontalJ18
1ESP32-C3-WROOM-02-N4RF_Module:ESP32-C3-WROOM-02U1
1GREENLED_SMD:LED_0805_2012MetricD3
1HLK-10M05Converter_ACDC:Converter_ACDC_Hi-Link_HLK-10MxxPS1
1LP38693MP-3.3Package_TO_SOT_SMD:SOT-223-5U2
1MAINS INTerminalBlock_MetzConnect:TerminalBlock_MetzConnect_Type171_RT13702HBWC_1x02_P7.50mm_HorizontalJ20
1RESETButton_Switch_SMD:SW_Push_1P1T_NO_CK_KMR2SW1
1T1A 250VFuse:Fuseholder_TR5_Littelfuse_No560_No460F2
1T8A 250VFuse:Fuseholder_Clip-5x20mm_Keystone_3517_Inline_P23.11x6.76mm_D1.70mm_HorizontalF1
1UARTConnector_PinHeader_2.54mm:PinHeader_1x04_P2.54mm_VerticalJ2
1ULN2803APackage_SO:SOIC-18W_7.5x11.6mm_P1.27mmU3
1USB-CConnector_USB:USB_C_Receptacle_HRO_TYPE-C-31-M-12J1
1USBLC6-2SC6Package_TO_SOT_SMD:SOT-23-6D1

More from YORROY123/kicad-scripted-pcb

3
  • 4 layers170 × 120 mmCm5, the printed circuit board in 3D

    Cm5

    YORROY123/kicad-scripted-pcb

    Three KiCad 10 PCBs designed entirely as Python code with layered verification

    243 parts1MIT
  • 2 layers32 × 49 mmEsp32c3, the printed circuit board in 3D

    Esp32c3

    YORROY123/kicad-scripted-pcb

    Three KiCad 10 PCBs designed entirely as Python code with layered verification

    26 parts1MIT
  • 2 layers40 × 24 mmUsbc ldo, the printed circuit board in 3D

    Usbc ldo

    YORROY123/kicad-scripted-pcb

    Three KiCad 10 PCBs designed entirely as Python code with layered verification

    16 parts1MIT

Similar boards

  • 2 layers133 × 106 mm8-channel relay, the printed circuit board in 3D

    8-channel relay

    akashh218/ESP32-8-Channel-Smart-Switch-PCB

    ESP32-based 8-channel smart switch PCB for wireless control of multiple electrical loads, featuring relay interfaces and a compact PCB design.

    86 parts
  • 2 layers115 × 75 mmSecador toalha, the printed circuit board in 3D

    Secador toalha

    forg3/secadora-de-toalha

    Secador de toalhas inteligente em alumínio (390W/127V~): PCB dedicada KiCad 10, ESP32-C3, controle térmico isolado e modo eco.

    25 parts
  • 2 layers200 × 150 mmSony-5.1-revival, the printed circuit board in 3D

    Sony-5.1-revival

    stsukesh/sony-mhc-gn1300d-5.1-revival

    Complete DIY/OEM revival of Sony MHC-GN1300D 5.1 audio system: custom KiCad 10 PCB (Lion Circuits), 3x TPA3116D2, analog crossover, and ESP32 IoT control hub.

    71 partsMIT
  • 6 layers75 × 78.4 mmPoe backplate, the printed circuit board in 3D

    Poe backplate

    dotstartech/wall-panel

    Wall mounted 4 inch touch display panel with CM4 inside

    125 parts445
  • 4 layers112 × 57 mmUniversalboxArm1-0, the printed circuit board in 3D

    UniversalboxArm1-0

    Solartraveler/UniversalboxArm

    PCB for experimenting with a STM32

    170 parts2
  • 4 layers100 × 81.5 mmTubes Mk. PCB, the printed circuit board in 3D

    Tubes Mk. PCB

    wangga03/Tugas-Akhir

    Sistem monitoring dan analisis data untuk wahana submersible berbasis Teensy 4.1. Proyek ini mencakup kontrol real-time via Ethernet/USB dan alat analisis data hasil pengujian (Data Playback).

    80 parts

Questions

How big is the Relay8 PCB?

It measures 232 × 110 mm and has 2 copper layers, 1.6 mm thick.

What parts does the Relay8 use?

65 parts, built around the ESP32-C3-WROOM-02-N4, HLK-10M05, LP38693MP-3.3 and ULN2803A. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.

Where can I download the Relay8 KiCad files?

From the YORROY123/kicad-scripted-pcb repository on GitHub, at the commit this page was made from: the board is boards/relay8/relay8.kicad_pcb and its schematic boards/cm5/cm5.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the Relay8 design in my own project?

Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).