I am very new to the world of raspberrypi and I am probably making some beginner mistakes. I am trying to move a NEMA17 motor (stepper motor) using a Raspberry Pi 3B+ and a4988 driver.

First I set the driver voltage to 12v (since Imax = Vref/(8Rs); Vref=1.5A8*0.1 Ohm ; vref=12v).

So, after this adjustment and measuring it with the multimeter I connected the motor to the driver (Red wire to 2A, Blue wire to 2B, Green wire to 1A, Black to 1B).

I also connected the voltage of 5V (pins 4 y 6) and 12 v after transform it.

Additionally I connected MS1, MS2 and MS3 of the driver with pins 8, 10 and 12 of the Raspberry Pi . Finally I connected pins 38 and 40 of the Raspberry Pi to the step and dir pins respectively.

Something like this:

enter image description here

The code I used is from this page (https://www.iotdesignpro.com/projects/raspberry-pi-stepper-motor-control-through-a-webpage-using-flask) I paste the link to the page as I don't want to overwhelm the reader writting here all the code.

After switching on the transformer the driver gets very hot and the motor makes noises but does not run. I followed all the instructions on the page copied above. What am I doing wrong?

Any contribution will be welcome. Thank you in advance.

I paste photos of the connection:

enter image description here enter image description here enter image description here

enter image description here

  • 1
    There are too many possibilities. I suggest you do one thing at a time. Perhaps just a simple program to pulse the stepper? You need to localise the fault(s).
    – joan
    May 14, 2021 at 19:37
  • 1
    And unless you properly anchor the power cable and cover the power connections you may not live to try other methods.
    – Milliways
    May 14, 2021 at 22:11
  • @Adrián P.L., Welcome and nice to meet you. I very much appreciate your very considerate, very concise and yet very detailed question, which is, in short: "How can Rpi3B+ use the A4988 driver to drive a NEMA17 stepper motor? I am thinking to writing up an answer this gloomy, locking down Saturday afternoon. It would be nice if you can let me know the web links to the following: (a) The NEMA stepper motor, (b) The A4988 driver module, (c) the PSU (not too important though). And can I assume that you are using the most update Rpi buster OS? Have a great project. Cheers.
    – tlfong01
    May 15, 2021 at 2:33
  • Before answering a question, I usually search the forum for related questions, to avoid reinventing the wheels. The search results is disappointing: either superficial answers, or generic answers not related to the specific ddriver A4988. This is the search summary: (1) Related Questions on Rpi SE (given by Rpi SE built in search system) (a) 4 rPi2 model B v1.1 smoke comes out near power port, (b) 1 Updated info/software/advice on using Raspberry Pi to control stepper motor drivers, (c) 0 Can this DC Motor Driver feed my RPi?, / to continue, ...
    – tlfong01
    May 15, 2021 at 2:59
  • / cont'd, ... (d) 1 Rpi GPIO Interface L298N DC Motor Driver Troubleshooting Problem, (e) 1 Robot Buggy Not Moving Once Set On Surface, (f) 0 brushless dc motor connection, (2) Search "A4988" found 5 results (a) Which driver for controlling bipolar stepper motor with a raspberry pi? Asked 4 years ago, Viewed 587 times raspberrypi.stackexchange.com/questions/55632/…, / to continue, ...
    – tlfong01
    May 15, 2021 at 3:00

2 Answers 2



How can Rpi3B+ use the A4988 driver to drive a NEMA17 stepper motor?


a4988 test

  1. Introduction

    1.1 Prerequisite knowledge and skills required

    The OP says he is a newbie in Rpi and stepping motor. So I would recommend him to first skim References 1 ~ 4 below, to get a rough idea on stepping motors and drivers.

    There is no hurry to get to know Rpi now, because we will start testing offline, by hand, then by simple 555 timer/signal generator, and only finally by Rpi.

  1. Offline testing of A4988 stepping motor driver and NEMA17 motor in full step mode and DC signal by hand

a4988 module

test wiring

  1. A4899 offline test, using sig gen square wave step pulse, PWM signal for Enable) and ms1, ms2, ms3 microstepping config

stepper motor test

/ to continue, ...


(1) A4988 Datasheet – Allergo

(2) A4988 Stepper Motor Driver Module – AliExpress US$0.6

(3) Tutorial on stepper motors (eg, 28BYJ48) and drivers (eg, ULN2003, L293D) - EESE, Asked 2019apr27, Viewed 885 times

(4) Stepping Motors Fundamentals (AN907) - MicroChip

(5) Drive a Nema 17 stepper motor with the RpiMotorLib Python library for A4988 (RpiMotorLib and Flask) - DiyProjects, 2021feb09

(6) A4988 Stepping Motor Driver Q&A (schematic and photos) - tlfong01 EESE, 2021apr14

(7) AliExpress HK42BYG250-001 Stepper Motor NEMA17 | High torque 1.2A 38mm stepper motor for 3D printer 42 with speed feedback - CN¥25

(8) XY-PWM Square Wave Signal Generator (How can Rpi4B python UART talk to XY PWM Signal Generators? - Asked 2019oct20, Viewed 641 times)

(9) Raspberry Pi PWM Generation using Python (Tutorial) - ElectronicWings 2019mar

(10) Raspberry Pi PWM Generation using Python (Demo Program Source Code) - ElectronicWings 2019mar

(11) Control Stepper Motor with A4988 Driver Module & Arduino - LastMinuteEngineers https://lastminuteengineers.com/a4988-stepper-motor-driver-arduino-tutorial/

(12) NEMA Stepper Motors Tutorial - Reprap 2018jan20

(13) NEMA 17 Stepper motor spec - Reprap 2020dec01

(14) NEMA 17 and 28-BYJ48 Stepper Motor Pinout, Wiring Spec - Components 101, 2019aug19

(15) Stepping Motor Step rates - Reprap 2017jun25


Appendix A - The A4988 stepping motor driver module used in this answer

(2) A4988 Stepper Motor Driver Module – AliExpress US$0.6

a4988 module

Appendix B - The NEMA17 stepping motor tested in this answer

(7) AliExpress HK42BYG250-001 Stepper Motor NEMA17 | High torque 1.2A 38mm stepper motor for 3D printer 42 with speed feedback - CN¥25

stepper motor 1

stepper motor 2

Appendix C - A4988 Stepping Motor Driver and NEMA17 Stepping Motor Test Schematic

a4988 full step test

Appendix D - 12V 1A PSU for NEMA17 Stepping Motor

psu 12V 1A

/ to continue, ...


I've successfully used a Raspberry Pi with an A4988 driver board in order to spin a stepper motor. I've noticed a few differences between what you've done and what I've done, and one of these might be the problem.

Have you connected the nRESET and nSLEEP pins on your A4988 board to anything? Different boards are slightly different from each other, but with the boards that I have, nRESET and nSLEEP both need to be connected to HIGH (3.3v) in order for the motor to spin. If you leave those pins unconnected, then the driver probably won't spin the motor. (The instructions that you linked to say to connect the nRESET and nSLEEP pins to each other, which will probably work for some boards, but probably won't work for your board.)

The VDD pin should probably be connected to 3.3 V, not to 5 V.

I'm guessing that connecting nRESET, nSLEEP and VDD to 3.3 V will fix your problem.

I suggest leaving the microstep pins (MS1, MS2, MS3) unconnected until after you've figured your problems out.

Make sure that the Pi is sending pulses to the STEP pin at an appropriate frequency. A frequency of 100 Hz should definitely produce visible motion. If the frequency is too low, then the motor will turn so slowly that it'll look like it's not turning at all. If the frequency is too high, the motor will vibrate instead of spinning.

If you have a multimeter, then one thing you should try is measuring the output voltages with the motor disconnected. There are 4 pins, which means there are 6 pairs of pins that you can put the multimeter on. If you set the multimeter to measure AC, and you measure while the Pi is sending a 100 Hz step signal, then I think you should see 12 V between 1A and 1B, 12 V between 2A and 2B, and 6 V between any other pair.

Another thing to try is setting the multimeter to measure DC and measuring those pins while the Pi is sending a 1 Hz signal. If you measure between 1A and 1B, or between 2A and 2B, you should see 12 V for two seconds and then -12 V for two seconds, in a repeating cycle. If you measure between any other pair of pins, you should see 12 V for one second, 0 V for one second, -12 V for one second, and 0 V for one second again.

Make sure that the motor is disconnected while you take those voltage measurements.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.