

ESP32 Motor Controller
Design and development of a portable, self contained closed loop Field Oriented Controller (FOC) for Brushless DC (BLDC) motors built on the ESP32 S3 via a custom designed PCB.
- Size
- 52.8 × 56.4 mm
- Copper layers
- 4
- Thickness
- 1.66 mm
- Parts
- 154
- Nets
- 114
- Pads
- 612
- Tracks, vias
- 1,264, 270
- Pours
- 42
- Routed
- Yes
- KiCad
- KiCad 9.0 (file 20241229)
- Created
- 3 Nov 2025
- Updated
- 2 Nov 2026
Overview
ESP32 Motor Controller is an open-source printed circuit board by Angelpele, from the Angelpele/Integrated_FOC_BLDC_Actuator repository on GitHub, published under the MIT licence. It is a 4-layer board of 52.8 × 56.4 mm with 154 parts on 114 nets, routed with 1,264 tracks and 270 vias.
It is built around the MCP2551-I/SN-HG, ESP32-S3-WROOM-1-N8 and DRV8302DCAR, with the MT6701CT-AKD-R, BMI270 and TLV75733PDBV among its other parts. Its parts include 54 capacitors, 43 resistors, 11 diodes, 7 transistors and 5 ICs. It belongs with the robots and motor control boards and the ESP32 boards of this library.
Main components
12MCP2551-I/SN-HG
SOP-8SOP-8 CAN Transceivers ROHSHGSEMICAN TransceiversESP32-S3-WROOM-1-N8
SMD,25.5x18mm-40℃~+85℃ -98.2dBm 2.4GHz 20.5dBm 355mA 3V~3.6V 95mA Bluetooth5.0 ESP32-S3 Chip On-board PCB Antenna UART、SPI、I2C、I2S、USB SMD,25.5x18mm WiFi Modules ROHSEspressif SystemsWiFi ModulesDRV8302DCAR
HTSSOP-56-6mm-40℃~+125℃ 2.3A 3 50uA 8V~60V Three Phase HTSSOP-56-6mm Brushless DC (BLDC) Motor Driver ROHSTexas InstrumentsBrushless DC (BLDC) Motor DriverMT6701CT-AKD-R
SOP-8-40℃~+125℃ 0°~360° 1.75mm 10mA 3.3V~5V 3.9mm 5mm I2C Magnetic rotary position sensor No Programmable transmission、Zero position programming、Fault diagnosis、Multi-axis magnetic field detection SOP-8 Position Sensors ROHSNOVOSENSEPosition SensorsBMI270
LGA-14(2.5x3)-40℃~+85℃ 1.71V~3.6V 16bit 2KB 3.5uA Accelerometer Gyroscope SPI、I2C X,Y,Z X,Y,Z ±16g ±2000dps LGA-14(2.5x3) Accelerometers ROHSBosch SensortecAccelerometersTLV75733PDBV
SOT-23-5-40℃~+125℃@(Tj) 1 1A 3.3V 40uA 46dB@(100kHz) 5.5V 650mV@(1A) 71.5uVrms Fixed Positive Under Voltage Lockout、Over Current Protection、Over Temperature Protection、Soft Start SOT-23-5 Voltage Regulators - Linear, Low Drop Out (LDO) Regulators ROHSTexas InstrumentsVoltage Regulators - Linear, Low Drop Out (LDO) RegulatorsFH4008GS
PDFN5x6-8LUncategorisedXIN FEI HONGTS-1088-AR02016
SMD,4x3mm-30℃~+80℃ 1.6N 100,000 cycles 12V 2mm 3.9mm 3mm 50mA Black Round Button SMD(SMT) Tab SPST Surface Mount,Vertical Without Bracket SMD,4x3mm Tactile Switches ROHSXUNPUTactile SwitchesXT30PW-M
-- Power connector / plug connector ROHSChangzhou Amass ElecUncategorisedB360
SMC(DO-214AB)-55℃~+150℃ 1 Independent 100A 3A 500uA@60V 60V 700mV@3A SMC(DO-214AB) Schottky Diodes ROHSDiodes IncorporatedSchottky DiodesBZT52C18
SOD-123Zener DiodeshongjiachengSMAJ30CA
DO-214AC(SMA)-55℃~+150℃ 1 30V 33.3V 400W 48.4V 5uA 8.3A Bidirectional TVS DO-214AC(SMA) ESD and Surge Protection (TVS/ESD) ROHSGOODWORKESD And Surge Protection (TVS/ESD)
README
README.mdIntegrated FOC BLDC Actuator
A portable, self-contained closed loop Field Oriented Controller (FOC) for Brushless DC (BLDC) motors built on the ESP32-S3 via a custom designed PCB. This project focuses on the development of a robust FOC controller for BLDC motors to be integrated into future robotic systems, such as robotic arms or other kind of robots. The controller combines the advantages of different motor technologies, offering:
- The speed of a BLDC motor
- The precision of a stepper motor
- The torque provided by cycloidal gear reductions
Both CAD and 3D printed preliminary models
Features and Goals
- High Performance: Closed-loop sinusoidal PWM (SPWM) field-oriented control for precise speed, position, and torque management.
- Integrated Protection: Reverse polarity protection (RPP), fault detection for overvoltage, overcurrent, DRV8302 hardware faults (NFAULT/NOCTW), magnetic encoder field anomalies and IMU fault.
- Advanced Sensors: Magnetic encoder (MT6701) for precise motor shaft angle, BMI270 IMU for 3D acceleration and gyroscope tracking, and NTC thermistor for temperature monitoring.
- Modularity: Designed for portability and adaptability across multiple robotic platforms. Independent sensor and driver classes with clean interfaces.
- Multi-Task Architecture: FreeRTOS task scheduler on dual cores with semaphore and mutex protected shared data and a hardware timer ISR for all the control loops.
- CAN Bus Communication: MCP2551 transceiver for daisy chain communication in robotic systems.
- Power Bus Connection: Dual XT30 connectors provide easy connection between different motors in the same bus.
Hardware
Core Components
- Microcontroller: ESP32-S3 WROOM (dual core, 240 MHz)
- Motor Driver: DRV8302 3 phase gate driver with integrated current sense amplifiers
- Sensors:
- MT6701 Magnetic Encoder: SSI interface, 14 bit resolution (16384 counts/rev), diametrically magnetized rotor for absolute shaft angle
- BMI270 IMU: 3 axis accelerometer and gyroscope via 3 wire SPI
- NTC Thermistor: B=3380 K, real time board temperature monitoring with Steinhart Hart equation
- PVDD Voltage Divider: Resistor divider on ADC2 for bus voltage monitoring
- CAN Transceiver: MCP2551 for multi motor communication at up to 1 Mbps
Protection Features
- Reverse polarity protection with integrated MOSFET and parallel zener diode
- TVS protection against exterior ESD discharges
- Overvoltage detection on PVDD (configurable threshold) with immediate driver shutdown
- DRV8302 hardware fault latch (NFAULT + NOCTW) with software latch counter and hysteresis
- MT6701 magnetic field anomaly detection
- IMU wrong data detection
- Watchdog timer (WDT) subscription on all FreeRTOS tasks to catch runaway loops
Soldered PCB V1
Mechanical Design
- Cycloidal Gearbox: For torque amplification and precision gain, 15:1 gear reduction. Features dual disc configuration to supress motor vibrations.
- Modified motor coupling: The motor and gearbox coupler presents a D slot to transfer the rotation power without the need for small screws as in previous versions.
- Integrated bearings: Metallic bearings offer a smooth movement of the gearbox with outer steel pins.
- Integrated Motor: 5010 750KV motor integrated into the enclosure.
- Integrated PCB: The PCB support has been designed to be as compact as possible, reading the magnet from the motor axis and preventing external cables outside the casing.
- Custom PCB (V1): Compact integration of ESP32-S3, DRV8302, MT6701, BMI270, MCP2551, and NTC. Schematic available in
ESP32_Motor_Controller_V1.pdf. - Custom PCB (V2): Several improvements implemented and corrected errors from V1:
- Voltage upgrade: Input raised to 36 V (MOSFET max 40 V); RPP, TVS diode, phase voltage dividers, and MOSFET selection updated accordingly (targeting ≥50 V rating).
- Dual configuration for higher power motors and lower power ones (16V vs 36V).
- Passives:
- Large-value caps (22 µF, 1 µF) moved to 0805+ for voltage headroom
- All MOSFET line power caps in 0805
- GVDD/AVDD/DVDD decoupling can stay 0603 (16 V rated)
- BOM consolidated to reuse values/footprints.
- Layout:
- Power and sensor zones separated
- Routing improved with stitching vias
- External pull-up resistors added on I2C lines
- Gate series resistance tuned.
- Schematic available in
ESP32_Motor_Controller_V2.pdf.
Mechanical CAD Design
Firmware Architecture
State Machine
The main task runs a three-state machine:
SYSTEM_INIT → SYSTEM_CALIBRATION → SYSTEM_RUNNING- INIT: Initializes MT6701 and DRV8302. Retries on failure.
- CALIBRATION: Sets up MCPWM, performs current sense offset calibration (DC_CAL pulse, 500 samples averaged), and magnetic encoder field quality check (1000 samples).
- RUNNING: Monitors faults in the main loop; all control logic runs in ISR-driven FreeRTOS tasks.
Control Loop (Timer ISR at 20 kHz)
A hardware timer (APB clock / 80 divider = 1 MHz, alarm at 50 µs) triggers task notifications at divided rates:
| Task | Rate | Core | Priority |
|---|---|---|---|
focLoop | 20 kHz | 1 | 10 |
magLoop | 5 kHz | 1 | 9 |
drvLoop | 500 Hz | 0 | 8 |
telemetryLoop | 100 Hz | 0 | 2 |
All shared data (drv_pkg, mag_pkg) is protected by FreeRTOS mutexes.
SPWM Generation
DRV::update_spwm() runs three stages:
- Alignment (Open loop): Ramps duty cycle over 500 ms to lock rotor to a known electrical angle. Computes
elec_offsetfrom the MT6701 reading at alignment. - Frequency Ramp: Linearly ramps
electrical_freqfrom 2 Hz totarget_electrical_freq(20 Hz default) at 100 Hz/s. - Closed Loop SPWM: Uses MT6701 angle +
elec_offset+ pole pairs (7) to compute instantaneous electrical angle.
Motor parameters (5010 750KV, 14 poles, 270 mΩ phase resistance, 40 A max) are defined as constexpr in DRV.h.
Current Sensing
- Two shunt channels (SO1, SO2) on ADC1 with DRV8302 internal amplifier (gain selectable via GAIN pin, default 40×, R_shunt = 10 mΩ)
- DC offset calibration via
DC_CALpin pulse at startup, sanity-checked against 12-bit midpoint (valid range 1000–3000) - Third phase current reconstructed as
I_C = -(I_A + I_B)
Software
- Motor Calibration: Automated at boot — current sense offset calibration and magnetic field quality verification.
- Real Time Telemetry: UART serial output at 100 Hz: PVDD voltage, phase currents, raw ADC values, NFAULT/NOCTW states, NTC temperature, and encoder angle/status.
- Debug Mode:
debug_mode_enabledflag bypasses the state machine for rapid hardware-in-the-loop testing. - Fault Override: Per-subsystem override flags (
DRV::set_override,MT6701::set_override) for bench testing without a valid magnetic field or full power stage.
Integration with ROS2 and a graphical PID tuning interface are planned for future iterations.
References
- SimpleFOC Library
- ODrive Pro Documentation
- DRV8302 Datasheet (
drv8302.pdf) - MT6701 SSI Encoder Datasheet
- ESP32-S3 WROOM Datasheet (
ESp32_S3_WROOM.pdf)
Parts
154| Qty | Value | Footprint | References |
|---|---|---|---|
| 13 | 0.1uF | Capacitor_SMD:C_0402_1005Metric | C202, C204, C205, C305, C322, C402, C406, C409, C501, C502, C503, C507, C508 |
| 10 | 10uF | Capacitor_SMD:C_0805_2012Metric | C104, C105, C106, C107, C108, C109, C110, C111, C112, C113 |
| 9 | 10k | Resistor_SMD:R_0402_1005Metric | R103, R201, R303, R304, R305, R403, R410, R415, R509 |
| 6 | 10R | Resistor_SMD:R_0603_1608Metric | R401, R402, R406, R407, R411, R412 |
| 6 | FH4008GS | Package_DFN_QFN:PQFN-8-EP_6x5mm_P1.27mm_Generic | Q401, Q402, Q403, Q404, Q405, Q406 |
| 5 | 1N4002 | Diode_SMD:D_SOD-123 | D102, D302, D401, D402, D403 |
| 4 | 0.1uF | Capacitor_SMD:C_0603_1608Metric | C306, C307, C308, C321 |
| 4 | 100k | Resistor_SMD:R_0402_1005Metric | R310, R404, R409, R414 |
| 4 | 1uF | Capacitor_SMD:C_0603_1608Metric | C114, C115, C201, C320 |
| 4 | MountingHole | MountingHole:MountingHole_3.2mm_M3 | MP_1, MP_2, MP_3, MP_4 |
| 3 | 0.1uF | Capacitor_SMD:C_0805_2012Metric | C312, C315, C316 |
| 3 | 0R | Resistor_SMD:R_0402_1005Metric | R501, R502, R503 |
| 3 | 1nF | Capacitor_SMD:C_0402_1005Metric | C318, C403, C404 |
| 3 | 2.2 uF | Capacitor_SMD:C_0805_2012Metric | C401, C405, C408 |
| 2 | 0.01R | Resistor_SMD:R_2512_6332Metric | R405, R408 |
| 2 | 100R | Resistor_SMD:R_0603_1608Metric | R506, R507 |
| 2 | 10k | Resistor_SMD:R_0603_1608Metric | R308, R312 |
| 2 | 2.2nF | Capacitor_SMD:C_0402_1005Metric | C309, C310 |
| 2 | 2.2uF | Capacitor_SMD:C_0805_2012Metric | C311, C313 |
| 2 | 3V3 | LED_SMD:LED_0603_1608Metric | D201, D204 |
| 2 | 5,1k | Resistor_SMD:R_0402_1005Metric | R101, R102 |
| 2 | 560pF | Resistor_SMD:R_0402_1005Metric | C504, C505 |
| 2 | 56R | Resistor_SMD:R_0603_1608Metric | R202, R205 |
| 2 | 56R | Resistor_SMD:R_0402_1005Metric | R301, R302 |
| 2 | TS-1088-AR02016 | TS-1088-AR02016:SW_TS-1088-AR02016 | SW1, SW2 |
| 2 | XT30PW-M | XT30PW-M:AMASS_XT30PW-M | J101, J102 |
| 1 | -k | Inductor_SMD:L_0603_1608Metric | FB |
| 1 | 0.015uF | Capacitor_SMD:C_0402_1005Metric | C304 |
| 1 | 0.022uF | Capacitor_SMD:C_0402_1005Metric | C303 |
| 1 | 100k | Resistor_SMD:R_0603_1608Metric | R313 |
| 1 | 1100R | Resistor_SMD:R_0603_1608Metric | R204 |
| 1 | 121R | Resistor_SMD:R_0603_1608Metric | R504 |
| 1 | 12uH | SM7850 Inductor:SM7850 | L301 |
| 1 | 12uH | Capacitor_SMD:C_0603_1608Metric | C319 |
| 1 | 150R | Resistor_SMD:R_0603_1608Metric | R203 |
| 1 | 15pF | Capacitor_SMD:C_0402_1005Metric | C317 |
| 1 | 16V | LED_SMD:LED_0603_1608Metric | D203 |
| 1 | 1uF | Capacitor_SMD:C_0402_1005Metric | C506 |
| 1 | 2.2uF | Capacitor_SMD:C_0603_1608Metric | C302 |
| 1 | 200k | Resistor_SMD:R_0402_1005Metric | R307 |
| 1 | 22uF | Capacitor_SMD:C_0805_2012Metric | C203 |
| 1 | 3.3k | Resistor_SMD:R_0402_1005Metric | R311 |
| 1 | 3V3 | TestPoint:TestPoint_Pad_D1.0mm | TP9 |
| 1 | 4.7uF | Capacitor_SMD:C_0805_2012Metric | C314 |
| 1 | 4k7 | Resistor_SMD:R_0402_1005Metric | R505 |
| 1 | 52.3k | Resistor_SMD:R_0603_1608Metric | R309 |
| 1 | 5V | LED_SMD:LED_0603_1608Metric | D202 |
| 1 | 5V | TestPoint:TestPoint_Pad_D1.0mm | TP13 |
| 1 | 86.6k | Resistor_SMD:R_0402_1005Metric | R306 |
| 1 | AVDD | TestPoint:TestPoint_Pad_D1.0mm | AV |
| 1 | A_SENSE | TestPoint:TestPoint_Pad_D1.0mm | A |
| 1 | B360 | B3030A:B3030A | D301 |
| 1 | BMI270 | BMI270:XDCR_BMI270 | U501 |
| 1 | BZT52C18 | Diode_SMD:D_SOD-123 | D101 |
| 1 | B_SENSE | TestPoint:TestPoint_Pad_D1.0mm | B |
| 1 | CAN | Jumper:SolderJumper-2_P1.3mm_Open_Pad1.0x1.5mm | JP3 |
| 1 | CAN1 | Connector_JST:JST_PH_S2B-PH-K_1x02_P2.00mm_Horizontal | J502 |
| 1 | CAN2 | Connector_JST:JST_PH_S2B-PH-K_1x02_P2.00mm_Horizontal | J503 |
| 1 | C_SENSE | TestPoint:TestPoint_Pad_D1.0mm | C |
| 1 | Conn_01x01_Pin | Connector_PinHeader_2.00mm:PinHeader_1x01_P2.00mm_Vertical | Ext_Cap101 |
| 1 | DRV8302DCAR | DRV8302:DRV8302 | U301 |
| 1 | ESP32-S3-WROOM-1 | RF_Module:ESP32-S3-WROOM-1U | ESP 32 |
| 1 | GND | TestPoint:TestPoint_Pad_D1.0mm | GND |
| 1 | Hall Encoder | Connector_JST:JST_PH_S5B-PH-K_1x05_P2.00mm_Horizontal | J501 |
| 1 | MCP2551-I_SN | MCP2551-I_SN:SOIC127P599X175-8N | U502 |
| 1 | MT6701CT-AKD | MT6701CT-STD-R:SOIC127P600X175-8N | IC501 |
| 1 | NTC 10k | Resistor_SMD:R_0603_1608Metric | TH1 |
| 1 | PESDNC2 | Diode_SMD:D_0201_0603Metric | TVS101 |
| 1 | PVDD | TestPoint:TestPoint_Pad_D1.0mm | PV |
| 1 | Pad401 | MountingHole:MountingHole_2.5mm_Pad_Via | MP1 |
| 1 | Pad402 | MountingHole:MountingHole_2.5mm_Pad_Via | MP2 |
| 1 | Pad403 | MountingHole:MountingHole_2.5mm_Pad_Via | MP3 |
| 1 | SMAJ30CA | Diode_SMD:D_SMC | TVS103 |
| 1 | SOLDER - RPP | Jumper:SolderJumper-2_P1.3mm_Open_Pad1.0x1.5mm | JP1 |
| 1 | SOLDER - XRPP | Jumper:SolderJumper-2_P1.3mm_Open_Pad1.0x1.5mm | JP2 |
| 1 | SRV05-4 | Package_TO_SOT_SMD:SOT-23-6 | TVS102 |
| 1 | TLV75733PDBV | Package_TO_SOT_SMD:SOT-23-5 | U2 |
| 1 | USB_C 3.1 | Connector_USB:USB_C_Receptacle_Palconn_UTC16-G | USB-C |
| 1 | XRS80P06F | XRS80P06F:XRS80P06F | Q1 |
Similar boards
- 4 layers100 × 75 mm

- 4 layers113 × 100.2 mm

- 4 layers69 × 39 mm

JPBms2
jakepoz/jpbms
JPBms is a simple BMS for solar charging and balancing a 3-cell lithium ion battery.
132 parts2 - 2 layers46.3 × 53.3 mm

- 2 layers73.1 × 65.2 mm

Module dual powerstage tiled
Squantor/DiySolderingStation
Do it yourself soldering station
252 parts7MIT - 2 layers187.5 × 45 mm

Gamma spectrometer
Motokichirou/gamma-spectrometer
NaI(Tl) gamma spectrometer: STM32G474 + R1307 PMT + 4-board stack, KiCad schematics, LTspice simulations
231 parts - 2 layers70 × 35 mm

- 4 layers150 × 90 mm

Motherboard
Foosa7/koi_8x8
The controller board for Koi 8×8. Carries a Raspberry Pi Pico (RP2040) and hosts up to 8 daughterboards in PCIe-x4 card-edge slots, addressing each board's DAC/ADC over a shared SPI bus. Formerly codenamed MOBO.
56 parts2
Questions
How big is the ESP32 Motor Controller PCB?
It measures 52.8 × 56.4 mm and has 4 copper layers, 1.66 mm thick.
What parts does the ESP32 Motor Controller use?
154 parts, built around the MCP2551-I/SN-HG, ESP32-S3-WROOM-1-N8, DRV8302DCAR and MT6701CT-AKD-R. 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 ESP32 Motor Controller KiCad files?
From the Angelpele/Integrated_FOC_BLDC_Actuator repository on GitHub, at the commit this page was made from: the board is Hardware/ESP32_Motor_Controller/ESP32_Motor_Controller.kicad_pcb and its schematic Hardware/ESP32_Motor_Controller/CONTROLLER [2].kicad_sch. PCBKit opens the board in the browser, with nothing to install.
Can I use the ESP32 Motor Controller design in my own project?
Its repository publishes it under the MIT licence: you may reuse it on that licence's terms (keep the author's notice, and for a copyleft licence share your changes alike).