Motor
Controlling BLDC ESC Motor with ESP32
What is the BLDC ESC?
BLDC ESC practical reference
A brushless DC motor paired with an ESC for high-RPM applications like drones, RC vehicles, and cooling fan projects.
Key specifications
- Motor type: Sensorless 3-phase brushless DC (BLDC)
- ESC control input: Standard servo-style PWM, 50Hz, ~1ms (stop/min throttle) to ~2ms (full throttle)
- Battery: 2S-4S LiPo typical for small hobby ESCs (7.4V-14.8V) — confirm your specific ESC's rated cell count before connecting a pack
- Max current: ESC-dependent — commonly 20A-30A continuous on small hobby ESCs, check the label on yours
- Startup: Most ESCs require an arming sequence (throttle held at minimum on power-up) and beep out cell count/status before responding to input
Pinout and connection notes
Always run the arming/calibration sequence documented for your specific ESC before first use — sending a mid-range throttle value on power-up on an uncalibrated ESC is a common cause of "the motor won't start" confusion.
- Motor wires (3): 3-phase output from ESC to motor — order is arbitrary, swap any two to reverse rotation direction
- Battery + / -: LiPo battery input to the ESC — observe polarity, reversing it can destroy the ESC instantly
- Signal: PWM control input from the MCU, same as a standard servo signal
- BEC + / -: Many ESCs feed regulated 5V back out on the signal connector's power pins (BEC) — can power your MCU's logic side if within its current rating
Integration checklist
- Confirm the exact part number and breakout-board revision.
- Verify supply voltage, current demand, logic levels, and signal direction against the datasheet.
- Check controller pin assignments and bus address or interface mode against the example code.
- Power up with external loads disconnected, then test signals before full integration.
- If readings or communication fail, check power and ground first, then pin mapping, interface settings, and library initialization.
Troubleshooting and reproducibility
Record the board used, wiring, library/version, supply arrangement, and measured behavior. Use the selected board-specific wiring example as the source of truth. Never assume visually similar modules share identical voltage tolerance or pin order.
Setting Up BLDC ESC with ESP32
Library
ESP32Servo by Kevin Harrington / John K. Bennett
Search "ESP32Servo" in Library Manager (Sketch > Include Library > Manage Libraries)
Wiring
| Component pin | ESP32 pin | Note |
|---|---|---|
| Signal | GPIO18 | Use ESP32Servo, not the standard Arduino Servo library — the ESP32's PWM hardware works differently and the stock library will not produce a clean signal |
| BEC + / - | Not connected (leave BEC unused, or see notes) | Only wire this in if you intentionally want the ESC to power the ESP32 — check the BEC's output current rating first |
| Battery + / - | Separate LiPo pack — not the ESP32's supply | |
| Motor wires (3) | BLDC motor phases — not connected to the ESP32 |
Swipe sideways to see every column →
ESP32Servo needs the explicit min/max pulse range passed to attach() — the defaults aren't always a good match for ESC arming ranges. Same arming behavior as the Uno: minimum throttle at boot before commanding any speed.
Related Components
DC Motor L298N
Classic brushed DC motor + dual H-bridge driver combo.
L298N Driver
Dual H-bridge motor driver — the standard for controlling two DC motors or one stepper.
NEMA17
The standard 42 mm stepper behind most 3D printers and small CNC machines.
Stepper 28BYJ48
Low-cost geared stepper for precise, low-speed positioning.
Related Guides & Projects
MicroPython vs Arduino on ESP32: Which Should You Learn First?
An honest comparison for beginners: where MicroPython is easier, where Arduino C++ is faster, how libraries and memory differ, and how to choose based on your project instead of hype.
MicroPython ESP32 Web Server: Control an LED or Relay from Your Browser
Create a working web server with the socket module, parse requests, serve a responsive control page for an LED or a relay, keep the displayed state truthful, choose a safe relay startup state and make the server survive bad or repeated requests.
MicroPython on ESP32 and Raspberry Pi Pico W: The Complete Guide
A structured MicroPython learning path for ESP32 and Pico W. Set up your tools, control GPIO, read sensors, connect to WiFi, build web servers, publish MQTT data and make projects reliable. Start here, then follow the links by level.
boot.py vs main.py in MicroPython: What Runs, When and Why
Understand the difference between boot.py and main.py in MicroPython, startup order, Wi-Fi setup, project structure, and recovery from boot errors.