Skip to content

Instantly share code, notes, and snippets.

@nikhilrayaprolu
Created May 31, 2026 08:45
Show Gist options
  • Select an option

  • Save nikhilrayaprolu/7fca898b0ce62d090db520d660d4f91e to your computer and use it in GitHub Desktop.

Select an option

Save nikhilrayaprolu/7fca898b0ce62d090db520d660d4f91e to your computer and use it in GitHub Desktop.
PCB-Designing-Guide

A Comprehensive Guide to PCB Design for Software Developers

From Code to Copper: Bridging the Software-Hardware Gap


Table of Contents

  1. Why Software Developers Should Learn PCB Design
  2. Foundational Electronics Concepts
  3. Understanding PCB Fundamentals
  4. The PCB Design Workflow (The "Agile Sprint" of Hardware)
  5. Schematic Design Deep Dive
  6. Component Selection and Management
  7. PCB Layout: From Schematic to Board
  8. Design Rules and Constraints
  9. Signal Integrity and Power Integrity
  10. Manufacturing and Assembly
  11. Testing and Debugging PCBs
  12. Tools of the Trade
  13. Version Control and Collaboration for PCB
  14. Common Mistakes and How to Avoid Them
  15. Real-World Project Walkthrough
  16. Resources and Next Steps

Chapter 1: Why Software Developers Should Learn PCB Design

The Convergence of Hardware and Software

The boundary between hardware and software is dissolving. Consider the landscape:

  • IoT devices require custom PCBs with firmware you'll write
  • Wearables demand tiny, optimized boards running your code
  • Prototyping at startups often means "you design the board AND write the firmware"
  • Embedded roles increasingly expect full-stack hardware-software competence
  • Hobbyist platforms (Arduino, Raspberry Pi) are gateways to custom PCB design

The Software Developer's Advantage

You already possess skills that translate directly:

Software Skill PCB Design Equivalent
Modular code architecture Hierarchical schematic design
Version control (Git) PCB version management
Debugging Board bring-up and testing
Design patterns Proven circuit topologies
Refactoring Board revision cycles
Dependency management Component library management
CI/CD pipelines Design rule checking (DRC/ERC)
Type systems Net classes and constraint rules

What You'll Be Able to Do After This Guide

  • Read and create schematics fluently
  • Design a 2-layer or 4-layer PCB from scratch
  • Select appropriate components
  • Route traces with confidence
  • Send a board to a manufacturer
  • Debug and iterate on your designs
  • Communicate effectively with hardware engineers

Chapter 2: Foundational Electronics Concepts

2.1 Voltage, Current, and Resistance — The Holy Trinity

Think of electricity like water in a pipe system:

Voltage (V)    = Water Pressure    (the "push")
Current (I)    = Water Flow Rate   (the "movement")  
Resistance (R) = Pipe Narrowness   (the "opposition")

Ohm's Law — the if/else of electronics:

V = I × R
I = V / R
R = V / I

Example:

  • A 5V supply pushing through a 1kΩ resistor:
  • Current = 5V / 1000Ω = 5mA (0.005 Amps)

2.2 Power

P = V × I  (in Watts)

Power is what heats things up. Every component has a power rating. Exceed it, and you get smoke — the hardware equivalent of a runtime exception, except there's no undo.

Also:
P = I² × R    (useful when you know current and resistance)
P = V² / R    (useful when you know voltage and resistance)

2.3 AC vs. DC

  • DC (Direct Current): Constant voltage. Like a constant value in code. Batteries, USB power, microcontrollers all use DC.
  • AC (Alternating Current): Oscillating voltage. Like a sine wave function. Wall outlets are AC. Most PCB design for digital electronics is DC-focused, but AC concepts become critical for high-speed signals.

2.4 Digital Signals

In software, you deal with booleans. In hardware, those booleans are voltage levels:

Logic HIGH (1):  Typically 3.3V or 5V (depends on the logic family)
Logic LOW  (0):  Typically 0V (ground)

Key digital concepts:

┌──────────────────────────────────────────────┐
│  Signal Name    │  Software Equivalent       │
├─────────────────┼────────────────────────────┤
│  GPIO           │  boolean variable          │
│  PWM            │  duty cycle function       │
│  SPI/I2C/UART   │  communication protocol   │
│  Interrupt pin  │  event listener / callback │
│  Clock signal   │  system timer / scheduler  │
│  Reset line     │  process restart           │
└──────────────────────────────────────────────┘

2.5 Kirchhoff's Laws

Kirchhoff's Current Law (KCL): The total current entering a node equals the total current leaving it. Like data flowing through a network — what goes in must come out.

        ┌──[R1]──┐
   I_in │        │ I_out1
   ─────┤ Node A ├──[R2]──
        │        │ I_out2
        └──[R3]──┘

   I_in = I_out1 + I_out2

Kirchhoff's Voltage Law (KVL): The sum of all voltages around any closed loop is zero. Like an accounting ledger — everything balances.

   +9V ───[R1]───[R2]───GND

   V_source = V_R1 + V_R2
   9V = V_R1 + V_R2

2.6 Capacitors, Inductors, and Diodes

Capacitors — Tiny Rechargeable Batteries

Symbol:  ─┤├─

Function: Stores energy in an electric field
          Smooths voltage fluctuations (like a buffer in data streaming)
          Blocks DC, passes AC (like a high-pass filter)

Common uses on PCBs:
  - Decoupling caps (placed near IC power pins to stabilize voltage)
  - Timing circuits (RC circuits)
  - Filtering noise

Think of a capacitor as a small local cache for electrical energy — it provides instantaneous current when the main power supply can't respond fast enough.

Inductors — Coils That Resist Current Changes

Symbol:  ─))))─

Function: Stores energy in a magnetic field
          Resists changes in current (like rate limiting)
          Passes DC, blocks AC (opposite of capacitors)

Common uses:
  - Power supply filtering (LC filters)
  - Buck/boost converter circuits
  - EMI suppression

Diodes — One-Way Valves

Symbol:  ─▷|─

Function: Allows current in one direction only

Types:
  - Signal diode (1N4148): General purpose
  - Schottky diode: Fast switching, low voltage drop
  - Zener diode: Allows reverse current at a specific voltage (voltage regulation)
  - LED: Emits light (Light Emitting Diode)

Transistors — The Switches That Make Computing Possible

NPN Transistor Symbol:
        Collector (C)
           │
    Base ──┤
           │
        Emitter (E)

Software equivalent: A transistor is like an if-statement
  - If current flows into Base → Current flows from Collector to Emitter (HIGH)
  - If no current into Base → No current flow (LOW)

MOSFET (more common in modern PCBs):
  - Gate = Base (input)
  - Drain = Collector
  - Source = Emitter
  - Voltage-controlled (no current needed at gate) — like an event-driven trigger

2.7 Communication Protocols — The APIs of Hardware

UART (Universal Asynchronous Receiver/Transmitter)

Like: HTTP — Simple, widely supported, point-to-point

Pins: TX (Transmit), RX (Receive), GND
Baud rates: 9600, 115200, etc.

Use case: Debug console, GPS modules, Bluetooth modules

Connection:
  Device A (TX) ──────── Device B (RX)
  Device A (RX) ──────── Device B (TX)
  Device A (GND)──────── Device B (GND)

SPI (Serial Peripheral Interface)

Like: gRPC — Fast, synchronous, one master controls everything

Pins: MOSI, MISO, SCK, CS (Chip Select)
Speed: Up to 100+ MHz

Use case: Displays, SD cards, flash memory, ADCs

  Master ───── MOSI ─────→ Slave
  Master ←──── MISO ────── Slave
  Master ───── SCK  ─────→ Slave  
  Master ───── CS   ─────→ Slave

I²C (Inter-Integrated Circuit)

Like: REST API on a shared bus — Multiple devices, addressed by ID

Pins: SDA (Data), SCL (Clock)
Speed: 100kHz (standard), 400kHz (fast), 3.4MHz (high speed)

Use case: Sensors, EEPROMs, RTCs, small displays

  ┌────────┐    ┌────────┐    ┌────────┐
  │Master  │    │Slave 1 │    │Slave 2 │
  │(MCU)   │    │(0x68)  │    │(0x3C)  │
  └───┬────┘    └───┬────┘    └───┬────┘
      │  SDA ───────┤─────────────┤
      │  SCL ───────┤─────────────┤
      
  Each device has a unique address (like a URL endpoint)

Chapter 3: Understanding PCB Fundamentals

3.1 What Is a PCB?

A Printed Circuit Board is a physical substrate that:

  1. Mechanically supports electronic components
  2. Electrically connects them via copper traces (like wires printed on the board)

Think of a PCB as the physical architecture of a system — it's the infrastructure layer that your firmware runs on.

Cross-section of a simple 2-layer PCB:

    ┌─────────────────────────────────────┐
    │ ▓▓▓▓ Copper Layer (Top) ▓▓▓▓▓▓▓▓▓ │  ← 35μm (1oz) copper
    │ ═══════════════════════════════════ │  ← FR4 substrate (1.6mm typical)
    │ ▓▓▓▓ Copper Layer (Bottom) ▓▓▓▓▓▓ │  ← 35μm (1oz) copper
    └─────────────────────────────────────┘

3.2 PCB Layers

2-Layer Board (Simplest and cheapest)

Layer 1 (Top):     Components + Signal routing
Layer 2 (Bottom):  Components + Signal routing

Use case: Simple circuits, Arduino-level projects, breakouts
Cost: $ (cheapest)

4-Layer Board (The sweet spot for most projects)

Layer 1 (Top):      Components + Signal routing
Layer 2 (Inner 1):  GND Plane (solid ground reference)
Layer 3 (Inner 2):  Power Plane
Layer 4 (Bottom):   Components + Signal routing

Use case: Microcontroller boards, IoT devices, moderate-speed designs
Cost: $$ (moderate)

6+ Layer Boards (Complex designs)

Layer 1:  Signal (Top)
Layer 2:  GND Plane
Layer 3:  Signal
Layer 4:  Power Plane
Layer 5:  GND Plane
Layer 6:  Signal (Bottom)

Use case: High-speed digital, DDR memory, dense BGA packages, RF
Cost: $$$+ (expensive)

Software analogy:

  • 2-layer = monolithic application (everything on a few files)
  • 4-layer = well-structured application (separation of concerns)
  • 6+ layer = microservices architecture (complex but organized)

3.3 PCB Terminology Cheat Sheet

┌─────────────────────┬─────────────────────────────────────────────┐
│ Term                │ What It Means                               │
├─────────────────────┼─────────────────────────────────────────────┤
│ Trace               │ A copper "wire" on the PCB                  │
│ Via                 │ A hole that connects traces between layers   │
│ Pad                 │ A copper area where a component is soldered │
│ Footprint           │ The physical pattern for a component        │
│ Schematic           │ The logical circuit diagram                 │
│ Net                 │ A named electrical connection point          │
│ Netlist             │ The list of all connections (like dependency │
│                     │ graph)                                       │
│ Copper pour/Plane   │ Large area of copper (ground or power)      │
│ Silkscreen          │ Text/labels printed on the board surface    │
│ Solder mask         │ The green (or other color) coating          │
│ Solder paste        │ Metal alloy used in SMD assembly            │
│ Gerber files        │ Manufacturing output files (the "binary")  │
│ Bill of Materials   │ Component list (BOM) — like package.json    │
│ DRC                 │ Design Rule Check (like linting)            │
│ ERC                 │ Electrical Rule Check (like type checking)  │
│ Clearance           │ Minimum distance between conductors         │
│ Trace width         │ Width of a copper trace                     │
│ Annular ring        │ Copper ring around a drilled hole           │
│ Drill hit           │ Where a hole is drilled                     │
│ Edge cut / outline  │ The physical board boundary                 │
│ Fiducial            │ Alignment mark for pick-and-place machines  │
│ Test point          │ Accessible pad for probing during testing   │
└─────────────────────┴─────────────────────────────────────────────┘

3.4 Component Packages

Through-Hole (THT)

    Component
    ┌────────┐
    │        │  ← Visible on top of board
    └──┬──┬──┘
       │  │     ← Leads go through holes
    ───┴──┴───  ← Soldered on bottom

Pros: Easy to hand-solder, robust, good for prototyping
Cons: Larger, not suitable for automated assembly at scale

Surface Mount (SMD/SMT)

    ┌────────────────┐
    │    Component    │  ← Sits on top of pads
    ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓  ← Soldered to surface pads

Common sizes (imperial/metric):
  Resistors/Caps:
    0201 (0603) — Tiny, hard to hand-solder
    0402 (1005) — Very small
    0603 (1608) — Small but manageable ← Good starting point
    0805 (2012) — Easy to hand-solder  ← Best for beginners
    1206 (3216) — Large, very easy

IC Packages:
    SOIC    — Gull-wing leads, easy to solder
    QFP     — Leads on all 4 sides
    QFN     — No-lead, pad underneath (needs reflow)
    BGA     — Ball Grid Array (professional only)
    SOT-23  — 3-6 pin small transistors/regulators

3.5 Reading a Schematic

A schematic is like a class diagram — it shows logical connections, not physical placement.

Basic schematic symbols:

Resistor:        Capacitor:        Inductor:          Diode:
   ┌─/\/\/─┐      ─┤├─             ─))))─            ─▷|─
                  (non-polar)                        (anode ▷| cathode)
                  
Electrolytic      LED:             NPN Transistor:    MOSFET (N-ch):
Cap (polar):      ─▷|✦─                  C                D
   ─┤+├─                          B ──┤             G ──┤
                                  E    └               └── S

Ground:          VCC/Power:        Crystal:
   ┴ (GND)       ──┬── (VCC)       ─┤XTAL├─
                   Arrow up          Two parallel lines

Connector pin:    Test point:       Net label:
   ○              ◇                 ─── Name ───

Power Symbols

VCC / VDD  ──── Positive supply voltage
VSS        ──── Ground (in CMOS terminology)  
GND        ──── Ground
+3.3V      ──── Specific voltage rail
+5V        ──── Specific voltage rail
AGND       ──── Analog ground (separate from digital for noise isolation)

Chapter 4: The PCB Design Workflow

4.1 The Complete Process

Think of the PCB design flow as a development lifecycle:

┌──────────────────────────────────────────────────────────────┐
│                    PCB DESIGN WORKFLOW                        │
│                                                              │
│  1. REQUIREMENTS          Like: Product requirements doc     │
│     │                                                        │
│  2. SYSTEM ARCHITECTURE   Like: High-level system design     │
│     │                                                        │
│  3. COMPONENT SELECTION   Like: Choosing libraries/frameworks│
│     │                                                        │
│  4. SCHEMATIC DESIGN      Like: Writing the code/logic       │
│     │                                                        │
│  5. ERC CHECK             Like: Type checking / linting      │
│     │                                                        │
│  6. PCB LAYOUT            Like: Code optimization            │
│     │                                                        │
│  7. DRC CHECK             Like: Integration testing          │
│     │                                                        │
│  8. REVIEW                Like: Code review (PR)             │
│     │                                                        │
│  9. GERBER GENERATION     Like: Build / compilation          │
│     │                                                        │
│  10. MANUFACTURING        Like: Deployment                   │
│     │                                                        │
│  11. ASSEMBLY             Like: Environment setup            │
│     │                                                        │
│  12. TESTING/BRING-UP     Like: QA / Integration testing     │
│     │                                                        │
│  13. ITERATE              Like: Bug fixes / new features     │
└──────────────────────────────────────────────────────────────┘

4.2 Step-by-Step Breakdown

Step 1: Requirements Definition

Questions to answer:
├── What does the board need to DO?
├── What are the power requirements? (voltage, current)
├── What is the physical size constraint?
├── What interfaces are needed? (USB, WiFi, sensors, etc.)
├── What is the operating environment? (temperature, moisture)
├── What is the production volume? (prototype vs. mass production)
├── What is the budget?
└── What is the timeline?

Step 2: System Architecture

Example: IoT Temperature Sensor

┌────────────┐     ┌────────────┐     ┌────────────┐
│ Temperature │     │            │     │  WiFi      │
│ Sensor      │I2C  │  ESP32     │SPI  │  Module    │
│ (SHT31)     ├────→│  MCU       ├────→│  (built-in)│
└────────────┘     │            │     └─────┬──────┘
                   │            │           │
┌────────────┐     │            │     ┌─────┴──────┐
│ USB-UART   │UART │            │     │  Antenna   │
│ (CP2102)   ├────→│            │     └────────────┘
└────────────┘     └─────┬──────┘
                         │
              ┌──────────┼──────────┐
              │          │          │
         ┌────┴───┐ ┌───┴────┐ ┌──┴───────┐
         │ 3.3V   │ │ USB    │ │ Battery  │
         │ LDO    │ │ Power  │ │ Charger  │
         └────────┘ └────────┘ └──────────┘

Step 3: Component Selection

(Deep dive in Chapter 6)

Step 4: Schematic Design

(Deep dive in Chapter 5)

Step 5: Electrical Rule Check (ERC)

Common ERC errors:
├── Unconnected pins (like unused variables)
├── Power pins not connected (like missing imports)
├── Short circuits (like name collisions)
├── Missing pull-up/pull-down resistors
└── Incorrect pin types (output connected to output)

Step 6: PCB Layout

(Deep dive in Chapter 7)

Step 7: Design Rule Check (DRC)

Common DRC checks:
├── Minimum trace width
├── Minimum clearance between traces
├── Minimum drill size
├── Annular ring size
├── Silkscreen overlap
└── Board edge clearance

Steps 8-13: Review through Iteration

(Covered in later chapters)


Chapter 5: Schematic Design Deep Dive

5.1 Organizing Your Schematic

Hierarchical Design

Like organizing code into modules/packages:

Top-Level Sheet
├── Power Supply (sub-sheet)
│   ├── USB Input
│   ├── LDO 3.3V
│   └── Battery Management
├── MCU (sub-sheet)
│   ├── ESP32 Module
│   ├── Crystal Oscillator
│   └── Reset Circuit
├── Sensors (sub-sheet)
│   ├── Temperature Sensor
│   └── Accelerometer
└── Communication (sub-sheet)
    ├── USB-UART Bridge
    └── Debug Header

5.2 Essential Circuits Every Designer Should Know

Decoupling Capacitors (CRITICAL)

This is the single most important passive circuit pattern:

     VCC Rail
       │
       ├────┬──── To IC VCC Pin
       │    │
      ┌┴┐  ┌┴┐
      │C│  │C│    C1: 100nF (0.1µF) ceramic — filters high-frequency noise
      │1│  │2│    C2: 10µF  electrolytic — filters low-frequency noise
      └┬┘  └┬┘
       │    │
       ┴────┴──── GND

RULE: Place these as CLOSE as physically possible to the IC's power pins.
      Every VCC pin on every IC gets at least a 100nF cap.
      
Software analogy: These are like L1/L2 cache — they provide 
instantaneous current "close to the computation."

Pull-up and Pull-down Resistors

Pull-up:                    Pull-down:
 VCC                         GND
  │                           │
 [R] 10kΩ                   [R] 10kΩ
  │                           │
  ├──── Signal Pin            ├──── Signal Pin
  │                           │
  
Ensures a defined logic state when nothing is driving the pin.

Software analogy: Default values / fallback states
  - Pull-up = default to HIGH (1)
  - Pull-down = default to LOW (0)

Required for:
  - I²C lines (SDA, SCL always need pull-ups)
  - Reset pins (usually pulled high, active low)
  - Interrupt lines
  - Chip select lines
  - Boot configuration pins

Voltage Divider

  V_in
   │
  [R1]
   │
   ├─── V_out = V_in × R2 / (R1 + R2)
  [R2]
   │
  GND

Example: 5V to 3.3V level shifting (for signals, NOT power)
  V_out = 5V × 10k / (10k + 5.1k) ≈ 3.3V

Software analogy: A scaling/normalization function

LED with Current-Limiting Resistor

  VCC (3.3V)
   │
  [R] = (VCC - V_LED) / I_LED
   │       R = (3.3 - 2.0) / 0.020 = 65Ω → use 68Ω or 100Ω
  [LED]
   │
  GND

NEVER connect an LED directly to a voltage source without a resistor.
This is the hardware equivalent of an unhandled exception.

Reset Circuit

  VCC
   │
  [R] 10kΩ (pull-up)
   │
   ├──── RESET pin of MCU
   │
  [C] 100nF (to GND)     ← Filters noise, ensures clean reset
   │
  [SW] Momentary push button to GND

Behavior:
  - Normal operation: R pulls RESET high → MCU runs
  - Button pressed: RESET pulled to GND → MCU resets
  - C prevents noise from triggering spurious resets

Crystal Oscillator Circuit

                    ┌────────────────┐
  ┌───[Crystal]────┤ XTAL1    MCU   │
  │                 │                │
 [C1]               │                │
  │    ┌───[Crystal]─┤ XTAL2        │
 [C2]  │             └────────────────┘
  │    │
  GND  GND

  C1, C2: Typically 12-22pF (check crystal datasheet)
  
  Software analogy: The crystal is the CPU clock — 
  it sets the fundamental timing of all operations.

USB Input Circuit

  USB Connector
  ┌──────────────────────────┐
  │  VBUS (5V)  ───────────────────── To power supply input
  │  D-     ─────[R 22Ω]──────────── To MCU/USB-UART IC D-
  │  D+     ─────[R 22Ω]──────────── To MCU/USB-UART IC D+
  │  GND    ───────────────────────── Common ground
  │  Shield ─────[RC to GND]───────── Chassis ground (optional)
  └──────────────────────────┘
  
  Note: Series resistors (22Ω) help with signal integrity
  and USB spec compliance. Add ESD protection diodes for robustness.

Power Supply (LDO Voltage Regulator)

  Input (e.g., 5V from USB)
   │
  [C_in] 10µF + 100nF    ← Input capacitors (per datasheet)
   │
  ┌────────────────┐
  │  LDO (e.g.     │
  │  AMS1117-3.3)  ├──── Output (3.3V)
  │                │
  │  IN    OUT     │    [C_out] 10µF + 100nF  ← Output capacitors
  │       GND      │          │
  └───────┬────────┘         GND
          │
         GND

Output = 3.3V (fixed for AMS1117-3.3 variant)

Rule: ALWAYS check the datasheet for required input/output 
capacitors. Wrong caps = oscillation = unreliable board.

5.3 Schematic Best Practices

1. ANNOTATE EVERYTHING
   ├── Label every net with a meaningful name
   ├── Add value labels to all components
   ├── Use net labels instead of long wires crossing the page
   └── Add notes for non-obvious design decisions

2. USE HIERARCHICAL SHEETS
   ├── One functional block per sheet
   ├── Keep sheets focused (20-30 components max per sheet)
   └── Use hierarchical pins for sheet-to-sheet connections

3. FOLLOW CONVENTIONS
   ├── Signals flow left to right
   ├── Power flows top to bottom (VCC at top, GND at bottom)
   ├── Use standard symbol libraries
   └── Consistent naming conventions for nets

4. REFERENCE DESIGNATORS
   ├── R1, R2, R3... (Resistors)
   ├── C1, C2, C3... (Capacitors)
   ├── U1, U2, U3... (ICs)
   ├── Q1, Q2, Q3... (Transistors)
   ├── D1, D2, D3... (Diodes)
   ├── J1, J2, J3... (Connectors)
   ├── SW1, SW2...   (Switches)
   ├── Y1, Y2...     (Crystals)
   └── FB1, FB2...   (Ferrite Beads)

5. INCLUDE A TITLE BLOCK
   ├── Project name
   ├── Revision number
   ├── Date
   ├── Author
   └── Sheet number / total sheets

Chapter 6: Component Selection and Management

6.1 The Component Selection Process

Like choosing libraries/frameworks for a software project:

Selection Criteria:
├── FUNCTIONALITY    Does it do what we need?
├── SPECIFICATIONS   Voltage, current, speed, accuracy
├── PACKAGE          Can we solder it? Does it fit?
├── AVAILABILITY     Is it in stock? Long lead time?
├── COST             Does it fit the budget?
├── ALTERNATIVES     Are there pin-compatible alternatives?
├── DOCUMENTATION    Good datasheet? Reference designs?
└── COMMUNITY        Examples, forums, known issues?

6.2 Where to Find Components

Major Distributors:
├── Digi-Key    (digikey.com)     — Largest selection, excellent search
├── Mouser      (mouser.com)      — Great for engineers
├── LCSC        (lcsc.com)        — Cheapest for prototypes (China-based)
├── Arrow       (arrow.com)       — Good for volume pricing
├── Farnell     (farnell.com)     — Popular in Europe
└── RS Components (rs-online.com) — Popular in Europe/Asia

Component Search Tools:
├── Octopart    (octopart.com)    — Searches ALL distributors at once
├── Findchips   (findchips.com)   — Price comparison and stock
└── SnapEDA     (snapeda.com)     — Free symbols + footprints

IMPORTANT: Check STOCK before designing in a component.
Supply chain issues can kill a project.

6.3 Reading a Datasheet

Every component has a datasheet. Reading one is like reading API documentation:

Key sections of a datasheet:

1. FIRST PAGE (Overview)
   ├── Part number breakdown
   ├── Key features
   ├── Pinout diagram        ← CRITICAL
   └── Absolute maximum ratings  ← NEVER EXCEED THESE

2. ELECTRICAL CHARACTERISTICS
   ├── Operating voltage range
   ├── Current consumption
   ├── Input/output voltage levels
   └── Timing specifications

3. APPLICATION INFORMATION
   ├── Typical application circuit  ← START HERE
   ├── Recommended component values
   └── Layout guidelines            ← READ THIS

4. PACKAGE INFORMATION
   ├── Physical dimensions
   ├── Footprint drawing
   ├── Recommended land pattern
   └── Thermal information

5. ORDERING INFORMATION
   ├── Part number suffixes/options
   ├── Package types available
   └── Temperature range grades

Example: Reading a Voltage Regulator Datasheet

AMS1117-3.3 Datasheet Key Info:

Pinout:
  ┌─────────┐
  │ 1. GND  │ ← Tab is also GND
  │ 2. OUT  │ ← 3.3V output
  │ 3. IN   │ ← Input voltage (4.5-12V)
  └─────────┘

Key Specs:
  ├── Output voltage: 3.3V (±1%)
  ├── Max output current: 1A
  ├── Dropout voltage: 1.3V (need at least 4.6V input)
  ├── Input capacitors: 10µF ceramic minimum
  ├── Output capacitors: 10µF ceramic minimum
  └── Thermal: Needs thermal pad on PCB for heat dissipation

6.4 Common Components Reference

Resistors

Common values to stock (E24 series):
10Ω, 22Ω, 47Ω, 100Ω, 220Ω, 330Ω, 470Ω,
680Ω, 1kΩ, 2.2kΩ, 4.7kΩ, 10kΩ, 22kΩ, 
47kΩ, 100kΩ, 470kΩ, 1MΩ

Power ratings:
  1/8W (0805)  — Most common for digital circuits
  1/4W (1206)  — Standard through-hole
  1/2W          — Higher power applications

Tolerance:
  1% (±) — Standard for most designs (get this)
  5%     — Acceptable for non-critical applications

Capacitors

Common values to stock:
10pF, 22pF, 100pF, 1nF, 10nF, 100nF (0.1µF) ← MUST HAVE
1µF, 4.7µF, 10µF, 22µF, 47µF, 100µF

Dielectric types:
  C0G/NP0 — Most stable, for precision analog/RF
  X7R     — Good general purpose (most common) ← Use this
  X5R     — Similar to X7R, slightly worse
  Y5V     — Avoid (terrible temperature stability)

Rules of thumb:
  100nF ceramic X7R — Decoupling (every IC gets one)
  10µF ceramic       — Bulk decoupling
  22pF ceramic C0G   — Crystal load capacitors

Voltage Regulators

Common LDOs:
  AMS1117-3.3  — 3.3V, 1A, cheap, SOT-223
  MCP1700-3302 — 3.3V, 250mA, low quiescent current
  AP2112K-3.3  — 3.3V, 600mA, low dropout

Common Buck Converters:
  MP1584       — Adjustable, 3A, compact module
  LM2596       — Adjustable, 3A, through-hole available
  TPS54331     — 3A, TI quality

Microcontrollers

For beginners (pick one to start):
  Arduino (ATmega328P)  — Simplest, largest community
  ESP32                  — WiFi+BLE, powerful, cheap
  STM32 (STM32F103)     — Industry standard ARM Cortex-M
  RP2040                 — Raspberry Pi's MCU, dual-core

USB-to-UART Bridges

CP2102N    — Silicon Labs, good driver support
CH340G     — Cheapest, works fine for most cases
FT232RL    — FTDI, best but most expensive

6.5 Component Library Management

Like managing a package registry:

Best Practices:
├── Create a STANDARD LIBRARY of frequently used components
│   ├── All your standard resistor values (0805 package)
│   ├── All your standard capacitor values (0805 package)
│   ├── Your preferred voltage regulators
│   ├── Your preferred connectors
│   └── Common ICs you use
│
├── VERIFY EVERY FOOTPRINT
│   ├── Check against datasheet recommended land pattern
│   ├── Check pin numbering (Pin 1 location!)
│   └── Check dimensions with calipers if possible
│
├── USE SYMPTOMATIC NAMING
│   ├── R_0805_100K — Resistor, 0805, 100kΩ
│   ├── C_0805_100N — Capacitor, 0805, 100nF
│   └── IC_ESP32-WROOM-32 — ESP32 module
│
└── SOURCES FOR SYMBOLS & FOOTPRINTS
    ├── SnapEDA (snapeda.com)
    ├── Ultra Librarian (ultralibrarian.com)
    ├── Component manufacturer websites
    ├── KiCad community libraries
    └── ALWAYS VERIFY downloaded libraries before use!

Chapter 7: PCB Layout — From Schematic to Board

7.1 The Layout Process

This is where the schematic (logical design) becomes a physical board. Like refactoring code for performance and readability:

LAYOUT WORKFLOW:
│
├── 1. Define Board Outline
│      Set physical dimensions, mounting holes
│
├── 2. Place Components (Critical Step!)
│      Group related components together
│      Start with connectors and fixed-position items
│      Then place ICs, then passives
│
├── 3. Route Power
│      Wide traces or copper pours for power/ground
│      Star topology or dedicated planes
│
├── 4. Route Critical Signals
│      High-speed, sensitive, or impedance-controlled traces first
│
├── 5. Route Remaining Signals
│      Fill in the rest of the connections
│
├── 6. Add Copper Pours
│      Ground planes, thermal relief
│
├── 7. Final Cleanup
│      Silkscreen, fiducials, test points
│
└── 8. Run DRC
      Fix all violations

7.2 Component Placement Strategy

Component placement is like architecture — it determines 80% of your board quality.

PLACEMENT HIERARCHY:

1. FIXED POSITIONS FIRST
   ├── Board connectors (USB, power jack, headers)
   ├── Mounting holes
   └── User interface (buttons, LEDs, display)

2. CRITICAL ICs SECOND
   ├── Main MCU — place near center
   ├── Crystal — right next to MCU
   ├── Decoupling caps — RIGHT NEXT TO IC power pins
   └── Power regulators — near power input

3. SUPPORTING COMPONENTS
   ├── Pull-up/pull-down resistors near their ICs
   ├── Filter components near connectors
   └── Bypass caps near every IC

4. THERMAL CONSIDERATIONS
   ├── Heat-generating components spread apart
   ├── Thermal vias under hot components
   └── Don't place electrolytic caps near heat sources

Placement Example: MCU Section

         ┌──────────────────────────────────────────┐
         │                                          │
         │    ┌──────┐     ┌──────┐                 │
         │    │C1    │     │C2    │   Decoupling    │
         │    │100nF │     │10µF │   caps as close │
         │    └──┬───┘     └──┬───┘   as possible   │
         │       │VCC         │VCC                  │
         │       ▼            ▼                     │
         │    ┌──────────────────────┐              │
         │    │                      │              │
         │    │     ESP32-WROOM      │              │
         │    │                      │              │
         │    └──────────────────────┘              │
         │              │                           │
         │         ┌────┴────┐                      │
         │         │  Y1     │  Crystal right       │
         │         │ 40MHz   │  next to MCU         │
         │         │         │  with load caps      │
         │         └─────────┘                      │
         │              ┌─┬─┐                       │
         │              │C│C│  Load capacitors      │
         │              │3│4│  (22pF typical)       │
         │              └─┴─┘                        │
         └──────────────────────────────────────────┘

7.3 Trace Routing

Trace Width Calculation

Trace width determines how much current a trace can carry. Like choosing wire gauge:

Current Capacity (approximate, for 1oz copper, 10°C rise):

Trace Width    │ Current Capacity (external layer)
───────────────┼──────────────────────────
6 mil (0.15mm) │ ~0.2A
8 mil (0.2mm)  │ ~0.3A
10 mil (0.25mm)│ ~0.4A
15 mil (0.38mm)│ ~0.6A
20 mil (0.5mm) │ ~0.8A
25 mil (0.635mm│ ~1.0A
50 mil (1.27mm)│ ~2.0A
100 mil (2.54mm│ ~4.0A

Use an online trace width calculator for precision:
  - Saturn PCB Toolkit
  - 4pcb.com trace width calculator
  - KiCad's built-in calculator

RULE OF THUMB:
  Signal traces: 6-10 mil (0.15-0.25mm)  
  Power traces: 20-50 mil (0.5-1.27mm) minimum
  High current: Use copper pours or multiple vias

Routing Rules

GOLDEN RULES OF ROUTING:

1. AVOID 90° TURNS
   ✗                    ✓
   ───┐                 ───┐
      │                    │
      └──                  └── (45° or curved)
   
   Why: 90° corners can cause impedance discontinuities 
        and acid traps during manufacturing.

2. KEEP TRACES SHORT AND DIRECT
   Don't route the scenic route — shortest path is best
   (within constraints)

3. AVOID RUNNING PARALLEL TRACES CLOSE TOGETHER
   → Crosstalk (signals interfering with each other)
   → Like data races in concurrent programming
   
   Minimum spacing: 2× the trace width (for non-critical)
   For high-speed: Follow impedance calculations

4. ROUTE ON GRID
   Use a routing grid (typically 5mil or 0.1mm)
   Keeps things neat and manufacturable

5. USE DIFFERENT LAYERS FOR DIFFERENT DIRECTIONS
   Layer 1: Mostly horizontal traces
   Layer 2: Mostly vertical traces
   (This minimizes parallel coupling and simplifies routing)

6. USE VIAS SPARINGLY
   Each via adds inductance and potential failure point
   But don't be afraid of them — they're necessary

7. MAINTAIN CLEARANCE
   Keep adequate space between traces, pads, and vias
   Follow your manufacturer's minimum specs

Via Types and Usage

Through-hole via (most common):
  ┌───────────┐ Top Layer
  │     ○     │
  │     │     │ ← Drilled hole plated with copper
  │     │     │
  │     ○     │ Bottom Layer
  └───────────┘

Blind via:
  ┌───────────┐ Top Layer
  │     ○     │
  │     │     │ ← Goes to inner layer only
  ├───────────┤ Inner Layer
  │           │
  └───────────┘

Buried via:
  ┌───────────┐ Top Layer
  │           │
  ├───────────┤ Inner Layer 1
  │     ○     │
  │     │     │ ← Between inner layers only
  ├───────────┤ Inner Layer 2
  │           │
  └───────────┘

Micro via:
  Laser-drilled, very small (0.1mm typical)
  Used in HDI (High Density Interconnect) designs
  Common under BGA packages

Via sizing (typical):
  Drill: 0.3mm (12mil)
  Pad: 0.6mm (24mil)  
  Annular ring: 0.15mm (6mil)

7.4 Ground Planes and Power Distribution

Ground Plane Design

SINGLE GROUND PLANE (preferred for most designs):
┌───────────────────────────────────────────┐
│ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ │
│ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ │
│ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ │
│ ▓▓▓▓▓▓ SOLID GROUND PLANE ▓▓▓▓▓▓▓▓▓▓▓▓ │
│ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ │
│ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ │
└───────────────────────────────────────────┘

RULES:
1. Keep ground plane SOLID and UNBROKEN
   ├── Don't route signal traces through it (on the ground layer)
   ├── Every break in the ground plane creates a current loop
   └── Current loops = antenna = EMI problems

2. Use stitching vias
   ├── Multiple vias connecting ground layers
   ├── Placed every 1/20th wavelength of highest frequency
   └── Around the board perimeter

3. Connect ALL ground pins to the plane with short traces or vias

Power Distribution

APPROACH 1: Power Plane (4+ layer boards)
  ┌──────────────────────────────────┐
  │  Dedicated power plane (3.3V)    │ ← Entire layer
  │  with splits for different rails  │
  └──────────────────────────────────┘

APPROACH 2: Power Traces (2-layer boards)
  VCC Rail: ──────── Wide trace (25-50 mil) ────────
              │         │         │
              C1       U1 VCC    C2
              │         │         │
  GND: ──────┴─────────┴─────────┴─── Ground pour/rail

APPROACH 3: Power Bus (Star topology)
                        VCC Input
                           │
              ┌────────────┼────────────┐
              │            │            │
           [Reg1]       [Reg2]       [Reg3]
              │            │            │
           3.3V          5V          1.8V
              │            │            │
           Load1        Load2        Load3
              │            │            │
              └────────────┼────────────┘
                           │
                         GND

7.5 Layer Stack-up Recommendations

2-Layer Board

Layer 1 (Top):    Signal + Components
Layer 2 (Bottom): Signal + Components

Tips:
├── Use ground pour on both layers
├── Keep ground pour as solid as possible
├── Route critical signals on one layer
└── Use lots of ground vias (stitching)

4-Layer Board (RECOMMENDED for most projects)

Layer 1 (Top):       Signal + Components
Layer 2 (Inner 1):   GND Plane (SOLID)
Layer 3 (Inner 2):   Power Plane(s)
Layer 4 (Bottom):    Signal + Components

Why this is the best:
├── Solid GND reference for all signals on Layer 1
├── Natural shielding between layers
├── EMI compliance is much easier
├── Impedance control is more predictable
└── Only ~$10-20 more than 2-layer for prototypes

6-Layer Board

Layer 1: Signal (Top)
Layer 2: GND Plane
Layer 3: Signal (Inner)
Layer 4: Power Plane
Layer 5: GND Plane
Layer 6: Signal (Bottom)

Use when: High-speed signals, dense BGA packages, DDR memory

7.6 Silkscreen and Documentation

SILKSCREEN BEST PRACTICES:

1. Label all connectors
   ├── "USB-C", "UART", "JTAG", "I2C_HEADER"
   └── Pin 1 indicators

2. Label important ICs
   ├── IC part number (or abbreviated)
   └── Pin 1 dot/mark

3. Label test points
   ├── "TP_3V3" (3.3V test point)
   ├── "TP_GND" (Ground test point)
   └── "TP_UART_TX" (UART transmit test point)

4. Add board info
   ├── Project name
   ├── Revision (REV 1.0)
   ├── Date
   ├── Your logo (optional but fun)
   └── URL to documentation

5. Component reference designators
   ├── R1, R2, C1, C2, U1, etc.
   └── (If space permits)

6. Orientation marks
   ├── LED polarity
   ├── Electrolytic capacitor polarity
   ├── Pin 1 for ICs
   └── Connector key direction

7. DO NOT put silkscreen over pads
   (DRC will flag this, but double-check)

Chapter 8: Design Rules and Constraints

8.1 Setting Up Design Rules

Like configuring a linter or compiler settings:

TYPICAL DESIGN RULES FOR HOBBYIST/PROTOTYPE:

┌──────────────────────────┬─────────────┬─────────────┐
│ Parameter                │ 2-Layer     │ 4-Layer     │
├──────────────────────────┼─────────────┼─────────────┤
│ Min trace width          │ 6 mil       │ 4 mil       │
│ Min clearance (spacing)  │ 6 mil       │ 4 mil       │
│ Min via drill            │ 0.3mm       │ 0.3mm       │
│ Min via pad              │ 0.6mm       │ 0.6mm       │
│ Min annular ring         │ 0.15mm      │ 0.15mm      │
│ Min text size            │ 0.8mm       │ 0.8mm       │
│ Board outline tolerance  │ ±0.1mm      │ ±0.1mm      │
│ Copper to board edge     │ 0.2mm       │ 0.2mm       │
│ Min hole-to-hole         │ 0.25mm      │ 0.25mm      │
└──────────────────────────┴─────────────┴─────────────┘

These vary by manufacturer. Check your fab's capabilities!
JLCPCB, PCBWay, and OSH Park all publish their specs.

8.2 Net Classes

Like type constraints in a type system:

NET CLASSES:
│
├── POWER (VCC, GND, 3V3, 5V, etc.)
│   ├── Trace width: 20-50 mil minimum
│   ├── Clearance: 8-10 mil
│   └── Priority: HIGH
│
├── HIGH_SPEED (USB, SPI clock, etc.)
│   ├── Trace width: Calculated for impedance (usually 8-10 mil)
│   ├── Clearance: Per impedance calculation
│   ├── Matched length: Yes (for differential pairs)
│   └── Priority: HIGH
│
├── ANALOG (sensor signals, audio)
│   ├── Trace width: 8-10 mil
│   ├── Clearance: 10+ mil (keep away from digital)
│   ├── Keep short and direct
│   └── Priority: HIGH
│
└── DIGITAL (GPIO, UART, I2C, etc.)
    ├── Trace width: 6-8 mil
    ├── Clearance: 6 mil
    └── Priority: NORMAL

8.3 Differential Pairs

For USB, LVDS, Ethernet, and other differential signaling:

DIFFERENTIAL PAIR:
  ┌─────────────┐         ┌─────────────┐
  │  D+  ──────────────────→  D+        │
  │             │         │             │
  │  D-  ──────────────────→  D-        │
  │  Transmitter│         │  Receiver   │
  └─────────────┘         └─────────────┘

Rules:
├── Route D+ and D- as close together as possible
├── Maintain consistent spacing between the pair
├── Match trace lengths (within 5 mil for USB)
├── Don't route anything between the pair
├── Keep the pair on the same layer
├── Avoid vias if possible (use them equally if needed)
└── Maintain ground reference plane below

USB 2.0 Differential Impedance: 90Ω ±10%

Chapter 9: Signal Integrity and Power Integrity

9.1 Why This Matters

Signal integrity (SI) is like network latency — when signals degrade, communication fails. Power integrity (PI) is like server uptime — unstable power means unstable operation.

SIGNS OF SIGNAL INTEGRITY PROBLEMS:
├── Communication works intermittently
├── Errors increase at higher speeds
├── Adding debug probes changes behavior
├── Board works in some orientations but not others
└── Reducing clock speed fixes problems

9.2 Ground Bounce and Return Paths

EVERY SIGNAL HAS A RETURN PATH:

Signal trace:
  ──────────────────────────────→  Signal (top layer)
  ════════════════════════════════  Ground plane (inner layer)
  ←──────────────────────────────  Return current (follows signal)

KEY INSIGHT: Return current follows the path of least impedance 
             (which at high frequencies = directly under the signal trace)

If you break the ground plane under a high-speed trace:
  ──────────┐    GAP    ┌──────────
  ═══════════│    ↓↓↓↓   │══════════  Ground plane
             └──────────┘
             
  The return current must detour → creates a LOOP → antenna → EMI

RULE: NEVER break a ground plane under a high-speed signal trace.

9.3 Decoupling Strategy (Expanded)

MULTI-TIER DECOUPLING:

Tier 1: Bulk capacitor (near power entry)
  47-100µF electrolytic or ceramic
  Handles large, slow current demands

Tier 2: Local bypass (near each IC)
  10µF ceramic
  Handles medium-frequency demands

Tier 3: Individual pin decoupling
  100nF ceramic, as close to VCC pin as possible
  Handles high-frequency demands

Place them in order: Power → Bulk → Bypass → IC pin
The closer to the pin, the smaller the cap value.

PLACEMENT RULE:
  The physical distance matters more than the capacitance value!
  A 100nF cap 1mm from the pin beats a 10µF cap 10mm away.

9.4 Crosstalk

CROSSTALK = unwanted signal coupling between adjacent traces

Three parallel traces:
  Signal A:  ──────────────── →
  Signal B:  ──────────────── →  ← This trace picks up noise from A and C
  Signal C:  ──────────────── →

Minimization techniques:
├── Increase spacing between traces (3× trace width rule)
├── Add ground traces between sensitive signals
├── Use ground planes (provide natural shielding)
├── Avoid long parallel runs
├── Route sensitive signals on different layers
└── Use differential signaling for critical paths

9.5 EMI (Electromagnetic Interference)

YOUR BOARD IS AN ANTENNA (whether you want it or not)

Common EMI sources on a PCB:
├── High-frequency clock traces
├── Switching power supplies
├── Long un-terminated traces
├── Ground plane splits
├── Cable connections
└── High-speed data buses

EMI reduction techniques:
├── Solid ground planes (most important!)
├── Short traces (especially high-speed)
├── Controlled impedance routing
├── Filtering at cable entry points
├── Proper decoupling
├── Shield cans over sensitive circuits
├── Ferrite beads on power lines
└── ESD protection at connectors

SOFTWARE ANALOGY: EMI is like security — you have to think about it 
from the beginning, not bolt it on at the end.

Chapter 10: Manufacturing and Assembly

10.1 Generating Manufacturing Files

Gerber Files

Gerber files are the "compiled binary" of your PCB design.

Required files:
├── Top Copper Layer        (*.GTL or *-F_Cu.gbr)
├── Bottom Copper Layer     (*.GBL or *-B_Cu.gbr)
├── Inner Layer 1 (if 4L)  (*.G1 or *-In1_Cu.gbr)
├── Inner Layer 2 (if 4L)  (*.G2 or *-In2_Cu.gbr)
├── Top Silkscreen          (*.GTO or *-F_Silkscreen.gbr)
├── Bottom Silkscreen       (*.GBO or *-B_Silkscreen.gbr)
├── Top Solder Mask         (*.GTS or *-F_Mask.gbr)
├── Bottom Solder Mask      (*.GBS or *-B_Mask.gbr)
├── Top Paste (for SMD)     (*.GTP or *-F_Paste.gbr)
├── Bottom Paste (for SMD)  (*.GBP or *-B_Paste.gbr)
├── Board Outline           (*.GKO or *-Edge_Cuts.gbr)
└── Drill File              (*.DRL or *.xln)

Additional files for assembly:
├── Bill of Materials (BOM)     ← like package.json
├── Component Placement File    (CPL/POS) ← X,Y coordinates + rotation
└── Assembly drawings           (PDF)

Exporting from KiCad

1. File → Fabrication Outputs → Gerbers
   ├── Select all layers
   ├── Use Protel filename extensions (most common)
   └── Plot

2. File → Fabrication Outputs → Drill Files
   ├── Excellon format
   ├── Decimal format
   └── Generate Drill File

3. Check with Gerber Viewer
   ├── Use KiCad's built-in viewer
   ├── Or upload to manufacturer's online viewer
   └── VERIFY before ordering!

10.2 Choosing a Manufacturer

PROTOTYPE MANUFACTURERS (Small Quantity):

┌──────────────┬───────────────┬──────────┬──────────────┐
│ Manufacturer │ Min Order     │ Cost (5 pcs) │ Lead Time  │
├──────────────┼───────────────┼──────────┼──────────────┤
│ JLCPCB       │ 5 pcs         │ ~$2-5    │ 3-5 days     │
│ PCBWay       │ 5 pcs         │ ~$5-10   │ 3-5 days     │
│ OSH Park     │ 3 pcs         │ ~$5/sq"  │ 12-20 days   │
│ Elecrow      │ 5 pcs         │ ~$5-10   │ 5-7 days     │
│ Aisler       │ 3 pcs         │ ~€15     │ 10-15 days   │
└──────────────┴───────────────┴──────────┴──────────────┘

PRODUCTION MANUFACTURERS (Volume):
  ├── Sierra Circuits
  ├── Advanced Circuits
  ├── Sunstone Circuits
  └── Various Chinese manufacturers for volume

JLCPCB Example Order Process

1. Go to jlcpcb.com
2. Upload your Gerber .zip file
3. Board specifications auto-detected:
   ├── Layers: 4
   ├── Dimensions: 50mm × 40mm
   ├── Thickness: 1.6mm
   ├── Color: Green (cheapest)
   ├── Surface Finish: HASL (cheapest) or ENIG (better for fine pitch)
   └── Quantity: 5
4. Add SMT Assembly (optional):
   ├── Upload BOM file
   ├── Upload CPL (component placement) file
   └── Select components from their library (LCSC parts)
5. Review the preview
6. Order!

Typical cost for a 4-layer, 50×40mm board:
  Bare PCB: ~$2-5
  Assembly: ~$20-30 (depends on component count)
  Shipping: ~$5-15 (varies by speed)
  TOTAL: ~$27-50 for 5 fully assembled boards!

10.3 Assembly Methods

Hand Soldering

Tools needed:
├── Temperature-controlled soldering station ($30-100)
├── Solder wire (0.8mm lead-free or 0.5mm leaded for easier work)
├── Flux (pen or paste)
├── Tweezers (fine tip, anti-static)
├── Magnifying glass or microscope
├── Solder wick / desoldering pump
└── Multimeter

Tips for SMD hand soldering:
1. Apply flux to pads
2. Tin one pad with solder
3. Position component with tweezers
4. Re-flow the tinned pad to tack one side
5. Solder remaining pads
6. Check for bridges with magnification

Package difficulty (hand soldering):
  0805 passives    ★☆☆☆☆  Easy
  SOIC             ★★☆☆☆  Moderate
  0603 passives    ★★★☆☆  Moderate-Hard
  QFP (0.5mm)      ★★★☆☆  Moderate-Hard  
  QFN              ★★★★☆  Hard (needs hot air)
  0402 passives    ★★★★☆  Hard
  BGA              ★★★★★  Requires reflow oven

Reflow Soldering (SMD mass assembly)

Process:
1. Apply solder paste to PCB (stencil or syringe)
2. Place components on paste
3. Heat in reflow oven following temperature profile
4. Cool down

Temperature Profile (Lead-Free SAC305):
  ┌─────────────────────────────────────┐
  │      Peak: 245°C (10-20 sec)       │
  │     ╱    ╲                          │
  │    ╱      ╲                         │
  │   ╱ Soak   ╲   Cooling             │
  │  ╱ 150-200°  ╲                     │
  │ ╱  (60-120s)  ╲                    │
  │╱                ╲                   │
  └─────────────────────────────────────┘
  Preheat → Soak → Reflow → Cool

Budget reflow options:
  ├── Hot air station ($30-80)
  ├── Toaster oven + controller ($50-100)
  ├── T-962 reflow oven ($150-300)
  └── Professional reflow oven ($1000+)

10.4 Bill of Materials (BOM)

BOM FORMAT:
┌─────┬─────────┬────────────────┬───────┬──────┬──────────┬────────┐
│ Qty │ Ref Des │ Description    │ Value │ Pkg  │ Part No. │ LCSC   │
├─────┼─────────┼────────────────┼───────┼──────┼──────────┼────────┤
│  5  │C1-C5    │ MLCC Capacitor │ 100nF │ 0805 │ CL21B104 │ C1525  │
│  2  │C6,C7    │ MLCC Capacitor │ 10µF  │ 0805 │ CL21A106 │ C15850 │
│  3  │R1-R3    │ Resistor       │ 10kΩ  │ 0805 │ RC0805FR │ C17414 │
│  1  │U1       │ MCU            │ESP32  │Module│ESP32-WR  │ C82158 │
│  1  │U2       │ LDO Regulator  │ 3.3V  │SOT223│AMS1117  │ C6186  │
│  1  │J1       │ USB-C Connector│       │ SMD  │          │ C164810│
│  2  │D1,D2    │ LED            │ Green │ 0805 │          │ C2286  │
│  1  │SW1      │ Push Button    │       │ 6mm  │          │ C127509│
└─────┴─────────┴────────────────┴───────┴──────┴──────────┴────────┘

TIPS:
├── Include LCSC/Digikey/Mouser part numbers
├── Specify tolerance for resistors/caps (1% for R, X7R for C)
├── Note any critical specifications (voltage rating, etc.)
├── Keep "do not populate" (DNP) items separate
└── Cross-reference with your schematic BOM export

Chapter 11: Testing and Debugging PCBs

11.1 Pre-Power Checks

BEFORE CONNECTING POWER (check with multimeter):

1. CONTINUITY CHECK
   ├── Power to Ground: Should be OPEN (no short!)
   ├── Check all expected connections match schematic
   └── Check no unintended shorts between adjacent pins

2. RESISTANCE CHECK
   ├── Power rail to Ground: Should be >1kΩ (not a dead short)
   ├── Signal lines: Should not be shorted to power or ground
   └── USB data lines: Check D+/D- aren't shorted

3. VISUAL INSPECTION
   ├── Check for solder bridges
   ├── Verify component orientation (ICs, LEDs, caps)
   ├── Check for cold solder joints (dull, grainy appearance)
   └── Verify no missing components

11.2 Power-Up Procedure

SAFE POWER-UP SEQUENCE:

1. Current-limited power supply
   ├── Set voltage to expected level (e.g., 5V)
   ├── Set current limit LOW (50mA to start)
   └── If current hits limit → something is wrong!

2. Gradual bring-up
   ├── Connect power, observe current draw
   ├── Expected quiescent current? (e.g., 20mA for idle MCU)
   ├── Much higher? → Short circuit or wrong component
   ├── Zero current? → No power reaching board or open circuit
   
3. Verify voltages
   ├── Measure 3.3V rail: Should be 3.3V ±5%
   ├── Measure 5V rail: Should be 5V ±5%
   ├── Check MCU power pins
   └── Check reference voltages

4. Check clock
   ├── Oscilloscope on crystal pins
   ├── Should see clean sine wave at expected frequency
   └── No clock = MCU won't run

5. First communication
   ├── Try UART debug output
   ├── Try SWD/JTAG connection
   └── Blink an LED

11.3 Common Debug Techniques

DEBUGGING TOOLKIT:

├── Multimeter
│   ├── Voltage measurements (DC)
│   ├── Continuity testing
│   ├── Resistance measurement
│   └── Basic signal presence
│
├── Oscilloscope (game changer!)
│   ├── View signal waveforms
│   ├── Check timing and frequency
│   ├── Debug communication protocols
│   ├── Check power supply ripple
│   └── Budget: Rigol DS1054Z (~$400) is excellent
│
├── Logic Analyzer
│   ├── Capture digital signals
│   ├── Decode protocols (SPI, I2C, UART)
│   ├── Budget: Saleae Logic (~$200) or cheap USB ones (~$10)
│   └── Software: PulseView (free), Saleae Logic
│
├── USB Protocol Analyzer
│   ├── Wireshark + USBPcap
│   └── Dedicated hardware analyzers
│
├── Thermal Camera
│   ├── Find hot components (shorts, overcurrent)
│   ├── Budget: FLIR ONE (~$200) or seek thermal (~$250)
│   └── Alternative: IPA (alcohol) evaporation method
│
└── JTAG/SWD Debugger
    ├── ST-Link (for STM32) (~$20)
    ├── J-Link (universal) (~$50-600)
    ├── ESP-Prog (for ESP32) (~$10)
    └── Black Magic Probe (open source) (~$60)

11.4 Common Failures and Fixes

┌─────────────────────────┬──────────────────────────────────────────┐
│ Symptom                 │ Likely Cause                             │
├─────────────────────────┼──────────────────────────────────────────┤
│ No power / no current   │ Missing solder joint on power trace     │
│                         │ Wrong component value                    │
│                         │ PCB trace broken (manufacturing defect)  │
├─────────────────────────┼──────────────────────────────────────────┤
│ Excessive current draw  │ Solder bridge (short circuit)           │
│                         │ Component installed backwards            │
│                         │ Wrong component (wrong value)            │
│                         │ Damaged IC (ESD)                         │
├─────────────────────────┼──────────────────────────────────────────┤
│ MCU won't program       │ No clock (crystal not oscillating)      │
│                         │ Reset line stuck low                     │
│                         │ Wrong voltage on MCU                     │
│                         │ Boot pins in wrong state                 │
│                         │ SWD/JTAG pins swapped                    │
├─────────────────────────┼──────────────────────────────────────────┤
│ Intermittent behavior   │ Poor solder joint (reflow)               │
│                         │ Missing decoupling capacitors            │
│                         │ Signal integrity issue                   │
│                         │ Power supply instability                 │
├─────────────────────────┼──────────────────────────────────────────┤
│ Communication fails     │ TX/RX swapped (very common!)             │
│                         │ Baud rate mismatch                       │
│                         │ Missing pull-up resistors (I2C)          │
│                         │ Signal levels wrong (3.3V vs 5V)         │
│                         │ Wrong pin mapping in firmware            │
├─────────────────────────┼──────────────────────────────────────────┤
│ Board works, then dies  │ Overheating (check power dissipation)   │
│                         │ ESD damage                               │
│                         │ Capacitor wrong voltage rating           │
│                         │ Thermal cycling (solder fatigue)         │
└─────────────────────────┴──────────────────────────────────────────┘

11.5 Design for Test (DFT)

INCLUDE THESE IN YOUR DESIGN:

1. TEST POINTS
   ├── One for each power rail (VCC, 3.3V, GND)
   ├── One for each critical signal
   ├── UART TX/RX for debug console
   ├── SDA/SCL for I2C bus monitoring
   └── Size: 1mm pad for oscilloscope probe

2. DEBUG HEADERS
   ├── JTAG/SWD header (even just pin holes)
   ├── UART header
   └── I2C header (for adding external debug tools)

3. LED INDICATORS
   ├── Power LED (always on when powered)
   ├── Status LED (controlled by firmware)
   └── Communication activity LEDs

4. CURRENT MEASUREMENT
   ├── Series jumper or zero-ohm resistor on power rail
   ├── Remove jumper, insert ammeter
   └── Or use a current sense resistor

5. ACCESSIBLE SIGNALS
   ├── Don't bury all signals under BGA packages
   ├── Provide accessible pads for probing
   └── Consider bed-of-nails test fixture for production

Chapter 12: Tools of the Trade

12.1 PCB Design Software

FREE / OPEN SOURCE:

KiCad (RECOMMENDED FOR BEGINNERS)
├── Price: FREE (open source)
├── Platforms: Windows, macOS, Linux
├── Features: Full professional-grade toolset
├── 3D viewer: Built-in, excellent
├── Community: Large and growing
├── Pros: No limitations, huge library, active development
├── Cons: Steeper learning curve than some paid tools
└── Best for: Hobbyists, open-source hardware, learning
    Website: kicad.org

EasyEDA
├── Price: FREE (web-based)
├── Platform: Browser (or desktop app)
├── Features: Full schematic + PCB design
├── Integration: Direct JLCPCB/LCSC integration (huge benefit!)
├── Pros: Very easy to learn, instant BOM pricing
├── Cons: Cloud-based (privacy concerns), less powerful
└── Best for: Quick prototypes, JLCPCB assembly workflow
    Website: easyeda.com

FreeCAD + KiCad Plugin
├── For mechanical integration (enclosure design)
└── Complement KiCad with mechanical CAD

COMMERCIAL (EXPENSIVE but industry-standard):

Altium Designer
├── Price: $300+/month or $10,000+ license
├── Industry standard for professional PCB design
├── Best-in-class component management
└── Best for: Professional hardware engineers, companies

Autodesk Eagle
├── Price: Free tier (limited), $500+/year for full
├── Now integrated with Fusion 360
├── Popular in maker community
└── Best for: Hobbyists who want commercial tool

OrCAD / Allegro
├── Price: $$$$ (enterprise pricing)
├── Cadence's professional suite
└── Best for: Large companies, complex designs

RECOMMENDATION FOR SOFTWARE DEVELOPERS:
  Start with KiCad. It's free, powerful, and has no limitations.
  The skills transfer to any professional tool.

12.2 Essential Hardware Tools

BEGINNER TOOLKIT ($100-200):

├── Multimeter ($20-50)
│   ├── Uni-T UT61E or similar
│   └── Must have: Voltage, current, resistance, continuity
│
├── Soldering Station ($30-80)
│   ├── Hakko FX-888D ($100) — excellent
│   ├── KSGER T12 ($30-50) — great budget option
│   └── TS100/TS80 ($50-80) — portable
│
├── Solder Wire ($10)
│   ├── 0.8mm for through-hole
│   ├── 0.5mm for SMD
│   └── Lead-free (SAC305) or leaded (63/37) for easier learning
│
├── Flux ($10)
│   ├── No-clean flux pen (Kester 951)
│   └── Makes soldering 10× easier
│
├── Tweezers ($5-15)
│   ├── Fine-point ESD-safe tweezers
│   └── ESD-11 or similar curved tip
│
├── Magnification ($10-50)
│   ├── USB microscope (cheap, works with PC)
│   ├── Headband magnifier
│   └── Or a good desk lamp with magnifier
│
├── Wire/Tools ($10)
│   ├── Wire cutters
│   ├── Wire strippers
│   ├── Heat shrink tubing
│   └── Helping hands / PCB holder
│
└── Desoldering Tools ($10-30)
    ├── Solder wick (copper braid)
    ├── Desoldering pump (solder sucker)
    └── Flux (essential for rework)
INTERMEDIATE ADDITIONS ($200-500):

├── Oscilloscope ($300-500)
│   ├── Rigol DS1054Z — legendary for value
│   ├── Hantek DSO5102P
│   └── Budget: Hantek 6022BE USB scope ($60)
│
├── Logic Analyzer ($10-200)
│   ├── Saleae Logic 8 ($200) — best
│   ├── FX2-based USB clones ($10) — functional
│   └── Use with PulseView (free) or Saleae software
│
├── Hot Air Station ($30-80)
│   ├── For SMD rework, QFN/BGA work
│   └── Quick 861DW or Atten ST-862D
│
├── Bench Power Supply ($50-150)
│   ├── Adjustable voltage and current
│   ├── Korad KA3005D ($60) — popular
│   └── Essential for safe board bring-up
│
└── USB Protocol Analyzer ($200+)
    ├── Beagle USB 480 ($400)
    └── Or use software-based analysis

12.3 Simulation Tools

CIRCUIT SIMULATION:

LTspice (Free, by Analog Devices)
├── Analog circuit simulation
├── Verify voltage regulator circuits
├── Check filter responses
├── Run transient analysis
└── Download: analog.com/en/design-center/

KiCad + ngspice
├── Built-in SPICE simulation in KiCad
├── Basic but functional
└── Good for learning

Online Simulators:
├── Falstad Circuit Simulator (falstad.com/circuit)
│   └── Visual, interactive, great for learning
├── EveryCircuit (app)
│   └── Animated current flow visualization
└── CircuitLab (circuitlab.com)
    └── Browser-based, professional features

IMPEDANCE CALCULATORS:
├── Saturn PCB Toolkit (FREE, excellent)
├── KiCad's built-in calculator
├── Altium's built-in calculator
└── Wadsworth's PCB Toolkit

Chapter 13: Version Control and Collaboration for PCB

13.1 Git for PCB Design (Yes, Really!)

WHY USE GIT FOR PCB?

├── Track every change (just like code)
├── Revert to previous designs (hardware bugs happen!)
├── Collaborate with team members
├── Branch for experimental designs
└── Document changes in commit messages

Setting Up a PCB Git Repository

.gitignore for KiCad:
─────────────────────────────────────
# KiCad backup files
*-backups/
*~
*.bak

# KiCad generated files (re-generated from source)
*.kicad_prl
fp-info-cache

# Netlist files (regenerated from schematic)
*.net

# 3D cache files
*.3dshapes/

# OS files
.DS_Store
Thumbs.db

# BOM output (can be regenerated)
*.csv
*.xml
─────────────────────────────────────

.gitignore for Eagle:
─────────────────────────────────────
*.b#*
*.s#*
*.l#*
epp.lib
─────────────────────────────────────

.gitattributes for KiCad (CRITICAL):
─────────────────────────────────────
# KiCad files are mostly text but have some binary content
*.kicad_sch  text
*.kicad_pcb  text
*.kicad_pro  text
─────────────────────────────────────

Commit Message Convention for PCB

Format: <type>(<scope>): <description>

Types:
  feat:     New feature (new circuit, new component)
  fix:      Bug fix (fixing a DRC error, correcting a connection)
  refactor: Change without functional impact (reorganizing layout)
  docs:     Documentation updates
  chore:    Library updates, file cleanup

Examples:
  feat(power): add 3.3V LDO regulator circuit
  fix(usb): correct D+/D- pin assignment on USB connector
  refactor(layout): reorganize MCU section for shorter traces
  docs(schematic): add notes about crystal load capacitor selection
  chore(library): update footprint for ESP32-WROOM module
  
  BREAKING CHANGE: Changed pin mapping for SPI bus

13.2 Design Review Process

PCB DESIGN REVIEW CHECKLIST:

PRE-REVIEW (Author):
├── All DRC errors resolved
├── All ERC errors resolved  
├── BOM complete and verified
├── 3D model reviewed (no physical conflicts)
├── All component footprints verified against datasheets
└── Design notes added for non-obvious decisions

REVIEW ITEMS:

Schematic Review:
├── Power supply: Correct voltages? Sufficient current capacity?
├── Decoupling: Every IC has local decoupling?
├── Pull-ups/pull-downs: All required ones present?
├── Signal levels: Compatible between all ICs? (3.3V vs 5V)
├── Pin assignments: Correct? (Cross-reference with firmware)
├── ESD protection: On external connectors?
├── Reset circuit: Proper pull-up and filter cap?
├── Boot pins: In correct state for normal operation?
└── All unused pins: Properly terminated?

Layout Review:
├── Component placement: Logical grouping?
├── Ground plane: Solid and unbroken?
├── Power traces: Wide enough for current?
├── Critical signals: Short and properly routed?
├── Differential pairs: Matched length and spacing?
├── Crystal: Close to MCU, proper load caps?
├── Decoupling caps: As close to IC as possible?
├── Thermal relief: On power components?
├── Silkscreen: Clear and not over pads?
├── Board outline: Correct dimensions?
├── Mounting holes: Correct position and size?
└── Fiducials: Present for assembly?

13.3 Documentation Standards

ESSENTIAL DOCUMENTATION:

1. README.md
   ├── Project description
   ├── Screenshot of PCB (3D render)
   ├── Block diagram
   ├── Key specifications
   ├── Known issues / errata
   └── Build/assembly instructions

2. SCHEMATIC PDF
   ├── Exported from EDA tool
   ├── Multi-page, readable at full zoom
   └── Includes title block with revision info

3. BOM (Bill of Materials)
   ├── Complete part list with quantities
   ├── Part numbers (LCSC, Digikey, Mouser)
   ├── Alternatives where possible
   └── Cost estimate

4. ASSEMBLY DRAWING
   ├── Component placement diagram
   ├── Special assembly instructions
   ├── Polarity indicators
   └── Hand-solder vs. reflow notes

5. ERATA / KNOWN ISSUES
   ├── Every board revision has issues
   ├── Document them clearly
   ├── Include workarounds
   └── This is your "bug tracker" for hardware

6. CHANGELOG
   ├── What changed between revisions
   ├── Why the change was made
   └── Like a CHANGELOG.md for your PCB

Chapter 14: Common Mistakes and How to Avoid Them

14.1 Schematic Mistakes

MISTAKE 1: Missing Decoupling Capacitors
Problem: Board resets randomly, communication errors
Fix: Add 100nF ceramic cap on EVERY VCC pin of EVERY IC
     Place as close as physically possible to the pin

MISTAKE 2: Swapped TX/RX
Problem: UART doesn't work, can't communicate with MCU
Fix: TX on one device connects to RX on the other
     Draw it out: Device A.TX → Device B.RX
                  Device A.RX → Device B.TX

MISTAKE 3: Wrong Pull-up/Pull-down
Problem: I2C doesn't work, MCU boots into wrong mode
Fix: I2C ALWAYS needs pull-ups (2.2kΩ-4.7kΩ to VCC)
     Check MCU datasheet for boot pin requirements

MISTAKE 4: Missing Current-Limiting Resistor on LED
Problem: LED burns out immediately, or worse, damages GPIO pin
Fix: ALWAYS use a resistor with LEDs
     R = (V_supply - V_LED) / I_LED

MISTAKE 5: No ESD Protection on External Connectors
Problem: Board dies when user touches USB port
Fix: Add TVS diodes (e.g., USBLC6-2SC6) on external connections

MISTAKE 6: Wrong Crystal Load Capacitors
Problem: MCU doesn't start, clock is unreliable
Fix: Check crystal datasheet for required load capacitance
     Typical: 12-22pF per cap

MISTAKE 7: Power Supply Instability
Problem: Voltage regulator oscillates, output is noisy
Fix: READ THE DATASHEET. Use the exact capacitor values
     and types recommended. Ceramic caps, not electrolytic
     (for LDO output caps — some LDOs specifically require ESR)

14.2 Layout Mistakes

MISTAKE 1: Broken Ground Plane
Problem: EMI issues, analog measurements noisy
Fix: Keep ground plane solid and unbroken
     Route signals on layers ABOVE the ground plane
     Use stitching vias liberally

MISTAKE 2: Traces Too Thin for Current
Problem: Trace burns out under load
Fix: Use trace width calculator for any trace carrying >100mA
     Power traces: minimum 20 mil for low current
     Use copper pours for high current paths

MISTAKE 3: Decoupling Caps Too Far from IC
Problem: High-frequency noise not filtered
Fix: Caps should be within 2-3mm of the IC power pin
     Via directly to ground plane from cap

MISTAKE 4: Ignoring Manufacturer's Design Rules
Problem: Board can't be manufactured, or has defects
Fix: Download your manufacturer's capabilities document
     Set DRC rules to match BEFORE you start routing

MISTAKE 5: Poor Component Placement
Problem: Long traces, routing nightmares, poor signal integrity
Fix: Spend 50% of your layout time on PLACEMENT
     Good placement = easy routing

MISTAKE 6: No Thermal Relief on Pours
Problem: Components are impossible to hand-solder
Fix: Use thermal relief spokes on pads connected to large copper areas
     (Most EDA tools have a setting for this)

MISTAKE 7: Forgetting Mechanical Constraints
Problem: Board doesn't fit in enclosure, mounting holes wrong
Fix: Import your enclosure 3D model into KiCad
     Check clearances with the 3D viewer
     Add mounting holes early in design

MISTAKE 8: Silkscreen Over Pads
Problem: Poor solder joints, can't read labels
Fix: Check DRC for silkscreen violations
     Move text that overlaps pads

MISTAKE 9: No Fiducials for Assembly
Problem: Pick-and-place machine can't align components
Fix: Add at least 2 fiducial marks (3 preferred)
     1mm bare copper circle with 3mm clearance

MISTAKE 10: Wrong Board Outline
Problem: Board doesn't fit, mounting holes don't align
Fix: Double-check dimensions before ordering!
     Print the design on paper at 1:1 scale to verify

14.3 Manufacturing Mistakes

MISTAKE 1: Ordering Without Reviewing Gerbers
Problem: Missing layers, wrong board outline, silkscreen errors
Fix: ALWAYS view Gerbers in an external viewer before uploading
     Check every layer individually

MISTAKE 2: Wrong Surface Finish
Problem: Can't solder fine-pitch components
Fix: HASL: Cheapest, fine for >0.5mm pitch (good for beginners)
     ENIG: Better for fine pitch, flat surface, more expensive
     OSP: Budget option, limited shelf life

MISTAKE 3: Not Considering Assembly Constraints
Problem: Hand-soldering 200 components is miserable
Fix: Use JLCPCB assembly or similar service
     Design with standard components (0805, SOIC)
     Minimize unique component count

MISTAKE 4: Skipping the Prototype
Problem: Ordering 100 boards with a design error
Fix: ALWAYS order 3-5 prototypes first
     Test thoroughly before committing to production quantity

Chapter 15: Real-World Project Walkthrough

Project: ESP32 Development Board

Let's design a complete PCB from scratch:

15.1 Requirements

PROJECT: Custom ESP32 Dev Board

Requirements:
├── ESP32-WROOM-32 module (WiFi + Bluetooth)
├── USB-C connector for power and programming
├── USB-to-UART bridge (CP2102N)
├── 3.3V LDO voltage regulator
├── 2x LED (power + user)
├── Reset and Boot buttons
├── Exposed GPIO header (2.54mm pitch)
├── I2C sensor header
├── Battery connector (JST-PH 2.0)
├── LiPo charging circuit (MCP73831)
├── 4-layer PCB, 50mm × 40mm
└── Must fit in a 3D-printed enclosure

15.2 System Architecture

                  USB-C Connector
                       │
                  ┌────┴────┐
                  │ CP2102N │
                  │ USB-UART│
                  │         │
                  │ TXD ────┤──────────────────────┐
                  │ RXD ────┤──────────────────┐   │
                  └─────────┘                  │   │
                                               │   │
    ┌──────────────┐                  ┌────────┴───┴────────┐
    │ JST Connector│                  │    ESP32-WROOM-32   │
    │ (LiPo Batt)  │                  │                     │
    └──────┬───────┘                  │  EN ──[R]──┬──[SW1]│
           │                          │            │ [C]  │
    ┌──────┴───────┐                  │  IO0 ──[R]─┬──[SW2]│
    │ MCP73831     │                  │            │ [C]  │
    │ LiPo Charger │                  │  TX ───────┘      │
    │              │                  │  RX ──────────────┘│
    │ VBAT─────┐   │                  │                     │
    └──────────┼───┘                  │  IO2 ────[R]──[LED]│
               │                      │  IO4 ──── Header   │
    ┌──────────┼───┐                  │  IO5 ──── Header   │
    │ AMS1117  │   │                  │  ... more GPIOs    │
    │ 3.3V LDO │   │                  │                     │
    │          │   │                  │  SDA ──── I2C HDR  │
    │ IN ←─VBAT│   │                  │  SCL ──── I2C HDR  │
    │ OUT──3.3V│   │                  └─────────────────────┘
    └──────────┘

15.3 Schematic Design

SHEET 1: Power Supply
──────────────────────

USB-C VBUS (5V) ──┬──[FB]──┬── MCP73831 VDD (battery charger)
                   │        │
                  [C1]     [C2]    100nF + 10µF
                   │        │
                  GND      GND

MCP73831:
  VDD  ← 5V from USB
  VBAT → Battery + charging
  STAT → [R] → LED (charging indicator)
  PROG → [R] 2kΩ (sets charge current to 500mA)
  VSS  → GND

AMS1117-3.3:
  IN  ← VBAT (from battery or USB) through Schottky diode
  OUT → 3.3V rail
  GND → GND
  [C_in] 10µF ceramic
  [C_out] 10µF ceramic + 100nF

3.3V Rail:
  ├── ESP32 VCC
  ├── CP2102N VDD
  ├── Sensor header VCC
  └── Decoupling: 10µF bulk + 100nF per IC


SHEET 2: ESP32 Circuit
──────────────────────

ESP32-WROOM-32:
  3V3 ← 3.3V rail + [C] 100nF decoupling (per VCC pin)
  EN  ← [R] 10kΩ pull-up to 3.3V + [C] 100nF to GND + [SW] to GND (Reset)
  IO0 ← [R] 10kΩ pull-up to 3.3V + [SW] to GND (Boot button)
  IO2 ← [R] 330Ω → [LED] → GND (User LED)
  TX  → Header + CP2102N RXD
  RX  ← Header + CP2102N TXD
  SDA → IO21 + [R] 4.7kΩ pull-up to 3.3V (I2C)
  SCL → IO22 + [R] 4.7kΩ pull-up to 3.3V (I2C)
  GND → Multiple GND connections (all ground pads)
  
GPIO Header:
  Break out: IO4, IO5, IO12, IO13, IO14, IO15, IO16, IO17, IO18, IO19, IO21, IO22, IO23, IO25, IO26, IO27, IO32, IO33, IO34, IO35
  Plus: 3.3V, GND, 5V (from USB)

SHEET 3: USB-UART Bridge
─────────────────────────

CP2102N:
  VDD  ← 3.3V
  VIO  ← 3.3V (I/O voltage reference)
  D+   ← USB-C D+ (via 22Ω series resistor)
  D-   ← USB-C D- (via 22Ω series resistor)
  TXD  → ESP32 RX
  RXD  ← ESP32 TX
  RST  ← 3.3V (pulled high)
  GND  → GND
  [C] 100nF on VDD, VIO pins
  [C] 4.7µF on VDD (per datasheet)
  
  SUSPEND pin: leave unconnected or pull high
  Suspend indicator: optional LED

SHEET 4: Sensor / Expansion Headers
────────────────────────────────────

I2C Header (4-pin):
  Pin 1: 3.3V
  Pin 2: SDA (IO21)
  Pin 3: SCL (IO22)
  Pin 4: GND

GPIO Header (2×20 pin):
  Even pins: GND (every other pin for easy ground access)
  Odd pins: GPIO signals + 3.3V + 5V

Reset Button:
  ┌────┐
  │    │  C100nF ─── GND
  │ SW │──┤
  │    │  R10kΩ ─── 3.3V
  └────┘
      └── ESP32 EN pin

15.4 PCB Layout

LAYOUT PLAN (50mm × 40mm, 4-layer):

┌──────────────────────────────────────────────────┐
│ [USB-C]  [CP2102N]  [Reset] [Boot]              │
│  J1       U2         SW1    SW2                  │
│                                                  │
│              ┌─────────────────┐                 │
│   [C4][C5]   │                 │    [LED1]       │
│              │   ESP32-WROOM   │    [LED2]       │
│              │                 │                 │
│              │     MODULE      │    [R LED]      │
│              │                 │                 │
│              └─────────────────┘                 │
│                                                  │
│  [MCP73831]         [AMS1117]                    │
│   U3                 U4                         │
│  [JST Battery]                                    │
│                                                  │
│  ┌───── GPIO Header ──────┐  ┌── I2C Header ──┐│
│  │  1  3  5  7  9 11 ...  │  │  VCC SDA SCL GND││
│  │  2  4  6  8 10 12 ...  │  └─────────────────┘│
│  └────────────────────────┘                      │
│                                                  │
│  Fiducial ●                           ● Fiducial │
│  Mount ○                                    ○ Mount│
└──────────────────────────────────────────────────┘

ROUTING PRIORITY:
1. GND plane: Solid on Layer 2 (inner 1)
2. 3.3V plane: Layer 3 (inner 2)
3. USB D+/D-: Matched length differential pair on Layer 1
4. UART TX/RX: Short direct routes
5. I2C: Short routes, near ground reference
6. GPIO: Route to header, less critical
7. Power: Wide traces or via to planes

15.5 Final Checklist Before Ordering

□ All DRC errors: 0
□ All ERC warnings: Reviewed and acceptable
□ BOM verified: All parts in stock at LCSC
□ 3D model reviewed: No physical conflicts
□ Layer stack-up confirmed: 4-layer, 1.6mm
□ Board dimensions: 50mm × 40mm ±0.1mm
□ Mounting holes: 4× M2 at corners
□ USB connector: Accessible from board edge
□ Silkscreen: All labels readable, no pad overlap
□ Gerbers: Reviewed in external viewer
□ BOM + CPL files: Generated for assembly
□ Design files: Committed to Git with descriptive message
□ Paper printout: Checked physical fit (1:1 scale)
□ Total component count: Under JLCPCB assembly limit

Chapter 16: Resources and Next Steps

16.1 Learning Resources

BEGINNER:

Books:
├── "Getting Started in Electronics" by Forrest Mims III
│   └── Classic beginner book, hand-drawn, wonderful
├── "The Art of Electronics" by Horowitz & Hill
│   └── THE reference book for electronics (3rd edition)
├── "PCB Design Tutorial" by Altium (free PDF)
│   └── Comprehensive introduction
└── "Make: Electronics" by Charles Platt
    └── Hands-on learning, great projects

YouTube Channels:
├── GreatScott! — Beginner-friendly projects
├── EEVblog — Deep technical content, equipment reviews
├── Ben Eater — Breadboard computers, incredible teaching
├── Robert Feranec — PCB layout expert, KiCad tutorials
├── Phil's Lab — PCB design tutorials, STM32 projects
├── Contextual Electronics — KiCad-specific courses
└── EEVblog #900 series — PCB design playlist

Websites:
├── learn.sparkfun.com — Excellent tutorials
├── learn.adafruit.com — Great for Adafruit products
├── electronics.stackexchange.com — Q&A
├── forums.kicad.info — KiCad community help
└── hackaday.io — Project inspiration
INTERMEDIATE:

Books:
├── "High-Speed Digital Design" by Howard Johnson
│   └── THE signal integrity bible
├── "EMC and the Printed Circuit Board" by Mark Montrose
│   └── Understanding EMI from a PCB perspective
├── "Signal and Power Integrity" by Eric Bogatin
│   └── Modern approach to SI/PI
└── "PCB Designers Field Guide" by Mike Creager
    └── Practical, from-the-trenches advice

Online Courses:
├── Robert Feranec's "Learn to Design Your Own Boards" (Udemy)
├── Phil's Lab YouTube series on STM32 PCB design
├── Contextual Electronics (subscription)
└── Altium Academy (free, Altium-focused)

16.2 Project Ideas (Progressive Difficulty)

LEVEL 1: First PCB
├── LED blinky board (ATtiny85 + LED + button)
├── USB power supply breakout board
├── Sensor breakout board (BME280, MPU6050)
└── Simple Arduino shield

LEVEL 2: Intermediate
├── ESP32 development board (like our walkthrough!)
├── Nixie tube driver board
├── Audio amplifier board (LM386)
├── Motor driver board (H-bridge)
└── Battery charger + power bank

LEVEL 3: Advanced
├── Custom mechanical keyboard PCB
├── FPGA development board
├── USB-C PD (Power Delivery) board
├── SDR (Software Defined Radio) receiver
├── Multi-sensor environmental monitor
└── Custom Raspberry Pi HAT

LEVEL 4: Expert
├── DDR3/DDR4 memory interface board
├── High-speed USB 3.0 device
├── Ethernet switch board
├── RF transmitter/receiver (2.4GHz)
└── Multi-processor system with bus architecture

16.3 Quick Reference Card

╔═══════════════════════════════════════════════════════════╗
║              PCB DESIGN QUICK REFERENCE                   ║
╠═══════════════════════════════════════════════════════════╣
║                                                           ║
║  OHM'S LAW:           V = I × R                           ║
║  POWER:               P = V × I                           ║
║  VOLTAGE DIVIDER:     Vout = Vin × R2/(R1+R2)            ║
║  LED RESISTOR:        R = (Vcc - Vf) / I_led             ║
║                                                           ║
║  DECOUPLING:          100nF ceramic at EVERY VCC pin      ║
║  I2C PULL-UPS:        2.2kΩ - 4.7kΩ to VCC              ║
║  UART:                TX→RX, RX→TX (always crossover)    ║
║  USB DIFF IMPEDANCE:  90Ω differential                   ║
║                                                           ║
║  TRACE WIDTH:         6mil signal, 20mil power minimum   ║
║  MIN CLEARANCE:       6mil (check your fab!)             ║
║  VIA:                 0.3mm drill, 0.6mm pad typical     ║
║  GROUND:              Keep solid, keep close, keep whole  ║
║                                                           ║
║  BEFORE POWER-UP:     Check shorts, check polarity,      ║
║                       current-limit your supply!          ║
║                                                           ║
║  MANUFACTURER SPECS:  Always check BEFORE designing!      ║
║  PROTOTYPE FIRST:     Never go straight to production!    ║
║                                                           ║
╚═══════════════════════════════════════════════════════════╝

16.4 Final Words

Welcome to the world of PCB design, fellow developer!

Remember:
├── Your first board WILL have mistakes. That's normal. Rev A is always 
│   a learning experience. Even veteran hardware engineers expect a Rev B.
│
├── The gap between software and hardware is smaller than you think.
│   The same principles apply: modularity, testing, documentation,
│   iteration, and learning from mistakes.
│
├── Start simple. An LED blinky board that YOU designed and 
│   manufactured is infinitely more satisfying than an Arduino shield.
│
├── Join communities. The electronics community is incredibly helpful.
│   Reddit (r/PrintedCircuitBoard, r/AskElectronics),
│   EEVblog forums, and KiCad forums are all welcoming.
│
├── The best way to learn is to BUILD something.
│   Pick a project, design a board, order it, solder it, debug it.
│   The iteration cycle teaches more than any book.
│
└── You now have the knowledge to design a real, functional PCB.
    The copper is waiting. Go create something amazing!

This guide is a living document. PCB design is a deep field — this covers the fundamentals and gets you to a working board. Each topic has depths that take years to fully explore, but the beauty of being a software developer is that you already know how to learn, iterate, and debug. The same mindset applies here.

Happy designing! 🔧⚡


Version: 1.0 Last Updated: 2025 License: Feel free to share and adapt with attribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment