Rpi python DRV8833 motor driver setting up and troubleshooting DC motor driving problem
Ask QuestionAsked todayActive todayViewed 21 times1
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


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
GPIO.setmode(GPIO.BOARD)
# 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
time.sleep(5)
GPIO.output(12, GPIO.LOW) # Set AIN1
GPIO.output(11, GPIO.LOW) # Set AIN2
raspberry-pi-osdc-motorShareEditFollowCloseFlagedited 56 mins agotlfong013,77733 gold badges88 silver badges2222 bronze badgesasked 8 hours agoPatrick Hession1122 bronze badges New contributor
- 1Frankly 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 8 hours ago
- 1Why is a 9V battery no good? I will also address your other concerns now. Thanks so much for your answer though π β Patrick Hession 8 hours ago
- 1Those 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 8 hours ago
- 1Oh..the DRV8833 component wants power between 2v and 10v though.. β Patrick Hession 8 hours ago
- 1I have added some more info to my question now. Hope this helps π β Patrick Hession 8 hours ago
- This EESE Q&A might help: (1) How to troubleshoot a DRV8833 motor driver module problem? – rpi.se 2020nov09, Viewed 698 times: electronics.stackexchange.com/questions/531470/β¦, (2) DRV8833 Motor Driver Test – Youtube 2020nov18, 174 views youtube.com/watch?v=31-qPfkHcbg. Cheers. β tlfong01 4 hours ago
- My above linked answer refers to the TI’s DRV8833 datasheet: (3) DRV8833 Dual H-Bridge Motor Driver Datasheet – TI 2015jul ti.com/lit/ds/symlink/β¦. This datasheet gives principles of operation, use of the input/output pins, and example application schematic. You might like to let me know which schematic in the datasheet you are using, then I would suggest how to assign logical values to the pins to do the troubleshooting. β tlfong01 4 hours ago
- (4) Actually you don’t need to us Rpi to do online testing/troubleshoot. You can put Rpi aside and just use DC level signals to make sure your drv8833 is not fried. (5) You can see in my answer, before I use a Rpi program to do the testing, I use a cheapy 555 astable to as input to drv8833. (5) It is only after the preliminary basic offline testing, then I move on to write a simple python program to move the motor. β tlfong01 4 hours ago
- (6) In case you find any thing you don’t understand when reading the drv8833 datasheet, you are welcome to ask me any newbie questions, and I would try to entertain your questions, by perhaps writing up an answer. Happy learning, cheers. β tlfong01 4 hours ago
- (7) You seem to have forgotten to short ASEN (A sense) to ground. The coil current needs to go to ground through this sense terminal, with or without any current sensing resistor, otherwise motor won’t move! π β tlfong01 just now Edit
2 Answers
Answer

- I would suggest to do the hardware setup in Appendix A for preliminary testing.
- 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.
- We don’t even need any motor for testing.
- I would suggest the following wiring:4.1 Motor voltage 6V (or 12V)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
- Testing procedure:5.1 Set nSleep to enable drv88335.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. 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, …
References
(1) DRV8833 Dual H-Bridge Motor Driver Datasheet – TI 2015jul
(3) How to troubleshoot a DRV8833 motor driver module problem? – EESE, 2020nov09, Viewed 701 times
(4) DRV8833 Motor Driver Test Demo Youtube Video – 2020nov18
/ to continue, …
Appendices
Appendix A – Suggested hardware setup for troubleshooting DRV8833








/ to continue, …
ShareEditDeleteFlagedited 4 mins agoanswered 2 hours agotlfong013,77733 gold badges88 silver badges2222 bronze badgesAdd a comment1
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.ShareEditFollowFlagedited 6 hours agoanswered 6 hours agoMilliways48.7k2424 gold badges8080 silver badges160160 bronze badges
- 1Great thanks for the help. Here is a link to the component I am using: adafruit.com/product/3297 β Patrick Hession 6 hours ago
- 1@PatrickHession DO NOT put detail in Comments. Edit your Question so others will see this. β Milliways 6 hours ago
Categories: Uncategorized