Quick Start
Getting a stepper turning takes three things: a logic connection to your controller, a separate supply for the motor, and a current limit set to suit the motor you have. Do the current limit first, before the motor ever turns, so the coils are never asked to carry more than they are rated for. The procedure is on Hardware Details.
The examples here use the NULA DeepSleep ESP32-S3 as the controller. Any board with five spare digital pins and 3V3 or 5V logic works; only the pin numbers change.
You program the controller connected to this breakout. The breakout itself is not flashed.
- Arduino
- MicroPython
1. Connect the breakout board
RESET and SLEEP both have to sit high for the driver to run, and both have internal pulldowns, so an unconnected board stays in reset and asleep. The Arduino library never touches them. Tie them to 3V3 and leave them there.
| Controller | Stepper Motor Driver DRV8825 Board |
|---|---|
| GND | GND (the pad next to FAULT) |
| 3V3 | RST |
| 3V3 | SLEEP |
| IO5 | STEP |
| IO4 | DIR |
Motor power is separate and does not come from the controller:
| Motor supply | Stepper Motor Driver DRV8825 Board |
|---|---|
| 8.2 V to 45 V | VIN |
| GND | GND (the pad next to VIN) |
Put a capacitor across the motor supply at the board. The MicroPython module's own example notes this; check your motor's datasheet for the value.
2. Install the library
Install Soldered Basic Stepper Driver Arduino Library using the Arduino IDE Library Manager, or download it from the source below.
🔗Soldered Basic Stepper Driver Arduino Library
AccelStepper-based Arduino library by Soldered
Tip: downloading from GitHub. On the library's GitHub page, click the green Code button and choose Download ZIP, then add it in Arduino IDE with Sketch → Include Library → Add .ZIP Library....
3. Run the first example
This is ConstantSpeed.ino with one change: the shipped sketch is constructed
with the FULL4WIRE default, and this board needs BasicStepper::DRIVER with
your STEP and DIR pins. Nothing else differs.
#include <Basic-Stepper-Driver-SOLDERED.h>
#define dirPin 4
#define stepPin 5
BasicStepper stepper(BasicStepper::DRIVER, stepPin, dirPin);
void setup()
{
stepper.setMaxSpeed(1000);
stepper.setSpeed(200);
}
void loop()
{
stepper.runSpeed();
}
4. Check the result
The motor turns continuously in one direction at 200 steps per second, which is about one revolution per second on a 200-step motor in full step. There is no serial output, so watch the shaft.
If it buzzes or judders instead of turning, runSpeed() applies no acceleration
and the motor may not be able to start at that speed under load. Lower
setSpeed() until it turns, then work back up.
5. If it does not work
Continue with Troubleshooting and retry this smallest example after each change.
1. Connect the breakout board
The MicroPython module drives ENABLE, RESET and SLEEP itself, so all five control pins go to GPIO.
| Controller | Stepper Motor Driver DRV8825 Board |
|---|---|
| GND | GND (the pad next to FAULT) |
| IO4 | DIR |
| IO5 | STEP |
| IO6 | EN |
| IO7 | RST |
| IO10 | SLEEP |
Motor power is separate and does not come from the controller:
| Motor supply | Stepper Motor Driver DRV8825 Board |
|---|---|
| 8.2 V to 45 V | VIN |
| GND | GND (the pad next to VIN) |
Wire the motor's two coils to B1/B2 and A1/A2, one coil per pair. Put a capacitor across the motor supply at the board; check your motor's datasheet for the value.
2. Install the module
Install DRV8825 with mpremote, using the command from the module's own
README:
mpremote mip install github:SolderedElectronics/Soldered-Micropython-modules/Actuators/DRV8825
On Windows:
python -m mpremote mip install github:SolderedElectronics/Soldered-Micropython-modules/Actuators/DRV8825
🔗Soldered MicroPython Modules: DRV8825
MicroPython module and examples for this board
Tip: downloading from GitHub. Without mpremote, open the module's .py
file on GitHub and click Download raw file, then open it in Thonny and use
File → Save as... → MicroPython device to copy it onto the board.
3. Run the first example
This is drv8825-motorRotationAndSleep.py, the module's own example for this
board. It turns the motor one full rotation, one back, then puts the driver to
sleep. Which way it turns first depends on how you wired the coils.
The five pin numbers below are the only change from the recorded example, which uses GPIO 5, 18, 19, 21 and 22. The NULA DeepSleep ESP32-S3 does not break out GPIO18, and the ESP32-S3 has no GPIO22 at all.
from drv8825 import DRV8825
from time import sleep
# Define pin numbers (adjust to match your board setup)
DIR_PIN = 4 # GPIO4
STEP_PIN = 5 # GPIO5
EN_PIN = 6 # GPIO6 (optional)
RST_PIN = 7 # GPIO7 (optional)
SLP_PIN = 10 # GPIO10 (optional)
# The motor should be connected via the B1,B2,A1,A2 pins
# The motor power supply should be connected to the VIN and GND pins and have a
# parallel connected capacitor, reffer to your motors datasheet for more information
# Initialize the driver
motor = DRV8825()
motor.begin(DIR=DIR_PIN, STEP=STEP_PIN, EN=EN_PIN, RST=RST_PIN, SLP=SLP_PIN)
# Configure motor behavior
motor.setStepsPerRotation(200) # Typical for 1.8° stepper motors
motor.setStepPulseLength(1000) # Microseconds per step pulse
motor.setDirection(DRV8825.CLOCK_WISE)
motor.enable()
# Step the motor forward 200 steps (one full rotation)
print("Stepping forward...")
for _ in range(200):
motor.step()
sleep(0.005) # 5ms delay between steps
# Change direction and step back
motor.setDirection(DRV8825.COUNTER_CLOCK_WISE)
print("Stepping backward...")
for _ in range(200):
motor.step()
sleep(0.005)
# Put the motor to sleep
motor.sleep()
print("Motor is now sleeping.")
4. Check the result
Three lines on the serial console, exactly as written:
Stepping forward...
Stepping backward...
Motor is now sleeping.
The motor turns 200 steps, reverses, and returns to where it started. On a 1.8° motor in full step, 200 steps is one full rotation. If you have changed the microstep setting with M0, M1 or M2, the same 200 pulses cover proportionally less: at 1/8 microstep they are one eighth of a turn.
After the last line the driver is asleep and holding nothing, so the shaft turns freely by hand.
5. If it does not work
Continue with Troubleshooting and retry this smallest example after each change.