Choosing a Motor

Compare servo, DC, and stepper motors for ESP32 — position control, continuous rotation, precise stepping, and when to use each

Motors make things move, but different motor types move in very different ways. Picking the wrong one for your project means fighting the hardware instead of building with it. This guide compares the three most common motor types in ESP32 projects and helps you choose the right one.

🔗Quick Recommendations

  • Move to a specific angle (robot arm, camera pan, door latch): Servo motor — built-in position feedback, no driver board needed.
  • Spin continuously (wheels, fans, pumps): DC motor with an H-bridge driver — simple speed and direction control.
  • Move in precise steps (CNC, 3D printer, camera slider): Stepper motor — exact positioning without feedback sensors.

🔗Comparison Table

FeatureServo (SG90)DC Motor + L298NStepper (28BYJ-48)
Motion typeRotate to a set angleContinuous rotationDiscrete steps
Range of motion$0\text{--}180°$ (standard)UnlimitedUnlimited
Position controlYes (built-in)No (needs encoder)Yes (open-loop)
Speed controlNo (fixed speed to target)Yes (PWM)Yes (step rate)
Holding torqueYes (actively holds position)No (freewheels when off)Yes (holds with power on)
Torque$1.8\,\text{kg·cm}$ @ $4.8\,\text{V}$Varies (motor-dependent)$\sim 300\,\text{g·cm}$
Driver neededNo (direct to GPIO)Yes (L298N or similar)Yes (ULN2003)
Signal typePWM ($50\,\text{Hz}$)PWM (any frequency)Step sequence (4-phase)
Supply voltage$4.8\text{--}6\,\text{V}$$5\text{--}35\,\text{V}$ (L298N)$5\,\text{V}$
Current draw$\sim 500\,\text{mA}$ stallVaries$\sim 240\,\text{mA}$
LibraryESP32ServoNone neededStepper (built-in)
PriceVery cheapCheap (motor + driver)Cheap (motor + driver)

🔗Servo Motor — Position Control

The servo motor rotates to a specific angle and holds it. You tell it "go to 90 degrees" and it goes there. Inside the housing, a potentiometer provides position feedback to a control circuit — this is why it knows where it is without any external sensors.

Best for:

  • Robot arms and grippers
  • Camera pan/tilt mechanisms
  • Door locks and latches
  • Sensor scanning (mounting an HC-SR04 on a servo)
  • Anything that needs to go to a position and stay there

Limitations:

  • Standard servos only rotate $0\text{--}180°$ — they cannot spin continuously (though "continuous rotation servos" exist, they lose position control)
  • Speed is fixed — you control position, not how fast it gets there
  • The SG90 has limited torque ($1.8\,\text{kg·cm}$) — for heavier loads, use an MG996R or a metal-gear servo
  • Draws power continuously while holding position, which can cause jitter on weak power supplies

Power tip: Never power servos from the ESP32's 3.3V pin. Use a separate $5\,\text{V}$ supply for the servo(s) and connect the grounds together.

🔗DC Motor — Continuous Rotation

A DC motor spins in one direction when you apply voltage, and the other direction when you reverse it. The speed depends on the voltage (controlled via PWM). It is the simplest motor type — but it has no idea where it is pointing.

Best for:

  • Wheels on robots and cars
  • Fans and ventilation
  • Pumps (peristaltic, water)
  • Anything that needs to spin continuously at a controllable speed

Limitations:

  • No position feedback — it does not know its angle or how many rotations it has made (you would need to add a rotary encoder for that)
  • Needs a driver — the L298N H-bridge lets you control direction and speed, but adds wiring and drops $\sim 1.5\text{--}2\,\text{V}$ internally
  • Freewheels when power is removed — no holding torque
  • Back-EMF when stopping/reversing can damage circuits without proper protection (the L298N handles this)

The L298N driver board supports two motors independently, making it ideal for differential-drive robots (two wheels, one per channel).

🔗Stepper Motor — Precise Steps

The stepper motor advances a fixed angle per electrical pulse. The common 28BYJ-48 takes $2{,}048$ half-steps per revolution, giving you precise control over position without any feedback sensor.

Best for:

  • Camera sliders and time-lapse rigs
  • Motorized blinds and curtains
  • CNC machines and 3D printers (with larger steppers like NEMA 17)
  • Anything that needs to move an exact amount and stop

Limitations:

  • Slow — the 28BYJ-48 tops out at about $15\,\text{RPM}$ reliably. Faster stepping causes missed steps and vibration.
  • Always on — the coils must stay energized to hold position, which generates heat. Disable the coils when holding is not needed.
  • Open-loop — if the motor misses steps (due to mechanical resistance or too-high speed), it has no way to detect or correct the error
  • The ULN2003 driver uses 4 GPIO pins (compared to 1 for servo or 2–3 for DC motor)
  • The 28BYJ-48 has low torque ($\sim 300\,\text{g·cm}$) — for anything beyond light loads, consider a NEMA 17 with an A4988 or DRV8825 driver

Pin order gotcha: The 28BYJ-48's internal wiring does not match the physical pin order. The correct GPIO sequence is documented in our stepper guide — get this wrong and the motor vibrates instead of spinning.

🔗Other Motor Types Worth Knowing

MotorWhat It IsWhen to Use It
Continuous rotation servoA modified servo that spins 360°Simple wheeled robots where you want servo-style PWM control without an H-bridge
NEMA 17 stepperLarger, more powerful stepperCNC, 3D printers, anything needing more torque than the 28BYJ-48
Brushless DC (BLDC)High-speed, high-efficiency motorDrones, high-speed fans — requires an ESC (electronic speed controller)
Linear actuatorMotor that pushes/pulls in a straight lineMotorized locks, adjustable stands, lift mechanisms

🔗Which Should You Pick?

Your SituationRecommendedWhy
Robot arm / gripperServoNeeds position control with holding torque
Two-wheel robotDC motor + L298NContinuous rotation with speed control, L298N drives 2 motors
Camera slider / time-lapseStepperPrecise, repeatable movement at slow speeds
Automatic blindsStepperMove an exact distance, then hold
Fan / ventilationDC motorContinuous rotation, speed via PWM
Scanning sensor mountServoPoint a sensor in different directions
Precise dispensing (liquid, filament)StepperExact volume/distance per step
Drone / high-speed applicationBrushless DC (BLDC)High RPM, high efficiency

🔗Next Steps