

H Bridge PCB
The project consists of two main components: 1. HBridgePCBDesign — KiCad PCB layout and schematic. 2. HBridgePCBCode — Firmware for the ESP32 controller.
- Size
- 110.3 × 110.3 mm
- Copper layers
- 2
- Thickness
- 1.6 mm
- Parts
- 124
- Nets
- 95
- Pads
- 392
- Tracks, vias
- 962, 160
- Pours
- 4
- Routed
- Yes
- KiCad
- KiCad 9.0 (file 20241229)
- Created
- 31 Jan 2025
- Updated
- 15 Dec 2025
Overview
H Bridge PCB is an open-source printed circuit board by reinto1234, from the reinto1234/H_Bridge_PCB repository on GitHub. It is a 2-layer board of 110.3 × 110.3 mm with 124 parts on 95 nets, routed with 962 tracks and 160 vias.
It is built around the CH340C, ESP32-WROOM-32 and NXJ1S0303MC-R13, with the IR2110S-MNS, AMC1306M25DWVR and L7812ABD2T-TR among its other parts. Its parts include 36 capacitors, 30 resistors, 16 diodes, 11 connectors and 10 ICs. It belongs with the interfaces and adapters boards and the ESP32 boards of this library.
Main components
12CH340C
SOP-16-20℃~+70℃ 2Mbps 3.3V、5V 50uA 7mA Transceiver USB 2.0 SOP-16 USB Converters ROHSWCH (Nanjing Qinheng Microelectronics)USB ConvertersESP32-WROOM-32
SMD,18x25.5mm-40℃~+85℃ -98dBm 2.4GHz 2.7V~3.6V 20dBm Bluetooth4.2 ESP32-DOWDQ6 UART、SDIO、SPI、I2C、GPIO、PWM、ADC、DAC SMD,25.5x18mm WiFi Modules ROHSEspressif SystemsWiFi ModulesNXJ1S0303MC-R13
SMD-5P,13.7x10.5mmIsolated Power ModulesMurataIR2110S-MNS
SOIC-16-300milGate DriversMinosAMC1306M25DWVR
SOIC-8-300mil-40℃~+125℃ 1 16 1LSB 3V~5.5V 78000Hz 78kHz Serial SOIC-8-300mil ADCs/DACs - Special Purpose ROHSTexas InstrumentsADCs/DACs - Special PurposeL7812ABD2T-TR
TO-263-2-40℃~+125℃@(Tj) 1 1.5A 12V 2V@(1A) 35V 4.4mA 60dB@(120Hz) Fixed Over Current Protection、Short Circuit Protection、Thermal shutdown Positive TO-263-2 Voltage Regulators - Linear, Low Drop Out (LDO) Regulators ROHSSTMicroelectronicsVoltage Regulators - Linear, Low Drop Out (LDO) RegulatorsTSW-102-15-T-S
插件,P=2.54mmPin HeadersSamtecS210
SOD-123-55℃~+150℃ 1 Independent 100V 100uA@5V 2A 40A 850mV@2A SOD-123 Schottky Diodes ROHSYangzhou Yangjie Electronic TechnologySchottky DiodesFSV2060L
TO-277-3-55℃~+150℃ 1 Independent 20A 320A 320uA@60V 600mV@20A 60V TO-277-3 Schottky Diodes ROHSonsemiSchottky DiodesIPD90N10S4L06ATMA1
TO-252-55℃~+175℃ 1 N-channel 100V 136W 2.1V 300pF 6.25nF 6.6mΩ@10V 90A TO-252 MOSFETs ROHSInfineon TechnologiesMOSFETsIRLB4030PBF
TO-220AB-55℃~+175℃ 1 N-channel 100V 11.36nF 130nC@4.5V 180A 2.5V 290pF 370W 4.5mΩ@4.5V 670pF N-Channel TO-220AB MOSFETs ROHSInfineon TechnologiesMOSFETsBC817
SOT-231 NPN 100nA 150MHz 300mW 40 45V 500mA 5V 700mV NPN SOT-23 Bipolar (BJT) ROHSShikuesBipolar (BJT)
README
README.mdH-Bridge PCB Project
Project Description
This project involves the design and implementation of an educational single-phase H-Bridge inverter controlled by an Espressif ESP32.
The system demonstrates bipolar sinusoidal PWM (SPWM) operation with closed-loop VRMS amplitude control and a browser-based interface for monitoring and control.
The H-Bridge can drive loads with the following ratings:
- Input Voltage: 24 V
- Input Current: up to 10 A
- Power: ≈ 240 W
Features
- Fixed switching frequency: 35 kHz
- Fixed output frequency: 50 Hz
- Bipolar SPWM modulation (only)
- Closed-loop VRMS control using PI regulation
- Web-based UI (HTTP + WebSocket) for control and telemetry
- Input/Output power measurement
- Overcurrent protection using INA228 (auto driver shutdown + UI fault latch)
The project consists of two main components:
- H_Bridge_PCB_Design — KiCad PCB layout and schematic.
- H_Bridge_PCB_Code — Firmware for the ESP32 controller.
Directory Structure
Directory Structure
H_Bridge_PCB_Project/
├── H_Bridge_PCB_Design/ # KiCad design files
├── H_Bridge_PCB_Code/ # ESP32 firmware
│ ├── include/ # Header files
│ │ ├── Controller.h
│ │ ├── I2C.h
│ │ ├── Input_meas.h
│ │ ├── mutexdefinitions.h
│ │ ├── Output_meas.h
│ │ ├── PWM.h
│ │ ├── spi_sampler.h
│ │ ├── Tasks.h
│ │ └── webserver.h
│ │
│ ├── src/ # Source files
│ │ ├── Controller.cpp
│ │ ├── I2C.cpp
│ │ ├── Input_meas.cpp
│ │ ├── Output_meas.cpp
│ │ ├── PWM.cpp
│ │ ├── spi_sampler.cpp
│ │ ├── Tasks.cpp
│ │ ├── webserver.cpp
│ │ └── main.cppRequirements
Hardware:
- PCB based on KiCad design
- 24 V DC power supply (≥ 10 A)
- Resistive or inductive load (max ≈ 240 W)
- Gate drivers with integrated dead-time
- INA228 current/voltage monitor for input sensing
Software:
- KiCad — PCB design
- PlatformIO — firmware build
- VS Code — recommended IDE
Webserver
The ESP32 provides a built-in Wi-Fi access point and hosts a web-based interface for control and measurement visualization.
Connect to WLAN Access Point
- SSID:
H_Bridge_Control - Password:
12345678
Open the web interface:
Functions:
- Start/Stop the inverter
- Set VRMS target
- Display live telemetry (Vin, Iin, VRMS, IRMS, PF, P, Q, f)
- View and acknowledge overcurrent faults
Code
The firmware is implemented in C++ (Arduino / FreeRTOS).
The web interface is built with HTML, JavaScript, and CSS.
Flowchart

Code Documentation
Brief overview of the most relevant components.
Inverter Implementation (PWM.cpp)
Implements the real-time control of the full-bridge inverter:
- startInverter() — Initializes and enables PWM output.
- stopInverter() — Stops PWM and resets inverter state.
- generateSPWM() — Produces bipolar SPWM using a sine table.
- begin() — Configures LEDC channels, frequency, and timers.
- getMeasurements() — Retrieves latest measurement snapshot.
- computePI() — Executes PI algorithm to maintain VRMS target.
- loop() — Runs the inverter control logic at fixed timing intervals.
Controller Implementation (Controller.cpp)
Implements the PI controller used to regulate the inverter’s RMS output voltage:
- PIController() — Initializes PI gains, integrator state, limits, and VRMS target.
- ControlRMS() — Computes RMS error and updates the global Q10 amplitude factor atomically.
- compute() — Executes PI algorithm with anti-windup and output clamping to min/max limits.
- g_amp_q10 — Global Q10-formatted amplitude value used by the SPWM stage.
I²C Bus Setup (I2C.cpp)
Implements the I²C interface for the INA228 current/voltage sensor:
- I2CINA — Dedicated I²C bus instance (port 0) used by the input measurement subsystem.
Input Measurement (Input_meas.cpp)
Implements DC input voltage, current, and power measurement using INA228:
- init() — Initializes I²C bus, scans for devices, configures INA228, and sets averaging/timing.
- init1() — Lightweight I²C initialization helper without full sensor setup.
- configure_overcurrent_alert_only() — Configures INA228 alert registers for shunt overcurrent shutdown.
- getVoltage() — Reads and returns the DC input voltage in volts.
- getCurrent() — Reads and returns the shunt current in amperes.
- getPower() — Reads and returns the input power in watts with simple error rejection.
- measurementall() — Updates the shared input measurement buffer (voltage, current, power) in a mutex-protected way and returns it.
- scanI2C() — Scans the I²C bus, prints found devices, and restarts the bus if no device is detected.
Main Application (main.cpp)
Implements system bring-up and FreeRTOS task orchestration:
- setup() — Initializes serial logging, mutexes, input measurement, Wi-Fi AP, webserver, SPI measurement engines, safety pins, and the overcurrent interrupt; then creates all application tasks.
- loop() — Empty main loop; periodically yields since all logic is implemented in FreeRTOS tasks.
- Task handles — Stores references to sampler, analyzer, WebSocket, controller, printer, and emergency stop tasks for debugging/management.
Mutex Definitions (mutexdefinitions.cpp)
Implements globally shared FreeRTOS mutexes for synchronization:
- inverterMutex — Protects access to the inverter state and control functions.
- measurementinMutex — Protects shared input measurement buffer.
- measurementoutMutex — Protects shared output measurement structures.
- measurementSpiMutex — Protects SPI-related measurement buffers and state.
Output Measurement (Output_meas.cpp)
Implements decimation, CIC filtering, RMS, and frequency analysis for AMC1306 bitstreams:
- buildByteCicLut() — Precomputes CIC integrator/differentiator contributions for all 8-bit patterns.
- OutputMeasurements() — Configures OSR, full-scale voltage, buffer sizes, and initial bit rate.
- init() — Allocates decimation ring buffers, analysis windows, and period buffers (with PSRAM support) and creates a snapshot mutex.
- copyRecentWindowWithStats() — Copies the newest segment from the decimation ring and computes mean, min, and max.
- findLastTwoRisingZcHyst() — Detects the last two rising zero-crossings with hysteresis to define one AC period.
- computeRmsOnePeriodExact() — Computes exact RMS over one period using piecewise linear interpolation.
- processRxBytesAndUpdateBitrate() — Processes raw SPI bytes, runs CIC pipeline, generates decimated voltage samples, and updates effective bit rate.
- analyzeStep() — Centers the signal, finds period boundaries, computes frequency, extracts a centered period, and calculates RMS.
- getSnapshot() — Returns the latest snapshot (RMS, frequency, period length) in a thread-safe way.
- copyLastPeriod() — Copies the last detected waveform period into a caller-provided buffer.
- copySinceSeq32() — Provides incremental decimated samples since a given sequence index, for streaming or plotting.
Emergency Stop (safety.cpp)
Implements minimal emergency-stop signaling for overcurrent events:
- g_emergency_stop — Global volatile flag indicating an active emergency stop condition.
- onAlertISR() — ISR that sets the emergency stop flag when the INA228 alert pin fires.
SPI Sampler (spi_sampler.cpp)
Implements DMA-driven SPI acquisition for dual AMC1306 isolated ADC channels:
- g_ch1_om / g_ch2_om — OutputMeasurements instances for both channels with hardware-specific scaling.
- g_sampler1 / g_sampler2 — Sampler context structures for SPI hosts, pins, DMA channels, and transactions.
- g_pack1 / g_pack2 — Pairs of sampler context and OutputMeasurements used by sampler tasks.
- spiSamplerInitMeasurements() — Initializes both OutputMeasurements engines and validates buffer allocation.
- spiInitAndStart() — Allocates DMA buffers, configures SPI bus and device, prepares transactions, and seeds the transaction queue.
Task Scheduler (Tasks.cpp)
Implements all FreeRTOS tasks for sampling, analysis, UI updates, control, and safety:
- spiSamplerTask() — Retrieves completed SPI DMA transactions, feeds data into OutputMeasurements, requeues transactions, and maintains sampling timing.
- analyzerTask() — Periodically calls analyzeStep() on a given OutputMeasurements instance to update RMS and frequency.
- printerTask() — Periodically prints analyzer timing, latest period samples, RMS, and frequency for both channels over serial.
- webSocketTask() — Processes WebSocket events in a loop to keep client connections responsive.
- webSocketUpdate() — Periodically collects input and output measurements and sends them as JSON via WebSocket to the UI.
- ControllerTask() — Runs the VRMS control loop by feeding the measured RMS value into the PI controller of the inverter.
- EmergencyStopTask() — Monitors the global emergency-stop flag, stops the inverter, signals the E-STOP output, and notifies the web UI when overcurrent is detected.
Webserver (webserver.cpp)
Implements Wi-Fi access point, HTTP endpoints, and WebSocket telemetry/UI control:
- resetDefaults() — Resets VRMS target and running state to their default values.
- initWiFi() — Starts the Wi-Fi SoftAP for the H-Bridge control interface.
- initServer() — Mounts LittleFS, serves static
/index.html,/style.css,/script.js, and defines/start,/stop, and/ack-tripendpoints. - updateMeasurements() — Packs input/output data and frequency into JSON and broadcasts it over WebSocket.
- broadcastStatus() — Sends current inverter running state to all connected clients via WebSocket.
- onWebSocketEvent() — Handles client connect/disconnect events and sends initial status on connect.
- broadcastTrip() — Notifies all clients of a trip condition and updates running state.
- _VRMS / _isRunning — Static internal state for desired RMS value and inverter run/stop status.
HTTP Endpoints:
/– Main HTML page/start– Start inverter/stop– Stop inverter/update– Update VRMS target/bipolar.png– Waveform reference
Overcurrent Protection
Overcurrent protection is implemented through the INA228 fault pin:
- When a current threshold is exceeded, drivers are disabled immediately.
- A fault message is sent to the web interface.
- After user acknowledgment, the inverter can be restarted safely.
Safety
- Use current-limited power supplies during development.
- Verify MOSFET temperature and load ratings.
- For educational/laboratory use only.
License
Released for educational and research purposes.
Use responsibly.
Parts
124| Qty | Value | Footprint | References |
|---|---|---|---|
| 10 | 100 nF | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | C9, C10, C13, C18, C19, C22, C24, C30, C33, C35 |
| 10 | TSW-102-15-T-S | SamacSys_Parts:TSW-102-XX-YY-S | J1, J2, J3, J4, J5, J7, J9, J12, J14, J15 |
| 8 | 10k | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | R4, R5, R6, R7, R30, R31, R40, R41 |
| 6 | 1µF | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | C11, C17, C21, C25, C26, C27 |
| 6 | S210 | SamacSys_Parts:DIOM5336X265N | D6, D7, D8, D9, D10, D11 |
| 5 | 1 µF | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | C12, C31, C32, C34, C36 |
| 4 | 0 | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | R19, R20, R23, R24 |
| 4 | 10 | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | R2, R3, R8, R9 |
| 4 | 575-4 | SamacSys_Parts:5754 | TP1, TP2, TP3, TP4 |
| 4 | FSV2060L | SamacSys:FSV2060L | D1, D2, D3, D5 |
| 4 | IPD90N10S4L06ATMA1 | SamacSys:IPD90N10S4L06ATMA1 | Q5, Q6, Q9, Q10 |
| 4 | IRLB4030PBF | SamacSys:TO254P483X1016X1994-3P | Q1, Q2, Q3, Q4 |
| 3 | 100uF | SamacSys_Parts:EEE1AA101SP | C7, C8, C23 |
| 2 | 1 uF | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | C28, C29 |
| 2 | 100 | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | R11, R27 |
| 2 | 12k | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | R13, R18 |
| 2 | 1k | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | R17, R28 |
| 2 | 2.2 | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | R1, R10 |
| 2 | 2.2 uF | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | C1, C6 |
| 2 | 22 nF | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | C3, C5 |
| 2 | 220 nF | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | C2, C4 |
| 2 | 220nF | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | C14, C15 |
| 2 | AMC1306M25DWVR | SamacSys:SOIC127P1150X280-8N | IC1, IC3 |
| 2 | BC817 | Package_TO_SOT_SMD:SOT-23_Handsoldering | Q7, Q8 |
| 2 | GMR100HTBFER015 | Resistor_SMD:R_2512_6332Metric_Pad1.40x3.35mm_HandSolder | R15, R42 |
| 2 | IR2110S | Package_SO:SOIC-16W_7.5x10.3mm_P1.27mm | U2, U3 |
| 2 | TLMG1100-GS15-1 | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | LED1, LED4 |
| 1 | 1 | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | R12 |
| 1 | 120k | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | R16 |
| 1 | 1734510-1 | SamacSys_Parts:17345101 | J13 |
| 1 | 330 | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | R29 |
| 1 | 4.7 µF | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | C20 |
| 1 | 5k | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | R14 |
| 1 | B32776E4406J000 | SamacSys_Parts:B32776E4406J000 | C16 |
| 1 | B3U-1000P | SamacSys:B3U-1000P | S1 |
| 1 | CH340C | Package_SO:SOIC-16_3.9x9.9mm_P1.27mm | U7 |
| 1 | ESP32-WROOM-32 | RF_Module:ESP32-WROOM-32 | U1 |
| 1 | HPZR-C26X | SamacSys_Parts:HPZRC26X | D12 |
| 1 | INA228 | Package_SO:VSSOP-10_3x3mm_P0.5mm | U4 |
| 1 | L7812ABD2T-TR | SamacSys:L7812ABD2TTR | IC2 |
| 1 | LD1086DT50TR | Package_TO_SOT_SMD:TO-252-2 | U6 |
| 1 | LT1963AxST-3.3 | Package_TO_SOT_SMD:SOT-223-3_TabPin2 | U5 |
| 1 | NXJ1S0303MC-R13 | SamacSys:NXJ1S0303MCR13 | PS1 |
| 1 | PHBC24N-2R0A0219V | SamacSys_Parts:PHBC24N2R0A0219V | FL1 |
| 1 | SP0503BAHT | Package_TO_SOT_SMD:SOT-143 | D4 |
| 1 | TLMG1100-GS15-2 | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | LED2 |
| 1 | TLMG1100-GS15-3 | Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder | LED3 |
The 120 most common of 124 parts.
Similar boards
- 4 layers138.2 × 200.4 mm

- 4 layers449.2 × 272.9 mm

Wpc power driver cost
lolz0r/Williams-WPC-Power-Driver-Board-A-12697-3
Untested, unverifed, AI created design.
453 parts2 - 2 layers80 × 52.8 mm

Lemon F334-K
NickNifontov/CipollinoRTOS
Sin wave invertor (HRPWM, 35kHz). Replacement for TL/EG PWM .
176 parts3 - 2 layers310 × 100 mm

AOML AB 3.0 reorganized v2
cxs1529/XBT_Autolauncher_PCB
KiCAD repository for the XBT Autolauncher board
247 parts - 2 layers196 × 176 mm

- 4 layers100 × 100 mm

Deneme2
Gokasimov/STM32-FOC-Control
A completely from-scratch, bare-metal implementation of Field-Oriented Control (FOC) tailored for ultra-low inductance (3 µH) drone motors (e.g., A2212).
118 parts2MIT - 4 layers90 × 53.5 mm

Buck boost solar
JonasCz/lt8491-charger-boards
Boosting high-voltage MPPT solar charger based on LT8491
129 parts2 - 2 layers85.3 × 50.3 mm

Questions
How big is the H Bridge PCB PCB?
It measures 110.3 × 110.3 mm and has 2 copper layers, 1.6 mm thick.
What parts does the H Bridge PCB use?
124 parts, built around the CH340C, ESP32-WROOM-32, NXJ1S0303MC-R13 and IR2110S-MNS. 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 H Bridge PCB KiCad files?
From the reinto1234/H_Bridge_PCB repository on GitHub, at the commit this page was made from: the board is H_bridge_PCB_Design/H_bridge_PCB.kicad_pcb and its schematic H_bridge_PCB_Design/H_bridge_PCB.kicad_sch. PCBKit opens the board in the browser, with nothing to install.
Can I use the H Bridge PCB design in my own project?
Its repository states no licence, so its author keeps all rights: ask reinto1234 before reusing the design.