ESP32 S3 - Stepper Motor A4988 Driver

Point a camera at the night sky, keep the shutter open for a minute, and every star becomes a short line. The sky did not jump. The Earth turned, and the camera turned with it. A barn door tracker solves this with two small boards and a hinge between them: a threaded rod pushes the boards apart, very slowly, and the camera on the upper board keeps looking at the same stars. What the rod needs is a calm motor. In this guide the ESP32 S3 drives a NEMA 17 stepper motor through a DIYables A4988 module. It turns the rod once per minute during the photo and winds it back quickly afterwards. For all the tests here, a bare motor on your desk is enough.

What you'll build in this tutorial:

  1. An A4988 module that is ready for work: 3.3V on VDD, a safe coil current, and the step size that fits your project
  2. A circuit with STEP on GPIO1, DIR on GPIO2, 3V3 and GND, plus a 12V adapter for the motor, once on an expansion board and once on the bare module
  3. A short test sketch, written with plain Arduino functions, that turns the rod once each way
  4. A tracker sketch with AccelStepper: slow 1/16 steps during the shot, then a rewind that speeds up and slows down softly
NEMA 17 star tracker motor stepped by an A4988 driver and an ESP32 S3

Hardware Preparation

1×ESP32 S3 WROOM N16R8
1×Alternatively, ESP32 S3 SuperMini Dev Module
1×Alternatively, ESP32 S3 Uno-form Board
1×Alternatively, ESP32 S3 Camera Board
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×A4988 Stepper Motor Driver
1×Expansion Board for A4988
1×12V Power Adapter
1×DC Power Jack
1×Jumper Wires
1×Recommended: Screw Terminal Expansion Board for ESP32 S3
1×Recommended: Breakout Expansion Board for ESP32 S3
1×Recommended: Power Splitter for ESP32 S3

Or you can buy the following kits:

1×DIYables ESP32 S3 Starter Kit (ESP32 S3 included)
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 .

The expansion board is optional. In its place, the bare module asks for a 100uF capacitor and one more jumper, and the wiring part explains both.

Overview of A4988 Stepper Motor Driver

Pin labels of the A4988 stepper motor driver module: EN, MS1, MS2, MS3, RST, SLP, STEP, DIR on one side, VMOT, GND, 2B, 2A, 1A, 1B, VDD, GND on the other

A GPIO pin is strong enough for a signal, not for a motor coil. So the work is shared. The ESP32 S3 says "one step now" and "this way", and the A4988 sends the real current into the coils. DIYables builds the chip onto a red board that measures about 20 x 15 mm. Makers know this shape under the name "StepStick". Its two rows of 8 pins need no soldering, and the package brings a small heat sink that sticks to the chip. Each module takes care of exactly one bipolar stepper motor with four wires. Does your motor have six? Four of them are enough, and the other two stay loose.

Key Specifications

The motor side accepts 8V to 35V DC, the logic side 3V to 5.5V. Expect about 1A per coil from a bare chip, and up to 2A once the heat sink is on and the air can carry its warmth away.

Item On this module
Motors 1 bipolar stepper motor
Motor power on VMOT 8-35V DC, here from a 12V adapter
Logic power on VDD 3-5.5V, here from the 3V3 pin
Coil current about 1A, up to 2A with good cooling
Step sizes five of them, full step down to 1/16 step
STEP pulse HIGH for 1 microsecond or more, LOW for 1 microsecond or more
Protection shuts down when too hot or when the voltage is too low, guards against crossover current
Error output none (there is no FAULT pin)

A4988 Pinout

Lay the module on the table with EN at the top left. Read the left row from top to bottom, then the right row:

  1. EN — on/off switch of the motor outputs; LOW or no wire means on, HIGH lets the shaft turn freely (the module itself holds this pin LOW)
  2. MS1, MS2, MS3 — the three step size inputs; each one is LOW until you wire it
  3. RST — reset, acts at LOW; it floats, which means nothing on the module decides its level, so it has to be joined to SLP
  4. SLP — sleep, acts at LOW; the module pulls it up
  5. STEP — one move each time it goes from LOW to HIGH
  6. DIR — its level chooses the turning direction
  7. VMOT — plus of the motor supply
  8. GND (under VMOT) — return line of the motor supply
  9. 2B, 2A — output pair for one coil of the motor
  10. 1A, 1B — output pair for the coil that is left
  11. VDD — plus of the logic supply
  12. GND (under VDD) — logic ground; a track on the module links it with the GND above

You may search in vain for "2B" on the upper face of the real board. It says B2, A2, A1, B1 there, and 2B, 2A, 1A, 1B on the lower face. The pins are the same.

What One Pulse Does

A stepper motor moves when its coils get current in the right order, and the A4988 knows this order by heart. Its translator (so the block is named) holds the coil pattern of each step. A rising edge on STEP makes it go one pattern further. Your sketch only has to make edges and count them.

There is a second helper inside. When the current in a coil climbs to the limit, the chip cuts it for an instant, lets it climb again, and so on. This is named current chopping. Because of it, a 12V supply does not burn a motor that is rated for 2V to 4V.

VDD Goes to 3V3

The A4988 cannot make a logic voltage from the 12V, so VDD must get its own wire. VDD also decides which pulses count. A pulse is HIGH for the chip only when it rises over 0.7 x VDD. A GPIO of the ESP32 S3 reaches 3.3V. Let us compare the two supplies. With 3.3V on VDD, the chip wants 2.31V, and the GPIO beats that with ease. With 5V on VDD, it wants 3.5V, and 3.3V is too low for that, so pulses may be missed. The rule for this board is simple: VDD (or V on the expansion board) belongs on 3V3 and never on 5Vin.

Step Size and the Three DIP Switches

Picture the tracker in full steps. The rod makes 200 moves in its minute, one small kick every 0.3 seconds, and a long lens can show that as a blurred star. In 1/16 steps, the same minute holds 3200 tiny moves. The motor is smoother and quieter, but each turn costs more pulses. The expansion board has three small switches for this. ON gives HIGH, OFF gives LOW, and the numbering goes backward: look for MS1 at switch 3 and for MS3 at switch 1.

Step size MS1 (switch 3) MS2 (switch 2) MS3 (switch 1) Pulses for 1 rod turn Pulses per second at 1 turn per minute
full OFF OFF OFF 200 3.3
1/2 ON OFF OFF 400 6.7
1/4 OFF ON OFF 800 13.3
1/8 ON ON OFF 1600 26.7
1/16 ON ON ON 3200 53.3

For 1/16 you simply push all three switches to ON. On the bare module, a jumper from an MS pin to 3V3 does the job of an ON switch. The ESP32 S3 cannot read these switches. So each time you move them, write the same step size into MICROSTEPS in the sketch.

Set the Current Limit

A small screw on the module, the trimmer, sets the highest current that a coil may get. You check it with a multimeter, because the trimmer voltage (called VREF) tells you the limit: current = VREF / (8 x Rs). To know Rs, look at the two tiny sense resistors. The print R100 on the DIYables module stands for 0.1 ohm, so all you need is VREF = 0.8 x current. Boards from other makers can carry R050. For those, calculate VREF = 0.4 x current.

Current you want VREF with R100 VREF with R050
0.4A 0.32V 0.16V
0.7A 0.56V 0.28V
1A 0.80V 0.40V
  1. Keep the 12V adapter away for now. USB power is fine, because VDD only needs the 3V3 pin.
  2. Choose a DC voltage range on the multimeter. Hold one probe on GND and touch the metal top of the trimmer with the other.
  3. Give the trimmer a tiny turn with a small screwdriver, then look at the display again. Do not let the tip slide onto the parts around it.
  4. Start with a low value. Go up only if the motor loses steps, and stay below the current that the motor is made for.

Remember one thing about trackers: between two photos the rod waits, but the coils still get their holding current. So expect both the motor and the driver to get warm while nothing turns.

A4988 or DRV8825?

The two modules look like twins. STEP and DIR work alike, and the expansion board has one pair of sockets for either of them. Only the numbers tell them apart. A DRV8825 runs its motor from 8.2V to 45V, gives a coil about 1.5A or 2.2A when cooled, goes down to 1/32 step and does not need the logic supply wire. The A4988 stays between 8V and 35V, gives about 1A or 2A when cooled, ends at 1/16 step and does need that wire. A slow tracker with a light load is an easy task for both. If you want to try the other one, read ESP32 S3 - DRV8825 Stepper Motor Driver. It uses other GPIO numbers than this page, so correct the two pin lines in the sketch when you swap the modules.

Overview of Stepper Motor

Our NEMA 17 is a bipolar motor. It has two coils inside. A coil has one wire at its start and one at its end, so each coil is a pair, and four wires leave the case. A full step moves the shaft by 1.8 degrees, and after 200 of them it has come full circle.

NEMA 17 motor wire colours: black and green are coil A-C, red and blue are coil B-D
Colour on our motor Wire Other names Belongs to
black A A+ / A coil A-C
green C A- / A with a bar coil A-C
red B B+ / B coil B-D
blue D B- / B with a bar coil B-D

Each maker picks its own colours, so trust the datasheet more than any table. If you have none, a multimeter sorts the wires: where it reads a few ohms, you hold both ends of one coil. You can also do it by hand. Let two bare wire ends touch and twist the shaft with your fingers; when it turns harder than before, you have found a pair. A pair that is connected the other way round only changes the direction. Pairs that are mixed up give you a motor that hums and stays where it is.

Wiring Diagram

GPIO1 and GPIO2 share one header row of the ESP32 S3, side by side and close to a GND pin, and 3V3 is on the row across. The two are ordinary pins with no strapping, USB, PSRAM or serial duty, which makes them a good home for STEP and DIR.

The wiring diagram between ESP32 S3 A4988 stepper motor driver

This image is created using Fritzing. Click to enlarge image

※ NOTE THAT:

  • An A4988 that sits backwards can be destroyed, so look twice. Its EN ... DIR edge belongs near the G V S pins, and its VMOT corner near the small arrow marked "VIN".
  • Brown, yellow, pink and purple were chosen for the motor wires only to keep the picture clear. Follow the letters of your own motor.
From To the expansion board
GPIO1 STEP row, S pin
GPIO2 DIR row, S pin
3V3 V pin, any row (inside the board they are linked)
GND G pin, any row (linked as well)
plus of the DC power jack VIN screw terminal
minus of the DC power jack GND screw terminal, below VIN
nothing EN row, S pin (the driver is on)

Pay attention to the V wire. With a DRV8825 in the sockets you could leave it out. With an A4988 you cannot, because nothing else feeds VDD. The motor has its own white plug on the board, with 2B at the top:

Plug pin Motor wire Colour on our motor
2B A black
2A C green
1A B red
1B D blue

A tracker is carried outside, set up in the dark and bumped now and then. Plug-in wires do not like that. Seat the ESP32 S3 in a Screw Terminal Block for ESP32 S3 and clamp all four wires:

The wiring diagram between ESP32 S3 A4988 stepper motor driver Screw Terminal

This image is created using Fritzing. Click to enlarge image

Or keep the jumper wires and give them better labels. On a GPIO Breakout Board for ESP32 S3, every GPIO number is printed beside its pin, which helps you by the light of a small red torch:

The wiring diagram between ESP32 S3 A4988 stepper motor driver GPIO Breakout Board

This image is created using Fritzing. Click to enlarge image

Without the Expansion Board

The bare module uses the same two GPIO pins. Only the other ends of the wires move to the module itself:

The wiring diagram between ESP32 S3 A4988 module  without expansion board

This image is created using Fritzing. Click to enlarge image

With the ESP32 S3 in the screw terminal block, it becomes this:

The wiring diagram between ESP32 S3 A4988 module Screw Terminal

This image is created using Fritzing. Click to enlarge image

And this is the breakout board version:

The wiring diagram between ESP32 S3 A4988 module GPIO Breakout Board

This image is created using Fritzing. Click to enlarge image

A4988 pin Other end of the wire
STEP GPIO1
DIR GPIO2
VDD 3V3
GND beside VDD any ESP32 S3 GND
VMOT plus of the DC power jack
GND beside VMOT minus of the DC power jack
2B motor wire A
2A motor wire C
1A motor wire B
1B motor wire D
RST SLP, with a short jumper (orange in the drawing)
EN, MS1, MS2, MS3 open (driver on, full step)

※ NOTE THAT:

  • The RST-SLP jumper is a must here. If it is missing, the shaft never turns.
  • Add one part that the drawing does not show: a capacitor of 100uF, close to the module. Choose one for 35V or more. Its + leg meets VMOT, the other leg the GND below. The expansion board has one already.

Safety Notes

Finish every wire first and leave the plug of the 12V adapter for last. While the adapter is on, do not connect or disconnect the motor: the coil kicks back with a high voltage, a spike, and can destroy the A4988 in an instant. The 12V wire ends at VIN (expansion board) or at VMOT (bare module) and touches no pin of the ESP32 S3. All grounds meet. The ESP32 S3, the module and the adapter minus share one line, otherwise the chip cannot tell HIGH from LOW. And let the driver cool for a moment before you touch its heat sink.

How To Program For A4988 Stepper Motor Driver

Making a step by hand is easy. STEP goes HIGH, the sketch waits, STEP goes LOW, and the sketch waits again. The function turnRod() of the first sketch sets DIR and then repeats this for each step. One pulse takes 2 x 2000 microseconds. This makes 250 steps per second or, in full steps, 75 RPM, and a NEMA 17 can jump to that speed from standstill.

The second sketch gives the pulses to the AccelStepper library. runSpeed() makes the even pace of the tracking, where the gap between two pulses never changes. For the way back, moveTo() sets the target, and run() makes the motor faster step by step and slower again near the end. Both functions send at most one pulse per call, so loop() has to come back to them quickly, and no delay() may run while the motor is turning.

ESP32 S3 Code - A4988 Stepper Motor Driver

This sketch is a check of the wiring. The rod goes one turn out, rests, comes one turn back and rests.

/* * 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-stepper-motor-a4988-driver */ // STEP and DIR of the A4988 (GPIO1 and GPIO2 sit side by side on one ESP32 S3 header) #define STEP_PIN 1 // ESP32 S3 GPIO1 connected to STEP of the A4988 #define DIR_PIN 2 // ESP32 S3 GPIO2 connected to DIR of the A4988 #define MICROSTEPS 1 // 1 = full step. Allowed: 1, 2, 4, 8, 16, same as the DIP switches #define STEPS_PER_TURN (200 * MICROSTEPS) // 360 / 1.8 = 200 full steps in one turn of the rod #define STEP_DELAY_US 2000 // microseconds of HIGH in a pulse, followed by as many of LOW #define REST_MS 1800 // milliseconds of rest after each turn // Turn the threaded rod. // level = voltage on DIR (HIGH or LOW), this picks the side // pulses = how many steps to make void turnRod(int level, long pulses) { digitalWrite(DIR_PIN, level); // choose the side first, delayMicroseconds(5); // and give the driver a moment to see it while (pulses > 0) { digitalWrite(STEP_PIN, HIGH); // LOW -> HIGH: the A4988 makes one step now delayMicroseconds(STEP_DELAY_US); digitalWrite(STEP_PIN, LOW); // back to LOW, the next pulse can come delayMicroseconds(STEP_DELAY_US); pulses--; } } void setup() { Serial.begin(9600); pinMode(STEP_PIN, OUTPUT); pinMode(DIR_PIN, OUTPUT); digitalWrite(STEP_PIN, LOW); // rest level of STEP between two moves Serial.print("Rod test on GPIO1 / GPIO2, pulses per turn: "); Serial.println(STEPS_PER_TURN); } void loop() { // 1. The hinge of the tracker opens: one rod turn with DIR at HIGH Serial.println("[open ] DIR HIGH, 1 rod turn"); turnRod(HIGH, STEPS_PER_TURN); delay(REST_MS); // 2. The hinge closes again: one rod turn with DIR at LOW Serial.println("[close] DIR LOW, 1 rod turn"); turnRod(LOW, STEPS_PER_TURN); delay(REST_MS); }

Detailed Instructions

  1. New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
  2. Choose full step: Push all three DIP switches to OFF. On the bare module, leave MS1, MS2 and MS3 open.
  3. Wire the logic side: Put in the STEP, DIR, 3V3 and GND wires, then set VREF over USB power as described above.
  4. Wire the power side: Pull out the USB cable. Connect the four motor wires and the DC power jack. The 12V adapter is still unplugged.
  5. Mark the shaft: Fold a strip of tape around it as a flag, because a bare turning shaft is hard to see.
  6. Upload: Plug the USB cable in again, choose ESP32S3 Dev Module and your COM port under Tools, and upload the sketch from the Arduino IDE.
  7. Switch on the motor power: Plug in the 12V adapter now.
  8. Read along: Start the Serial Monitor at 9600 baud with timestamps on, and compare each line with the flag.
  9. Pro Tip: Set MICROSTEPS to 16, push the three switches to ON, and upload again. It is still one turn, but it needs 3200 pulses and takes about 13 seconds.
∞
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
20:31:45.204 -> Rod test on GPIO1 / GPIO2, pulses per turn: 200 20:31:45.256 -> [open ] DIR HIGH, 1 rod turn 20:31:47.858 -> [close] DIR LOW, 1 rod turn 20:31:50.460 -> [open ] DIR HIGH, 1 rod turn 20:31:53.061 -> [close] DIR LOW, 1 rod turn 20:31:55.663 -> [open ] DIR HIGH, 1 rod turn 20:31:58.264 -> [close] DIR LOW, 1 rod turn
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

A new line appears every 2.6 seconds: 0.8 seconds of turning (200 pulses x 4 ms) and 1.8 seconds of rest. Look at the flag during the rest. It should stop at the same place after each turn. During the rest, also try to move the shaft with two fingers. It resists, and that is the holding current at work.

ESP32 S3 Code - Star Tracker with AccelStepper

Why one turn per minute? Seen from the ground, the sky moves by about 0.25 degrees in a minute. An M6 threaded rod moves 1 mm per turn. When the rod is about 229 mm away from the hinge, 1 mm opens the boards by just these 0.25 degrees. For another rod or another distance, change TRACK_RPM. The sketch tracks for one turn, waits, rewinds and starts over.

/* * 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-stepper-motor-a4988-driver */ #include <AccelStepper.h> // AccelStepper library by Mike McCauley // STEP and DIR of the A4988 (GPIO1 and GPIO2 sit side by side on one ESP32 S3 header) #define STEP_PIN 1 // ESP32 S3 GPIO1 connected to STEP of the A4988 #define DIR_PIN 2 // ESP32 S3 GPIO2 connected to DIR of the A4988 #define MICROSTEPS 16 // 1/16 step = all three DIP switches ON #define STEPS_PER_TURN (200L * MICROSTEPS) // 3200 pulses turn the rod once #define TRACK_RPM 1.0 // rod turns per minute while the camera follows the stars #define TRACK_TURNS 1 // rod turns in one shot (at 1 turn per minute: minutes) #define REWIND_SPEED (75 * MICROSTEPS) // top speed on the way back, in pulses per second #define REWIND_ACCEL (50 * MICROSTEPS) // speed won (or lost) in each second of the rewind #define PAUSE_MS 2500 // milliseconds of rest between two moves const float TRACK_SPEED = TRACK_RPM * STEPS_PER_TURN / 60.0; // in pulses per second, here about 53.3 const long SHOT_END = TRACK_TURNS * STEPS_PER_TURN; // rod position when the shot is over const long QUARTER = STEPS_PER_TURN / 4; // a progress line after each quarter turn // DRIVER mode: the library only needs the STEP pin and the DIR pin AccelStepper rod(AccelStepper::DRIVER, STEP_PIN, DIR_PIN); bool tracking; // true = slow tracking, false = fast rewind long nextReport; // rod position of the next progress line // Follow the stars: one fixed, slow speed void startTracking() { Serial.println("TRACK start, camera follows the sky"); tracking = true; nextReport = QUARTER; rod.setSpeed(TRACK_SPEED); } // Go back to position 0: gain speed, run, lose speed void startRewind() { Serial.println("REWIND back to position 0"); tracking = false; rod.setCurrentPosition(SHOT_END); // same position, but the old tracking speed is cleared rod.moveTo(0); // new target, the motor has not moved yet } void setup() { Serial.begin(9600); rod.setMaxSpeed(REWIND_SPEED); rod.setAcceleration(REWIND_ACCEL); rod.setMinPulseWidth(2); // STEP stays HIGH for 2 microseconds (the A4988 asks for 1 or more) Serial.print("Star tracker: "); Serial.print(TRACK_SPEED, 1); Serial.println(" pulses/s while tracking"); startTracking(); } void loop() { if (tracking) { rod.runSpeed(); // sends a pulse if its time has come, always at the same pace if (rod.currentPosition() >= nextReport) { Serial.print("TRACK "); Serial.print(nextReport); Serial.print(" of "); Serial.println(SHOT_END); nextReport += QUARTER; } if (rod.currentPosition() >= SHOT_END) { delay(PAUSE_MS); // the rod stands still, so delay() does no harm here startRewind(); } } else { rod.run(); // sends a pulse if its time has come, and works out the next speed if (rod.distanceToGo() == 0) { Serial.println("REWIND done, ready for the next shot"); delay(PAUSE_MS); // standing still again startTracking(); } } }

Quick Steps for the Tracker

  1. Choose 1/16 step: With the 12V off, slide all three DIP switches to ON. The bare module needs HIGH (3.3V, the same as VDD) on MS1, MS2 and MS3. If you do not want these three extra wires, leave the pins open and set MICROSTEPS to 1. The tracker still works, only with bigger steps.
  2. Open the Library Manager: In the Arduino IDE, the icon with the books at the left edge shows the list of libraries.
  3. Install AccelStepper: Search for AccelStepper, look for the entry by Mike McCauley and press 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. Upload: Put the code above into a new sketch and press Upload.
  2. Motor power on: Plug the 12V adapter in again.
  3. Be patient: During the first minute, the flag goes round only once. You hear almost nothing.
  4. Watch the way back: The rewind needs only about 4 seconds. It starts gently and ends gently.
  5. Pro Tip: For a real photo, set TRACK_TURNS to the number of minutes you need, and start the camera two or three seconds after the rod begins to move.
∞
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
21:47:03.118 -> Star tracker: 53.3 pulses/s while tracking 21:47:03.163 -> TRACK start, camera follows the sky 21:47:18.137 -> TRACK 800 of 3200 21:47:33.139 -> TRACK 1600 of 3200 21:47:48.141 -> TRACK 2400 of 3200 21:48:03.142 -> TRACK 3200 of 3200 21:48:05.645 -> REWIND back to position 0 21:48:09.822 -> REWIND done, ready for the next shot 21:48:12.325 -> TRACK start, camera follows the sky 21:48:27.301 -> TRACK 800 of 3200
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

The four progress lines should come 15 seconds apart, and 4 x 15 seconds is the full minute. Is your gap shorter or longer than that? Then compare TRACK_RPM with the value in the code above. Is the gap right, but the flag does more or less than one round? Then the DIP switches do not say 1/16. In the rewind, the speed climbs to 1200 pulses per second (22.5 turns per minute) and falls again before position 0.

Troubleshooting

The motor is silent and the shaft is loose.

The driver sleeps or has no logic power. On the bare module, look for the jumper from RST to SLP and for the VDD wire. On the expansion board, look for the V wire. Is the 12V adapter plugged in?

The motor hums or trembles and stays in its place.

Most often one wire of each coil has changed places with the other coil. Find the two pairs again with a multimeter. Are the pairs fine? Then give the coils a little more current with VREF. If only the rewind fails, it is too fast for your motor: lower REWIND_SPEED and REWIND_ACCEL.

The tracker follows the wrong way and the stars get longer.

Switch the 12V off, let the 2B and 2A wires trade places, and leave the other coil as it is. Software works as well: add rod.setPinsInverted(true, false, false); to setup() of the tracker sketch, and the library turns DIR around.

You cannot keep a finger on the heat sink.

The current limit is too high for this cooling. Turn VREF down and do not close the tracker box too tightly. If the heat sink is still in its bag, use it. An A4988 that overheats switches itself off, and a tracker that pauses like this loses the stars.

One turn in the sketch is not one turn of the rod.

MICROSTEPS and the DIP switches do not match. Remember the order, with MS1 at switch 3. Sixteen rounds in place of one means that the code says 16 and all switches are OFF.

Application and Project Ideas

A motor that counts its own steps can move more than a camera board.

  1. Moon time-lapse: Take one photo at the end of every fifth turn and let the ESP32 S3 press the shutter through a relay.
  2. Telescope focuser: Turn the focus knob by a few 1/16 steps, so your hand does not shake the telescope.
  3. Slow turntable: Show a model or a watch from all sides, with one very smooth round per minute.
  4. Panorama head: Rotate a camera by the same angle between shots and stitch the photos later.
  5. Sun follower for a plant: Turn a pot a little each hour, so all its leaves get light.

Challenge Yourself

  1. Beginner: Change TRACK_RPM to 2.0 and predict the time between two progress lines before you upload.
  2. Intermediate: Connect a button and start the tracking only when it is pressed.
  3. Advanced: Mount a limit switch at the closed position of the boards, and let the rod search for it at power-up, so position 0 is always the same point.

Video Tutorial

The video for this star tracker motor will be added here later.

※ 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!