ESP32 S3 UNO - Stepper Motor A4988 Driver
Seen from above, a small robot arm looks like a clock hand. The base turns and the gripper sweeps over the table: above the parts tray, above the box, and back to the middle. The base has to find these three spots again and again, and it must start and stop softly, or the whole arm begins to wobble. Here a NEMA 17 stepper motor turns that base in counted steps. The ESP32 S3 Uno gives the orders, and a DIYables A4988 module feeds the motor.
The stops on this page:
- Sort the A4988 pins into five small groups, and see why VDD gets 3.3V and never 5V on this board
- Decide how strong the base may push, with a tiny screwdriver and a multimeter
- Connect STEP to D3 and DIR to D2, once through a carrier board and once straight to the module
- Swing the base one full circle and back, with no library
- Send the base to PICK, PLACE and HOME with AccelStepper, with a gentle start and a gentle stop

The first program uses only built-in functions. For the second one you install a single library, and its Quick Steps show how.
Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
One part of this list is optional: the expansion board. With it, a capacitor, a motor plug, the RST-SLP link and the step size switches come ready-made. Without it, you do these few jobs yourself. Further down you find drawings for both.
Overview of A4988 Stepper Motor Driver
If the NEMA 17 is the muscle of the arm base, the A4988 is the nerve that tells the muscle what to do. DIYables puts this chip on a red 20 x 15 mm board in the well-known "StepStick" shape. The board comes with two strips of eight pins, soldered at the factory, plus a little stick-on heat sink. One board serves one joint of the arm: a single bipolar stepper motor with four wires. A six-wire motor can play that part too, with two of its wires left unused.

Sixteen pins sound like a lot, but they fall into five groups:
- The orders (STEP, DIR): every pulse on STEP is one step of the base. DIR says to which side. They are the only two signals from the ESP32 S3 Uno: STEP from D3 (GPIO17), DIR from D2 (GPIO18).
- The step size (MS1, MS2, MS3): three inputs that split a step into smaller ones. With nothing connected they read LOW, and the motor makes full steps.
- Awake or asleep (EN, RST, SLP): EN works upside down. HIGH releases the motor, LOW keeps it under power, and the module itself holds EN at LOW. RST and SLP both stop the driver at LOW. SLP has a pull-up, but RST floats, so one short link from RST to SLP keeps the two of them HIGH.
- The coils (2B, 2A, 1A, 1B): 2B and 2A are for one coil of the motor, 1A and 1B for the second coil. Do not let the print confuse you: seen from above the labels are B2, A2, A1, B1, seen from below they are 2B, 2A, 1A, 1B.
- The supplies (VMOT, VDD, two times GND): 12V enters at VMOT and the GND beside it. 3.3V enters at VDD and the GND beside it. The module connects its two GND pins to each other.
| DIYables A4988 Stepper Motor Driver Module | |
|---|---|
| Made for | one bipolar stepper motor |
| VMOT range | 8V to 35V DC, here 12V |
| VDD range | 3V to 5.5V, here 3.3V |
| Current per coil with a bare chip | about 1A |
| Current per coil with heat sink and good cooling | up to 2A |
| Step sizes | full, 1/2, 1/4, 1/8, 1/16 |
| Protection | over-temperature shutdown, under-voltage lockout, crossover-current protection |
| FAULT pin | no |
What one pulse does
A pulse is a short HIGH on STEP. The moment the level rises, the base moves by one step (or one microstep). Stay HIGH for at least 1 microsecond, and then LOW for at least 1 microsecond, and the chip never misses a pulse. Which coil has to be switched for that step? You do not need to know. A block in the chip, called the translator, has the coil pattern of all steps, so the sketch has only one job: counting.
The chip also looks after the current. When a coil reaches its limit, the chip switches it off for a moment, then on again, and so on. People call this chopping. Thanks to it, 12V does no harm to a motor whose label says 2V to 4V.
The bar that VDD sets
Unlike the DRV8825, the A4988 cannot power its own logic, so VDD is a wire you may not forget. VDD also works like the bar in a high jump. A signal counts as HIGH only if it jumps over 70% of VDD, and a pulse from the ESP32 S3 Uno jumps to 3.3V:
| VDD comes from | Height of the bar | Result for a 3.3V pulse |
|---|---|---|
| 3V3 | about 2.3V | over the bar, always HIGH |
| 5V | 3.5V | under the bar, not a safe HIGH |
For this board there is one answer only: VDD goes to 3V3 and never to 5V.
From 1.8° down to 0.1125°
In full steps the base jumps by 1.8° per pulse. Close to the motor that is tiny, but at the end of a long arm you can see it. Microsteps cut the jump into 2, 4, 8 or 16 parts. The 3-way DIP switch of the expansion board does the cutting (ON means HIGH). Its numbers run backward: MS1 has switch 3, MS2 has switch 2, MS3 has switch 1. On the bare module, a wire from an MS pin to 3V3 is HIGH and a free pin is LOW.
| Base angle per pulse | Step size | Switch 3 (MS1) | Switch 2 (MS2) | Switch 1 (MS3) | Steps per turn |
|---|---|---|---|---|---|
| 1.8° | full | OFF, LOW | OFF, LOW | OFF, LOW | 200 |
| 0.9° | 1/2 | ON, HIGH | OFF, LOW | OFF, LOW | 400 |
| 0.45° | 1/4 | OFF, LOW | ON, HIGH | OFF, LOW | 800 |
| 0.225° | 1/8 | ON, HIGH | ON, HIGH | OFF, LOW | 1600 |
| 0.1125° | 1/16 | ON, HIGH | ON, HIGH | ON, HIGH | 3200 |
With fine steps the gripper glides more quietly, but a quarter turn then takes 200 pulses (1/4), 400 (1/8) or 800 (1/16) and not 50. The sketch cannot see the switches. It has the constant MICROSTEPS for this, and the number there must fit the table row you chose.
How strong may the base push?
The small trimmer answers this question. It sets a voltage, VREF, and VREF sets the highest coil current. DIYables uses two sense resistors of 0.1 ohm (you can read R100 on them), and with these the math is short:
VREF = 0.8 × coil current
| Coil current | VREF |
|---|---|
| 0.5A | 0.40V |
| 0.7A | 0.56V |
| 1A | 0.80V |
This is how you adjust it:
- USB in, 12V out. The 3.3V on VDD is all that the trimmer needs.
- Find the test point. It is the metal head of the trimmer itself. Measure from there to GND, with the multimeter on its DC voltage range.
- Make very small turns. Read the display after each one. Keep the screwdriver tip on the trimmer, because a slip to the next part can make a short circuit.
- Begin at the low end. A weak base that skips steps may get a bit more. The motor datasheet tells you where to stop.
Is there another number on your sense resistors? A4988 boards of other brands can carry R050, and then VREF = 0.4 × coil current. Both rules come from current = VREF / (8 × Rs).
※ NOTE THAT:
Between two moves the motor grips the base with that same current. A warm driver and a warm motor are therefore normal, even if the arm has not moved for minutes. If the driver gets very hot, lower VREF and add the heat sink.
Overview of Stepper Motor
A bipolar stepper motor like our NEMA 17 hides two separate coils in its body. Each coil ends in two wires, which makes four. One full step is worth 1.8° of shaft angle, and 360 divided by 1.8 makes 200 steps for a round trip.

| Motor wire | Also called | Colour on our example motor | Driver pin |
|---|---|---|---|
| A | A+ or A | black | 2B |
| C | A- or A with a bar | green | 2A |
| B | B+ or B | red | 1A |
| D | B- or B with a bar | blue | 1B |
Colours are not a standard. If your datasheet says something else, the datasheet is right. And if there is no datasheet, ask the wires:
- With a multimeter: between the two ends of one coil it shows a few ohms. Between ends of different coils it shows no connection.
- With your fingers: hold two wire ends against each other and spin the shaft. Does it suddenly drag? Then both ends belong to one coil.
A coil that is connected the wrong way round is no problem, because it just makes the base rotate to the other side. Trouble starts when one wire of each coil shares a pair of pins. The motor then buzzes and shivers but goes nowhere.
ESP32 S3 Uno Pinout
Four spots on the ESP32 S3 Uno matter here: 3V3 and GND for the logic side of the driver, D3 (GPIO17) for STEP and D2 (GPIO18) for DIR. In the drawings below, these two header holes carry their GPIO names, IO17 and IO18.

※ NOTE THAT:
Why not D4 and D5, right beside them? On this board they are GPIO19 and GPIO20, and those two carry the USB data of the chip. D6 (GPIO3) and D9 (GPIO46) have a second life as strapping pins: the chip reads them while it boots. D2 and D3 have no such side job.
Wiring Diagram
With the expansion board
The black 42 x 42 mm expansion board is a seat for the driver module, with two sockets of eight holes. It accepts the A4988 and the DRV8825. From there, two signal wires, one 3.3V wire and one ground wire lead to the ESP32 S3 Uno.

This image is created using Fritzing. Click to enlarge image
※ NOTE THAT:
Look twice before you press the module into its sockets. The board has a small arrow with the word "VIN": the VMOT corner of the module belongs there. The row with EN at one end and DIR at the other then faces the G V S header. The wrong way round can kill the module.
| ESP32 S3 Uno / Other Part | Expansion Board |
|---|---|
| D3 (GPIO17) | STEP row, S pin |
| D2 (GPIO18) | DIR row, S pin |
| 3V3 | a V pin |
| GND | a G pin |
| 12V adapter, + screw of the DC power jack | VIN |
| 12V adapter, - screw of the DC power jack | GND (next to VIN) |
| Motor wires A (black) and C (green) | motor plug 2B and 2A |
| Motor wires B (red) and D (blue) | motor plug 1A and 1B |
| nothing | EN row (free means on) |
It makes no difference which V pin and which G pin you take, since the three of each kind are connected. But do connect the V wire. A DRV8825 in this seat would run without it, an A4988 gets its VDD from it. All DIP switches stay OFF for now. The link from RST to SLP and a 100uF / 35V capacitor are part of the board.
Do not search for a brown, a yellow, a pink or a purple wire on your motor. The drawing just paints its four motor lines that way.
A turning arm shakes the table a little with every move, and after a while jumper wires creep out of their holes. Screws do not. Two shields turn the header of the ESP32 S3 Uno into screw terminals, the Screw Shield V2 and the Proto Screw Terminal Block Shield. Here is the first one with our four wires, where the terminals for STEP and DIR have the marks 3 and 2:

This image is created using Fritzing. Click to enlarge image
WARNING
- 12V has one address: VIN on the expansion board, or VMOT on the bare module. On a pin of the ESP32 S3 Uno it ends the life of the board.
- 3.3V for the logic: V and VDD come from 3V3. The 5V pin is right next to it on the header, so check it twice.
- One common ground: adapter minus, driver and ESP32 S3 Uno share the same GND.
- Leave the motor plug alone under power. Taking the motor off a live A4988, or adding it, gives a spike of voltage, and the chip can die from it.
- 12V comes last: all other wires first, a second look at them, then the adapter.
Without the expansion board
Straight to the module, the plan is the same: two signals, 3.3V, ground and 12V. A short RST-SLP link is added.

This image is created using Fritzing. Click to enlarge image
| A4988 Module | ESP32 S3 Uno / Other Part |
|---|---|
| STEP | D3 (GPIO17) |
| DIR | D2 (GPIO18) |
| VDD | 3V3 |
| GND beside VDD | GND |
| VMOT | 12V adapter, + screw of the DC power jack |
| GND beside VMOT | 12V adapter, - screw of the DC power jack |
| 2B and 2A | motor wires A (black) and C (green) |
| 1A and 1B | motor wires B (red) and D (blue) |
| RST | SLP (a short wire from pin to pin) |
| EN, MS1, MS2, MS3 | free |
※ NOTE THAT:
- Orange jumper: this is the RST-SLP link in the drawing. A driver without it stays in reset, and the base never turns.
- Missing in the drawing: a 100uF capacitor between VMOT (+ leg) and the GND beside it, right at the module. Best is one rated for 35V or more. It catches voltage peaks on the 12V side.
Screw terminals work for the bare module as well:

This image is created using Fritzing. Click to enlarge image
How To Program For A4988 Stepper Motor Driver
Everything comes down to one question: how many pulses, to which side, and how fast?
- Give the two pins a name. The ESP32 core wants GPIO numbers, so header D3 is 17 and header D2 is 18:
- Work out the pulses for one turn. 200 full steps, multiplied by the microstep number of your DIP switches:
- Make one pulse. 2000 microseconds HIGH and 2000 LOW is 4 ms per step, so 250 steps per second. In full step that is 75 turns per minute, slow enough for a NEMA 17 to start without a run-up:
- Choose the side before you send pulses. Set DIR, give it a few microseconds, then start:
- Think in angles. A robot arm talks in degrees, and the driver counts steps. The formula between the two is steps = angle × steps per turn / 360:
lround() rounds to the nearest whole step. In full step, 72° is exactly 40 steps. An angle like 50° is 27.8 steps, so the base stops at step 28, which is 50.4°. With 1/8 steps the same 50° is 222 steps, or 49.95°.
- Let a library shape the speed. AccelStepper is told that a STEP / DIR driver is connected, then it gets a target. run() makes a step whenever one is due, and it speeds up and slows down by itself:
ESP32 S3 Uno Code - Stepper Motor A4988 Driver
This sketch is the first health check of your wiring. The base goes all the way around, waits 1.2 seconds, goes back the same way, waits again, and repeats this until you pull the plug. It needs no library.
Detailed Instructions
- Arduino IDE not ready yet? Follow ESP32 S3 Uno - Getting Started to add the ESP32 core.
- Give the motor a paper arm. The real arm stays off for now. A strip of paper, fixed to the shaft with tape, shows every move and breaks nothing.
- Do the wiring and check that the DIP switches are OFF. The 12V adapter is still lying on the table.
- Plug the USB Type-C cable into the computer and the ESP32 S3 Uno. The driver logic now has power, so this is the moment to adjust VREF.
- In Arduino IDE, set the board to ESP32S3 Dev Module and choose its COM port.
- Put the code above into an empty sketch and send it to the board with Upload.

- Give the motor its 12V. Remember where the paper arm points.
- Start the Serial Monitor, pick 9600 baud and press RESET. The text runs in step with the motor:
- Judge the paper arm, not the text. After each line it has to point exactly where it pointed before. If it does not, the DIP switches and MICROSTEPS disagree, or the motor skips steps.
ESP32 S3 Uno Code - PICK, PLACE and HOME with AccelStepper
Now the base gets a job. It goes to PICK, then to PLACE on the other side, then HOME, with a pause of 1.5 seconds at each stop. The speed grows step by step at the start of a move and shrinks step by step before the end, so the arm does not swing.
| Stop | Angle from HOME | Target in full steps | Way to go |
|---|---|---|---|
| PICK | 72° | 40 | 40 steps |
| PLACE | -126° | -70 | 110 steps |
| HOME | 0° | 0 | 70 steps |
Detailed Instructions
- Go to the Library Manager in Arduino IDE (the Libraries icon at the side).
- Enter "AccelStepper" as the search word. You want the entry by Mike McCauley.
- Add it with Install:
- Search for AccelStepper created by Mike McCauley
and click the Install button.
- Swap the sketches: pull the 12V plug, clear the editor, paste the new code, Upload.
- Set HOME by hand. Turn the paper arm until it points straight ahead.
- Start the motor and the counter together. Keep RESET pressed, bring the 12V back, then let RESET go.
- Read the route in the Serial Monitor, still with 9600 baud:
- Follow one long move with your eyes. On the way from PICK to PLACE, the base gets faster for 55 steps and slower for 55 steps. It never reaches TOP_SPEED (600 steps per second), because the way is too short for that. To make the arm livelier or calmer, change SPEED_GAIN.
- Try it with 1/8 steps. Switches 3 and 2 go ON, switch 1 stays OFF, and the sketch gets MICROSTEPS 8. The stops are at the same angles as before, with a finer motion in between.
※ NOTE THAT:
loop() must come round very often, because armBase.run() makes at most one step per call. This is why the pause uses millis(). A delay() while the base is moving would stop the pulses in the middle of the move.
Video Tutorial
Additional Knowledge
A4988 or DRV8825?
Both drivers plug into the same seat and listen to the same two signals, so in full step the sketches of this page run with either of them. What is different is the power they can handle:
| A4988 (on this page) | DRV8825 | |
|---|---|---|
| Motor supply | 8V to 35V | 8.2V to 45V |
| Coil current without cooling | about 1A | about 1.5A |
| Coil current with cooling | 2A | 2.2A |
| Finest step | 1/16 | 1/32 |
| VDD wire | required, 3V3 on this board | none |
The base of a light arm is easy work, so the A4988 is enough. If a heavier arm asks for more current, look at the DRV8825. And if your base has a plain DC motor with two wires, neither of them fits: take an H-bridge such as the one in ESP32 S3 Uno - BTS7960 Motor Driver.
HOME is only a number
The ESP32 S3 Uno counts the pulses it sends. It cannot feel the shaft. If somebody holds the arm, or if you move it while the power is off, the counter and the real angle no longer agree, and nothing tells the sketch. The usual cure is a homing run: turn slowly toward a switch, stop at the click and call that place step 0.
Ideas for the arm base
- Homing run: mount a lever switch beside the base and read it as in ESP32 S3 Uno - Limit Switch. At the click, call armBase.setCurrentPosition(0).
- Steer by hand: turn the stick of ESP32 S3 Uno - Joystick into a target angle for moveTo().
- Add a gripper: open it at PLACE and close it at PICK with a small servo, see ESP32 S3 Uno - Servo Motor.
- Teach new stops: dial the base to a spot with ESP32 S3 Uno - Rotary Encoder and store the step number when you press the knob.
- Buttons on the phone: make PICK, PLACE and HOME three links of a small site, with the code of ESP32 S3 Uno - Web Server.
Function References
FAQ
VDD accepts up to 5.5V. What is wrong with the 5V pin?
The A4988 would be fine with it, but your signals would not. The bar for a HIGH moves up to 3.5V, and a pin of the ESP32 S3 Uno ends at 3.3V. Some pulses may count and others may not, so the base would stop at the wrong angle.
Where do the numbers 17 and 18 in the code come from?
They are the GPIO numbers behind the header names: D3 is GPIO17 and D2 is GPIO18. If you write 3 and 2 in the sketch, the pulses come out of other pins of the chip, and the motor stays still.
Why can I not move the arm by hand while the program rests?
The driver keeps the coils under current and holds the base. To let go of it, wire the EN row to D8 (GPIO21) and write HIGH to 21. LOW grips again. A hand that moves the arm in between is invisible to the step counter, so do a new homing run after that.
Can the same ESP32 S3 Uno run the shoulder motor too?
Yes. Each motor needs its own A4988 with its own STEP and DIR pins, for example D8 (GPIO21) for STEP and D7 (GPIO14) for DIR. The 3V3, GND and 12V wires are shared, as long as the adapter can feed both motors. In the second program, create one more AccelStepper object and call its run() in loop() as well.
Is the USB cable not enough to power the motor?
No. VMOT starts at 8V, and USB brings 5V. The cable feeds the ESP32 S3 Uno, and over its 3V3 pin the logic half of the driver. The muscle power always comes from the adapter.
Troubleshooting
| Problem | Possible Cause | Solution |
|---|---|---|
| Text scrolls in the Serial Monitor, but the shaft does not move | VDD gets no 3.3V, or the driver is held in reset | Check the wire from 3V3 to V (or VDD). On the bare module, look at the RST-SLP link |
| The shaft is easy to turn by hand with the 12V adapter plugged in | No motor power, or EN is HIGH | Check VIN and GND, the DC power jack and that the EN row is free |
| Motor buzzes and shivers on the spot | The coil pairs are mixed up, or VREF is too low | Unplug 12V, search for the wire pairs again, then raise VREF a little |
| Short moves work, quick long ones stall | Speed or acceleration is too high | Make SPEED_GAIN and TOP_SPEED smaller, or PULSE_HALF bigger in the first sketch |
| PICK and PLACE are on the wrong sides | One coil is connected the other way round | Unplug 12V and exchange the two wires of one coil, for example on 1A and 1B |
| The base stops at half or twice the angle | The DIP switches do not fit the MICROSTEPS number | Compare with the step size table, and remember that MS1 has switch 3 |
| The driver is too hot, or it pauses and starts again | VREF is set too high | Lower VREF, glue on the heat sink, let air reach it |
| The stops wander away after some minutes | The motor skips steps under the load | Use a smaller SPEED_GAIN, raise VREF within the motor rating, add a homing run |
| Arduino IDE shows no port for the board | The cable carries only power, or the USB chip has no driver on the computer | Try another cable, install the CH340 or CP210x driver, or press RESET with BOOT held down |
| The Serial Monitor shows only symbols | It listens at another speed than 9600 | Choose 9600 baud at the top right of the Serial Monitor |