Skip to the content
2 layers90 × 42 mmBLDC, the printed circuit board in 3D

ESP32-based BLDC motor controller built with ESP-IDF, utilizing Hall sensors and the hardware MCPWM peripheral.

Size
90 × 42 mm
Copper layers
2
Thickness
1.6 mm
Parts
38
Nets
31
Pads
112
Tracks, vias
165, 112
Pours
1
Routed
Yes
KiCad
KiCad 9.0 (file 20241229)
Created
9 Jun 2026
Updated
23 Jun 2026

Overview

BLDC is an open-source printed circuit board by paulmikael02, from the paulmikael02/ESP32-BLDC-Motor-Controller repository on GitHub. It is a 2-layer board of 90 × 42 mm with 38 parts on 31 nets, routed with 165 tracks and 112 vias.

It is built around the IRS2001PBF and IRFZ44N. Its parts include 12 capacitors, 9 resistors, 6 transistors, 5 connectors and 3 ICs. It belongs with the robots and motor control and sensors and measurement boards and the ESP32 boards of this library.

Main components

2

README

README.md

ESP32-Based BLDC Motor Controller (Firmware & Hardware)

FI | Lue kattava suomenkielinen dokumentaatio tästä

This repository contains the hardware designs (KiCad) and embedded software (ESP-IDF) for a 3-phase brushless DC (BLDC) motor controller.

The project was developed as part of modernizing the educational equipment in the embedded systems laboratory at SeAMK. The old 8-bit ATmega architecture was upgraded to a modern 32-bit ESP32-C6 platform. The new motherboard was designed to directly support the laboratory's legacy analog and digital input/output expansion boards, preserving compatibility with the existing educational environment.

The firmware has been tested with both a small RC car motor and a larger 750W Vevor electric vehicle motor.

🚀 Key Features

  • Hardware: Two-board design separating 3.3V digital logic from high-power electronics.
  • Firmware: Event-driven C code built using ESP-IDF and FreeRTOS.
  • Motor Control: 20 kHz hardware PWM with a 1 µs dead-time to protect the MOSFETs.
  • Performance: Fast, interrupt-driven 6-step commutation optimized in IRAM.

System Architecture

The system consists of two physical printed circuit boards (PCBs) to electrically isolate the sensitive digital logic from the high-current power electronics.

Architecture Overview

Technical block diagram of the system architecture

1. ESP32 Carrier Board

Contains the ESP32-C6-based microcontroller, decoupling and bulk capacitors, and the necessary filtering for the power supply. 3D render of the ESP32 Carrier Board

2. BLDC Motor Controller

Contains the 3-phase MOSFET inverter bridge, gate drivers, protection diodes, and bulk and decoupling capacitors for the power input. 3D render of the motor controller power stage


🔌 Pinout Mapping

The physical interface between the software (include/bldc_control.h) and the hardware is defined as follows:

FunctionESP32-C6 PinDescription / Target on Power Stage
PWM U_H / U_LGPIO 11 / GPIO 10Control for U-phase high- and low-side MOSFETs
PWM V_H / V_LGPIO 19 / GPIO 7Control for V-phase high- and low-side MOSFETs
PWM W_H / W_LGPIO 0 / GPIO 6Control for W-phase high- and low-side MOSFETs
Hall U / V / WGPIO 5 / GPIO 4 / GPIO 18Signal inputs from the motor Hall sensors
PotentiometerGPIO 3 (ADC1_CH3)Analog voltage input (0–3.3 V)

💻 Software Structure and Implementation

The software is written in pure C using the ESP-IDF (v5.x) environment and PlatformIO tools. The implementation utilizes the FreeRTOS real-time operating system. The software is fully event- and interrupt-driven (no blocking delays), which guarantees accurate motor control even at high rotational speeds.

The code is divided into three logical main components:

1. Global Header File and API (include/bldc_control.h)

Acts as the hardware definition for the entire system and serves as the public application programming interface (API) for motor control parameters and GPIO definitions. It encapsulates internal helper functions and interrupt handlers away from the main program.

Low-level critical parameters for motor control:

  • PWM_RES_HZ (10 MHz): The base clock frequency for the MCPWM module.
  • PWM_PERIOD (500): Defines a 20 kHz PWM frequency ($10\text{ MHz} / 500$). The PWM duty cycle is set between 0 and 500 ticks.
  • DEAD_TIME_TICKS (10): Configures a 1-microsecond hardware dead time between the high- and low-side MOSFETs of each phase to prevent short circuits (shoot-through).
  • GPIO Definitions: Centralized configurations for the input Hall sensors and power stage transistor outputs.

2. Motor Control Logic (src/bldc_control.c)

Contains all low-level control logic utilizing the hardware interfaces directly:

  • MCPWM & Dead Time: Generates the 20 kHz PWM signals for the motor phases and monitors the hardware-level dead time.
  • Interrupt-Driven 6-Step Commutation: The motor Hall sensors are connected to the MCPWM Capture subsystem. A change in the sensor state triggers an immediate hardware interrupt (hall_sensor_callback). To maximize execution speed, the actual commutation function (update_bldc_commutation) is placed directly in IRAM memory. The code fully supports both forward and reverse commutation sequence tables.
  • FreeRTOS Background Task (potentiometer_task): Handles the potentiometer control and ADC channel processing. It simultaneously calculates the real-time rotational speed from the Hall pulse intervals and filters it using a digital low-pass filter (Exponential Moving Average, $\alpha = 0.10$).

3. Main Program (src/main.c)

Contains the higher-level application logic. Separate test routines have been built into the file for hardware commissioning:

  • run_hall_sensor_test(): Determines and verifies the sequence and state changes (1–6) of the Hall sensors. The power stage is kept off and the shaft is spun by hand. The order is verified via the serial port, and the motor-specific sequence is updated in the driver's table.
  • run_speed_ramp_test(): Performs an automatic PWM acceleration and braking run to verify the operation of the MOSFET bridges without external interference.
  • Normal Operation (app_main): Runs the main program's while(1) loop and tests the code-level direction change sequence (set_motor_direction) every 5 seconds.

📊 Telemetry and Data Visualization

The software outputs real-time data to the serial port every 50 ms. The outputs are formatted using the >variable:value standard, allowing direct visualization of the data as a real-time graph using, for example, the Teleplot VS Code extension or any Serial Plotter.

Monitored Variables:

  • Motor_Duty_Ticks: PWM pulse width (Counter between 0–500)
  • Hall_State: Latest state of the Hall sensors (Value between 1–6)
  • Motor_RPM: Filtered rotational speed (RPM, value is negative when reversing)
  • Motor_Direction: Direction of rotation (1 = forward, 0 = reverse)

🛠️ Quick Start

This project is built using PlatformIO in VS Code.

bash
# Clone the repository
git clone https://github.com/paulmikael02/ESP32-BLDC-Motor-Controller.git

# Open in VS Code with the PlatformIO extension installed.
# Build and upload the firmware:
pio run -t upload

Parts

38
QtyValueFootprintReferences
610Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_HorizontalR1, R2, R3, R4, R5, R6
6IRFZ44NPackage_TO_SOT_THT:TO-220-3_VerticalQ1, Q2, Q3, Q4, Q5, Q6
5100nCapacitor_THT:C_Disc_D3.8mm_W2.6mm_P2.50mmC1, C5, C8, C10, C13
310uCapacitor_THT:CP_Radial_D5.0mm_P2.00mmC3, C4, C7
31N5819Diode_THT:D_DO-41_SOD81_P10.16mm_HorizontalD1, D2, D3
31uCapacitor_THT:C_Disc_D5.1mm_W3.2mm_P5.00mmC2, C6, C9
34k7Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P15.24mm_HorizontalR7, R8, R9
3IRS2001Package_DIP:DIP-8_W7.62mm_SocketU1, U2, U3
1470uCapacitor_THT:CP_Radial_D10.0mm_P5.00mmC11
1Conn_01x02Connector_PinHeader_2.54mm:PinHeader_1x02_P2.54mm_VerticalJ5
1Conn_02x05_Odd_EvenConnector_IDC:IDC-Header_2x05_P2.54mm_VerticalJ4
1Screw_Terminal_01x02TerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-2-5.08_1x02_P5.08mm_HorizontalJ1
1Screw_Terminal_01x03TerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-1,5-3-5.08_1x03_P5.08mm_HorizontalJ2
1Screw_Terminal_01x05TerminalBlock_Phoenix:TerminalBlock_Phoenix_MPT-0,5-5-2.54_1x05_P2.54mm_HorizontalJ3

More from paulmikael02/ESP32-BLDC-Motor-Controller

1
  • 2 layers68 × 51 mmEsp32-c6-carrier, the printed circuit board in 3D

    Esp32-c6-carrier

    paulmikael02/ESP32-BLDC-Motor-Controller

    ESP32-based BLDC motor controller built with ESP-IDF, utilizing Hall sensors and the hardware MCPWM peripheral.

    19 parts2

Similar boards

  • 2 layers91.4 × 71.1 mmPico w rover, the printed circuit board in 3D

    Pico w rover

    NikodemBartnik/Mini-Mars-Rover

    Educational robotic platform made to look like a mini mars rover

    20 parts143MIT
  • 2 layers54.6 × 85.1 mmOpenScrewCounter, the printed circuit board in 3D

    OpenScrewCounter

    Indystrycc/OpenScrewCounter

    Open source screw counting machine

    28 parts71
  • 2 layers97.8 × 66 mmPico Watering System, the printed circuit board in 3D

    Pico Watering System

    NikodemBartnik/Pico-Watering-System

    Raspberry Pi Pico based automated watering system for your garden

    33 parts59MIT
  • 4 layers262 × 110.5 mmHM CENTRAL-02 painel, the printed circuit board in 3D

    HM CENTRAL-02 painel

    BenjamimKrug/robo_humanoide

    Repositorio para arquivos gerais necessários para o desenvolvimento do Robô humanoide

    303 parts10
  • 2 layers55.4 × 82 mmG board V0 1, the printed circuit board in 3D

    G board V0 1

    2technology/g-board

    ESP32 IoT Home automation PCB - 1 * 12V relay, 4 * input button connector with HW debounce, 4 * ws2812b output

    42 parts5GPL-3.0
  • 2 layers45.5 × 35.5 mmPWM, the printed circuit board in 3D

    PWM

    AvishkaVishwa/12V-DC-Motor-Speed-Controller-PCB-Design-using-KiCAD

    using 555 timer is at Astable mode

    16 parts4
  • 2 layers186.7 × 81.8 mmDD Scope PCBv3, the printed circuit board in 3D

    DD Scope PCBv3

    RichardBenear/DDScopeX-Hardware

    Hardware documentation for Direct Drive Scope

    85 parts3MIT
  • 2 layers107.6 × 82.5 mmLampe, the printed circuit board in 3D

    Lampe

    Churros98/LampeMagique-PCB

    3D / PCB & Bill of materials for building your own lamp at home.

    61 parts1

Questions

How big is the BLDC PCB?

It measures 90 × 42 mm and has 2 copper layers, 1.6 mm thick.

What parts does the BLDC use?

38 parts, built around the IRS2001PBF and IRFZ44N. 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 BLDC KiCad files?

From the paulmikael02/ESP32-BLDC-Motor-Controller repository on GitHub, at the commit this page was made from: the board is hardware/motor-controller/BLDC.kicad_pcb and its schematic hardware/esp32-carriercard/esp32-c6-carrier.kicad_sch. PCBKit opens the board in the browser, with nothing to install.

Can I use the BLDC design in my own project?

Its repository states no licence, so its author keeps all rights: ask paulmikael02 before reusing the design.