Building the Spark Analyzer: A USB-C PD Development Tool

How I designed and built an ESP32-powered USB-C Power Delivery analyzer with programmable power supply capabilities

Jason Too
hardware
esp32
usb-c
power-delivery
Building the Spark Analyzer: A USB-C PD Development Tool

Building the Spark Analyzer

The Spark Analyzer started as a simple need: I wanted a tool to debug USB-C Power Delivery negotiations in my projects. What began as a weekend project evolved into a full-featured USB-C PD analyzer and programmable power supply.

The Challenge

USB-C Power Delivery is powerful but complex. When things don't work, it's hard to debug:

  • What voltages are being negotiated?
  • Is the device requesting the right power profile?
  • Are the PD packets being sent correctly?

Commercial USB-C analyzers exist, but they're expensive ($200+) and often lack programmability.

The Solution

I designed Spark Analyzer around the ESP32-C3 microcontroller with these key features:

Hardware Design

Core Components:

  • ESP32-C3 for processing and WiFi/BLE
  • USB-C PD controller for protocol handling
  • High-precision ADC for voltage/current monitoring
  • Buck-boost converter for programmable output

Power Path:

USB-C Input → PD Controller → Buck-Boost → Output
                    ↓
              ESP32-C3 (Monitoring & Control)

Key Features

  1. USB-C PD Analysis

    • Real-time voltage/current monitoring
    • PD packet capture and logging
    • Support for PD 2.0 and 3.0 with PPS
  2. Programmable Power Supply

    • Voltage: 3.3V - 21V (20mV resolution)
    • Current: Up to 3A (50mA resolution)
    • Controlled via WiFi/BLE
  3. Wireless Control

    • Web interface for real-time monitoring
    • REST API for automation
    • Mobile app integration

Development Process

PCB Design

I used KiCad for the schematic and PCB layout. Key considerations:

  • Signal Integrity: USB-C data lines require careful routing with controlled impedance
  • Power Management: Separate power domains for analog and digital circuits
  • EMI: Added ferrite beads and proper grounding planes

Firmware Architecture

The firmware is built on ESP-IDF with these modules:

// Main components
- USB PD Protocol Handler
- ADC Sampling Engine
- Web Server (HTTP/WebSocket)
- BLE GATT Server
- Data Logger

Challenges & Solutions

Challenge 1: PD Timing USB-C PD has strict timing requirements (< 15ms response). Solution: Used FreeRTOS with dedicated task priorities.

Challenge 2: Current Sensing High-side current sensing needed amplification with low offset. Solution: Implemented auto-zeroing calibration on startup.

Challenge 3: WiFi Interference WiFi caused noise on ADC readings. Solution: Added RC filters and measured during WiFi idle periods.

Results

The final product exceeded expectations:

  • Accurate voltage measurement: ±10mV
  • Current measurement: ±20mA
  • PD negotiation success rate: 99.8%
  • WiFi latency: < 50ms

What's Next

Future improvements planned:

  • USB-C cable e-marker reading
  • Power profile presets
  • Integration with oscilloscope triggers
  • Machine learning for anomaly detection

Open Source

The Spark Analyzer is open source! Check out:

Conclusion

Building the Spark Analyzer was a journey in solving real-world problems with embedded systems. It's now an essential tool in my lab, and I hope it helps others too.

Have questions about the design? Want to build your own? Drop a comment or reach out!


Interested in similar projects? Check out my other builds in the Projects section.