So what I am trying to do is to get the motor to spin but I want to raspberry pi between the motor so I can spin it clockwise for 5 seconds and then spin it anti-clockwise for 5 seconds. But initially, I just want to make sure it works.

Here is my circuit: enter image description here enter image description here enter image description here

enter image description here

enter image description here

And here is the code I am running, should this code should output some voltage if I have a volt meter on the aout pins?

import RPi.GPIO as GPIO

# Declare the GPIO settings

# set up GPIO pins
GPIO.setup(19, GPIO.OUT) # Connected to AIN2
GPIO.setup(26, GPIO.OUT) # Connected to AIN1

# Drive the motor clockwise
GPIO.output(26, GPIO.HIGH) # Set AIN1
GPIO.output(19, GPIO.LOW) # Set AIN2

# Wait 5 seconds

GPIO.output(12, GPIO.LOW) # Set AIN1
GPIO.output(11, GPIO.LOW) # Set AIN2


So I have simplified my circuit to just test out an LED. Here is what it looks like now:

enter image description here

enter image description here


I have soldered the pins into the holes. What I am wondering now is should I have left the one that were N.C. unsoldered?

enter image description here enter image description here

Also you can see the wiring setup I have the results I get on the multimeter.

(1) My understanding was that the pins 2 and 4 would output 5v AC?

(2) Seems from the multimeter it is 10v AC but I mean I could be reading the multimeter wrong?

(3) I was using a wire that isn't connected to anything as an earth also, I don't know if this makes sense or not?

  • Here you can see what I mean in the above questions.

enter image description here

  • Here I am touching the earth wire and the slp pin

enter image description here

  • Here I am testing the ain1 pin to see if it has 5v

enter image description here

  • 1
    Frankly it is unclear what you actually have or are asking. List components and connections and preferably a circuit. Attempting to power a motor with a 9V battery is unlikely to work. With the wiring is is likely to be faulty use proper connections. None of the pins listed in your code seem to be connected.
    – Milliways
    May 28, 2021 at 22:41
  • 1
    Why is a 9V battery no good? I will also address your other concerns now. Thanks so much for your answer though :) May 28, 2021 at 22:48
  • 1
    Those batteries are designed for low power electronic devices. They can't supply sufficient current to run a motor. If it actually turns it won't for long.
    – Milliways
    May 28, 2021 at 22:52
  • 1
    Oh..the DRV8833 component wants power between 2v and 10v though.. May 28, 2021 at 22:58
  • 1
    I have added some more info to my question now. Hope this helps :) May 28, 2021 at 23:02

2 Answers 2


You need to do some more research.

I suggest you start with something simpler! Preferably light a few LEDs.

You use GPIO.setmode(GPIO.BOARD) BUT then use BCM numbering.

You DO NOT have a Gnd connection between the devices - this is ABSOLUTELY essential for all circuits.

You DO NOT have proper connections to the device. Sticking pins through the holes is not good enough! If you are lucky it may work, but then a loose connection may fry your Pi.

Better I suggest you try gpiozero which is simpler, is well documented and has good examples.

I do not know what a DRV8833 is or its connections. Maybe someone does, but YOU should supply this information.

  • 1
    Great thanks for the help. Here is a link to the component I am using: adafruit.com/product/3297 May 29, 2021 at 0:56
  • 1
    @PatrickHession DO NOT put detail in Comments. Edit your Question so others will see this.
    – Milliways
    May 29, 2021 at 1:00


Rpi python DRV8833 motor driver setting up and troubleshooting a N20 DC motor driving problem

drv8833 n20 motor



  1. I would suggest to do the hardware setup in Appendix A for preliminary testing.

  2. For this preliminary testing, no online Rpi and programming is need. We can do offline DC level signals input to DRV8833 and test one of the two outputs.

  3. We don't even need any motor for testing.

  4. I would suggest the following wiring:

    4.1 Motor voltage 6V (or 9V)

    4.2 Status LED with serial current limiting resistor to simulate motor coil.

    4.2 Testing signals summary:

    AIN1 - 5V, 0V
    AIN2 - 5V, 0V
    BIN1 - N.C.
    BIN2 - N.C
    nSleep - 5V, 0V
    nFault - N.C
    AOUT1 - serial current protecting resistor, to status LED Anode.
    AOUT2 - LED Cathode
    BOUT1 - N.C.
    BOUT2 - N.C.
    ASEN  - Ground 
    BSEN  - Ground
  5. Testing procedure:

    5.1 Set nSleep to enable drv8833

    5.2 By hand, use jumper wire to connect AIN1 to High (5V)

    5.3 By hand, use jumper wire to connect AIN2 to Low (0V)

    5.4 LED should be now switched on by DRV8833, implying that if motor is used instead of (or at the same time as) LED, current will pass motor coil, and motor would move in one directions (CW or CCW).

    5.5 Now connect AIN1 to Low, and AIN2 to High, LED should be switched off.

    5.6 Replace LED by motor (Errata and Edit 2021jun03 - The LED should have a series current limiting resistor, otherwise the LED would fry immediately. I would suggest the OP to try any "Blinky" for newbie program first, before any further testing on this project. Motor should move (a) in one direction if AIN1, AIN2 are connected by jumper wires to High, Low, and (b) in opposite direction if AIN1, AIN2 are connected to Low High.

    5.7 Use a NE555 timer to generate 0.5Hz square pulse (1 second High, 1 second Low), motor should repeatedly move in one direction for 1 second, and opposite direction for 1 second.

    5.8 Use a NE555 timer to generate PWM signals, say 1kHz and different duty cycles, to adjust the speed of the motor, (or the brightness of the status LED). For this motor speed adjustment test, AIN1 is set to High or Low, AIN2 is connected to the PWM signal.

    5.8 Then test the OP's python program in the question.

/ to continue, ...


(1) DRV8833 Dual H-Bridge Motor Driver Datasheet - TI 2015jul

(2) How to use motor drivers with H-bridge and PWM input, to control direction and speed of DC motors? - EESE 2020jul16

(3) How to troubleshoot a DRV8833 motor driver module problem? - EESE, 2020nov09, Viewed 701 times

(4) DRV8833 Motor Driver Test Demo Youtube Video - 2020nov18

(5) DRV8835 Dual Low-Voltage H-Bridge IC (11V, 1.5A Datasheet - TI 2016aug

(6) DRV8873 H-Bridge Motor Driver (38V, 10A, SPI) Datasheet - TI 2018aug https://www.ti.com/lit/ds/symlink/drv8873.pdf?ts=1622343011657&ref_url=https%253A%252F%252Fwww.ti.com%252Fproduct%252FDRV8873

(7) How to Solder: Through-Hole Soldering (Testing and Troubleshooting Solder Joints) - joel-eb SparkFun 2017oct

(8) DRV8833 DC/Stepper Motor Driver Breakout Board US$5- AdaFruit

/ to continue, ...


Appendix A - Suggested hardware setup for troubleshooting DRV8833

drv8833 hardware setup for testing drv8833

drv8833 2

drv8833 3

drv8833 4

drv8833 5

drv8833 6

drv8837 7

drv8833 8

Appendix B - Spec of the OP's N20 Motor

Note - N20 motor current spec:

(a) No load current ~< 60mA,

(b) Load current ~= 150mA,

(c) Stall current ~= 400mA

N20 Motor Spec

Appendix C - Shorting Asense/Bsense to Ground if Current sense resistors not used

surrent sense 1

current sense 2

/ to continue, ...

  • 1
    Thanks for this. So I have tried the simple setup you have listed about, my LED does not light up May 29, 2021 at 19:42
  • Ah, (1) you need to connect AS (A side current sense) to ground, if you are testing A side motor/LED. (2) You need to get (a) a soldering iron to solder connecting/jumper wire to the terminals, (b) A multi-meter to check point to point open/short soldering jobs, to make sure all the point to point connections are secure, ie, no bad/dry soldering joints.
    – tlfong01
    May 30, 2021 at 9:09
  • 1
    ok I have done the soldering and tried with the votlmeter, thanks again for the help Jun 2, 2021 at 20:33
  • 1
    No, I think you mentioned resistor but I don't know what size resistor to use? Is there anything else? The LED doesn't light up at all. why is this? Jun 3, 2021 at 12:14
  • 1
    Why is the voltmeter showing 10V AC? Is this correct? Jun 4, 2021 at 8:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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