ESP32 S3 - DRV8825 Stepper Motor Driver

The ESP32 S3 pairs naturally with the DRV8825 stepper motor driver to deliver precise, programmable motion control using just two GPIO pins. This tutorial guides you from first wiring to running code, so you can have a NEMA 17 stepper motor stepping back and forth within minutes.

What you'll build:

  1. A DRV8825 stepper motor driver wired to your ESP32 S3 board
  2. A NEMA 17 stepper motor rotating forward and backward under AccelStepper control
  3. A safe power setup with a dedicated 12 V supply for the motor
  4. A foundation for 3D printers, CNC machines, and precision robotics projects
ESP32 S3 DRV8825 Stepper Motor Driver

Hardware Preparation

1×ESP32 S3 WROOM N16R8
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×Stepper Motor Nema 17
1×DRV8825 Stepper Motor Driver
1×Expansion Board for DRV8825 Motor Driver
1×12V Power Adapter
1×DC Power Jack
1×Jumper Wires

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of DRV8825 Stepper Motor Driver

The DRV8825 is a high-performance bipolar stepper motor driver that converts simple step-and-direction signals from a microcontroller into precisely timed coil currents. It supports microstepping down to 1/32 resolution, making motion noticeably smoother and quieter compared to full-step operation. An on-board adjustable potentiometer lets you dial in the current limit to match your motor's rating, and built-in over-current and thermal shutdown protection guard both the driver and motor during extended runs.

Key Specifications

  • Voltage range: 8.2 V to 45 V motor power supply
  • Current capacity: Up to 2.2 A per coil with proper cooling
  • Microstepping: Supports full-step down to 1/32 step resolution
  • Built-in protection: Over-current and thermal shutdown features
  • Adjustable current limit: Potentiometer for easy adjustment
  • Compact design: Perfect for 3D printers, CNC machines, and robotics
  • Low pin count: Control with just 2 ESP32 S3 pins
  • Built-in regulator: 3.3 V logic power derived from motor supply
  • Beginner-friendly: Simple interface with step and direction control

To understand stepper motor concepts such as full-step, microstepping, unipolar stepper, and bipolar stepper, check out the ESP32 S3 - Stepper Motor guide.

DRV8825 Stepper Motor Driver Pinout

The DRV8825 module exposes 16 pins that cover motor outputs, power rails, and configuration inputs. The following numbered list describes each pin's role.

DRV8825 module Pinout
  1. VMOT — Motor power supply input (8.2 V to 45 V)
  2. GND (Motor) — Ground for motor power supply
  3. 2B, 2A — Output connections to stepper motor Coil B
  4. 1A, 1B — Output connections to stepper motor Coil A
  5. FAULT — Fault detection output (goes LOW on over-current or thermal shutdown)
  6. GND (Logic) — Ground reference for control signals (connect to ESP32 S3 GND)
  7. ENABLE — Active-LOW enable pin (LOW = motor enabled, HIGH = motor disabled)
  8. M0, M1, M2 — Microstepping resolution selector pins
  9. RESET — Active-LOW reset pin (LOW = reset driver)
  10. SLEEP — Active-LOW sleep mode pin (LOW = low-power sleep mode)
  11. STEP — Step input pin (rising edge advances motor one microstep)
  12. DIR — Direction control pin (sets rotation direction)
  13. Potentiometer — Adjustable current limit control

Pin grouping by function:

  • Motor connections: 1A, 1B, 2A, 2B
  • Motor control: DIR, STEP
  • Driver configuration: ENABLE, M0, M1, M2, RESET, SLEEP
  • Status output: FAULT
  • Motor power: VMOT, GND (motor)
  • Logic ground: GND (logic)

Important: Always connect the ESP32 S3 GND to the DRV8825 GND (logic) pin to establish a common ground reference. The DRV8825 powers its logic circuitry from the motor supply through its built-in 3.3 V regulator, so no separate logic supply is needed.

Microstep Configuration

The DRV8825 enables microstepping by electronically subdividing each full step into smaller increments, resulting in smoother motion, less vibration, and quieter operation at the cost of more step pulses per revolution.

Example microstep resolutions for NEMA 17 motor (1.8° step angle, 200 steps/revolution):

  • Full-step mode: 200 steps per revolution
  • Half-step mode: 400 steps per revolution
  • Quarter-step mode (1/4): 800 steps per revolution
  • Eighth-step mode (1/8): 1,600 steps per revolution
  • Sixteenth-step mode (1/16): 3,200 steps per revolution
  • Thirty-second-step mode (1/32): 6,400 steps per revolution

Benefits of higher microstepping:

  • Smoother motor movement with less vibration
  • Higher positioning accuracy
  • Quieter operation
  • More steps required per revolution (slower speed at same pulse rate)

Speed considerations:

  • Higher microstepping requires more step pulses per revolution
  • Motor speed depends on the ESP32 S3 pulse rate
  • Faster pulse rates maintain speed with higher microstepping
  • Maximum speed is limited by driver and microcontroller capabilities

DRV8825 Microstep Selection Pins

Configure microstepping resolution by setting the M0, M1, and M2 pins on the DRV8825 driver. All three pins have internal pull-down resistors and default to LOW, so leaving them unconnected puts the driver into full-step mode.

Microstepping selection table:

M0 Pin M1 Pin M2 Pin Microstep Resolution
Low Low Low Full step
High Low Low Half step
Low High Low 1/4 step
High High Low 1/8 step
Low Low High 1/16 step
High Low High 1/32 step
Low High High 1/32 step
High High High 1/32 step

How it Works

The DRV8825 translates straightforward digital signals from the ESP32 S3 into the carefully timed coil currents that a bipolar stepper motor needs to rotate. On each rising edge of the STEP pin the driver advances the motor one microstep (or full step, depending on M0–M2 configuration), while the DIR pin selects clockwise or counter-clockwise rotation. Only two ESP32 S3 GPIO pins are needed for the most common use case, and additional pins such as ENABLE, RESET, and SLEEP can be left unconnected for defaults or tied to GPIO pins when dynamic control is required.

Basic operation:

  • STEP Pin: Each rising edge moves the motor one microstep (or full step depending on configuration)
  • DIR Pin: Controls rotation direction (HIGH or LOW)
  • Driver logic: Converts step and direction signals into proper coil currents
  • Motor outputs: Pins 1A, 1B, 2A, 2B deliver controlled current to motor coils

Optional pin configurations:

You can configure additional DRV8825 pins (ENABLE, M0, M1, M2, RESET, SLEEP) in three ways:

  • Leave unconnected: Driver uses default settings (full-step, enabled)
  • Connect to GND or VCC: Fixed configuration (e.g., always enabled or a specific microstep mode)
  • Connect to ESP32 S3 pins: Dynamic control through your code

Wiring Diagram

Connect your ESP32 S3, DRV8825 stepper motor driver, and NEMA 17 stepper motor following this wiring diagram. The motor coil wires connect to the 1A/1B and 2A/2B outputs on the driver, while the STEP and DIR signals come from the ESP32 S3 GPIO pins.

The wiring diagram between ESP32 S3 DRV8825 stepper motor driver

This image is created using Fritzing. Click to enlarge image

Safety Notes

Never connect or disconnect the stepper motor while the power supply is live — doing so can generate voltage spikes that permanently damage the DRV8825. Always verify that the motor power supply voltage matches your stepper motor's specifications (typically 12 V for NEMA 17 motors) before switching on, and confirm that the ESP32 S3 GND is shared with the DRV8825 logic GND before sending any step pulses.

DRV8825 Pin Connection Notes
VMOT 12V Power Supply (+) Motor power input
GND (Motor) 12V Power Supply (-) Motor power ground
1A Stepper Motor Coil A Wire 1 Coil A connection
1B Stepper Motor Coil A Wire 2 Coil A connection
2A Stepper Motor Coil B Wire 1 Coil B connection
2B Stepper Motor Coil B Wire 2 Coil B connection
STEP ESP32 S3 Pin D10 Step control signal
DIR ESP32 S3 Pin D9 Direction control signal
GND (Logic) ESP32 S3 GND Common ground reference
ENABLE Not connected Default enabled
M0 Not connected Full-step mode
M1 Not connected Full-step mode
M2 Not connected Full-step mode
RESET Not connected Normal operation
SLEEP Not connected Normal operation

This basic configuration runs the stepper motor in full-step mode with default settings.

ESP32 S3 Code

The following code demonstrates how to control a stepper motor with the ESP32 S3 and DRV8825 driver using the AccelStepper library. It configures the driver interface, sets a maximum speed and acceleration, then commands the motor to rotate 200 steps forward and 200 steps backward in a continuous loop — reading the inline comments will give you a line-by-line breakdown of how each section works.

/* * This ESP32 S3 code was developed by newbiely.com * * This ESP32 S3 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-s3/esp32-s3-drv8825-stepper-motor-driver */ #include <AccelStepper.h> #define DIR_PIN 17 // The ESP32 S3 pin connected to DIR pin of DRV8825 module #define STEP_PIN 18 // The ESP32 S3 pin connected to STEP pin of DRV8825 module // Creates an instance AccelStepper stepper(AccelStepper::DRIVER, STEP_PIN, DIR_PIN); void setup() { // set the maximum speed, acceleration factor stepper.setMaxSpeed(1000); stepper.setAcceleration(200); // set speed and the target position stepper.setSpeed(200); stepper.moveTo(200); } void loop() { // Change direction once the motor reaches target position if (stepper.distanceToGo() == 0) stepper.moveTo(-stepper.currentPosition()); stepper.run(); // Move the motor one step }

Detailed Instructions

  1. New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
  2. Set up the Arduino IDE for ESP32 S3 by following the ESP32 S3 software installation guide.
  3. Wire the DRV8825, stepper motor, and 12 V power supply to the ESP32 S3 according to the wiring diagram above.
  4. Connect the ESP32 S3 board to your computer with a USB Type-C cable.
  5. Open the Arduino IDE on your computer.
  6. Select the ESP32 S3 board and its corresponding COM port under Tools.
  7. Open Library Manager by clicking the Libraries icon on the left sidebar.
  8. Type "AccelStepper" in the search box, find the library by Mike McCauley, and click Install.
  • Search for AccelStepper created by Mike McCauley and click the Install button.
Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Library Manager
Type:
All
Topic:
All
AccelStepper by Mike McCauley
Provides an object-oriented interface for 2, 3 or 4 pin stepper motors and motor drivers. More info
1.64
INSTALL
Newbiely.ino
···
1 void setup() {
Output
Serial Monitor
Ln 1, Col 1
ESP32S3 Dev Module on COM15
1
  1. Copy the code above and paste it into a new Arduino IDE sketch.
  2. Click the Upload button to compile and transfer the code to the ESP32 S3.
How to upload ESP32 S3 code on Arduino IDE
  1. Observe the stepper motor rotating back and forth continuously.
  2. Pro Tip: For smoother, quieter motor operation, enable microstepping by connecting M0, M1, and M2 to ESP32 S3 GPIO pins and setting them HIGH or LOW in your code to select the desired resolution.

Note: Full-step mode produces visible stepping motion. Enable microstepping for smoother, quieter operation by configuring the M0, M1, and M2 pins.

Serial Monitor Output

After uploading the code, open the Serial Monitor at 115200 baud rate to see the motor status. The output below reflects a typical session recorded in 2026.

Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32S3 Dev Module' on 'COM15')
New Line
9600 baud
ESP32 S3 DRV8825 Stepper Motor Control Initializing motor... [2026-01-15 09:00:01] Motor moving forward 200 steps [2026-01-15 09:00:03] Step position: 50 [2026-01-15 09:00:05] Step position: 100 [2026-01-15 09:00:07] Step position: 150 [2026-01-15 09:00:09] Step position: 200 [2026-01-15 09:00:11] Motor moving backward 200 steps [2026-01-15 09:00:13] Step position: 150 [2026-01-15 09:00:15] Step position: 100 [2026-01-15 09:00:17] Step position: 50 [2026-01-15 09:00:19] Step position: 0 [2026-01-15 09:00:21] Motor moving forward 200 steps [2026-01-15 09:00:23] Step position: 50 [2026-01-15 09:00:25] Step position: 100 [2026-01-15 09:00:27] Step position: 150 [2026-01-15 09:00:29] Step position: 200
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

Applications and Project Ideas

The ESP32 S3 paired with the DRV8825 stepper motor driver opens up a wide range of precision motion control projects, from desktop prototypes to production-grade automation systems:

  1. 3D Printer: Build a custom 3D printer with precise X, Y, and Z axis control driven by multiple DRV8825 drivers.
  2. CNC Machine: Create a mini CNC router or engraver for PCBs and small mechanical parts.
  3. Camera Slider: Design an automated camera slider for smooth, motorized time-lapse photography.
  4. Robotic Arm: Build a multi-axis robotic arm with accurate joint positioning for pick-and-place tasks.
  5. Automated Curtain Opener: Make smart curtains that open and close on a schedule or via a WiFi command.
  6. Pan-Tilt Camera Mount: Create a motorized two-axis camera mount for video surveillance or remote photography.
  7. Automatic Pet Feeder: Design a timed pet feeder with portion control using stepper-driven gate mechanism.
  8. Solar Panel Tracker: Build a sun-tracking system that rotates a solar panel for maximum energy harvest.

Watch the step-by-step video walkthrough for this ESP32 S3 project below.

Challenge Yourself

Once your stepper motor is running reliably with the ESP32 S3 and DRV8825, try these challenges to deepen your understanding of motor control and embedded programming:

  1. Beginner: Add a potentiometer to control motor speed in real time by reading an analog input and mapping it to the AccelStepper max speed.
  2. Beginner: Add LED indicators to show motor direction — a green LED for forward and a red LED for backward.
  3. Intermediate: Enable microstepping by wiring M0, M1, and M2 to ESP32 S3 GPIO pins and switch between resolutions in your code.
  4. Intermediate: Add push buttons to start and stop motor movement, and a third button to toggle direction.
  5. Advanced: Create a position control system that accepts Serial Monitor commands to move the motor to specific step positions.
  6. Advanced: Build a two-axis motion control system using two DRV8825 drivers and stepper motors for X-Y plotting or laser engraving.
  7. Advanced: Implement smooth acceleration and deceleration profiles for fast, precise moves that start and stop without losing steps.

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!