Back to Tutorial

Smart Control: Stepper Motor with ESP32


🔍 What is the 28BYJ-48 Stepper Motor?

The 28BYJ-48 is a 5V unipolar stepper motor with a built-in reduction gearbox. This makes it ideal for applications requiring precise control at low speed.


🧾 Specifications

SpecificationValue
Motor TypeUnipolar Stepper
Rated Voltage5V DC
Number of Phases4
Coil Resistance~50Ω per coil
Step Angle (before gearbox)11.25°
Gear Reduction Ratio~64:1 (actually ~63.68395:1)
Steps Per Revolution (output shaft)2048 steps
Holding Torque~300 gf·cm
Wires5
Max Current~240mA (safe at ~100–200mA)

🔁 How Does It Work?

  • The motor has 4 coils and a common wire (VCC).
  • Coils are energized in a sequence to rotate the internal rotor.
  • The gearbox slows down output but increases torque and precision.

⚙️ Full Output Shaft Rotation:

  • Internal motor steps: 32 steps/rev (11.25° each)
  • Gearbox: 63.68395:1 ratio
  • Result:
    32 × 63.68395 ≈ 2048 steps/rev
    That’s 0.176° per step – very precise!

🎯 Advantages of 28BYJ-48

✅ Low voltage (5V) – safe for microcontrollers
✅ High torque due to gearbox
✅ Fine step resolution (2048 steps/rev)
✅ Cheap and widely available
✅ Compatible with ULN2003 board


🧲 Wiring Details

5 Wires (typically colored):

ColorFunctionULN2003 IN Pin
RedVCC (common)Motor power (not IN)
BlueCoil 1 (A)IN1
PinkCoil 2 (B)IN2
YellowCoil 3 (C)IN3
OrangeCoil 4 (D)IN4

🧪 Test & Troubleshooting

  • Motor not rotating? Check wiring and ULN2003 power.
  • Wrong direction? Reverse coil order (e.g., IN1 ↔ IN4).
  • Skipping steps? Add delay or check power supply.
  • Weak torque? Use a stronger 5V supply (≥500mA).

🛠 Advanced Tips

  • Use AccelStepper library for smoother motion.
  • Gearbox introduces backlash – not ideal for fast direction changes.
  • Not suitable for high-speed applications.
  • Use microcontroller sleep or disable pins to reduce heat when idle.

🔧 Real-Life Applications

  • Robot arms and legs (slow, accurate movement)
  • Camera sliders
  • Smart blinds/curtains
  • Automatic locks
  • Hobby CNC or XY plotters (light-duty)
HOW TO OPERATE

 

#include <Stepper.h>

const int stepsPerRevolution = 2048; // or the actual steps per revolution
#define IN1 19
#define IN2 18
#define IN3 5
#define IN4 17

Stepper myStepper(stepsPerRevolution, IN1, IN3, IN2, IN4);

void setup() {
  Serial.begin(115200);
  myStepper.setSpeed(15); // Set speed in RPM
}

void loop() {
  Serial.println("Clockwise");
  myStepper.step(stepsPerRevolution);
  delay(1000);

  Serial.println("Counterclockwise");
  myStepper.step(-stepsPerRevolution);
  delay(1000);
}

Share this post

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to Tutorial