# Using the DRV8835 with a Raspberry Pi Zero W

**URL:** <https://forum.core-electronics.com.au/t/using-the-drv8835-with-a-raspberry-pi-zero-w/3169>\
**Category:** Raspberry Pi\
**Created:** [1 August 2018 06:45 UTC](https://forum.core-electronics.com.au/t/using-the-drv8835-with-a-raspberry-pi-zero-w/3169 "2018-08-01T06:45:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel67286](https://avatars.discourse-cdn.com/v4/letter/d/3da27b/32.png) [@Daniel67286](https://forum.core-electronics.com.au/u/Daniel67286)\
**Post date:** [1 August 2018 06:45 UTC](https://forum.core-electronics.com.au/t/using-the-drv8835-with-a-raspberry-pi-zero-w/3169/1 "2018-08-01T06:45:43Z")

</div>

Hi, I’m trying to use a DRV8835 with a Raspberry Pi Zero W to drive 2 DC motors.  
I’ve tested the motors by connecting them directly to the battery pack and they work fine, however when I try and use them with the Pi, DRV8835 and this Python code: (using pigpio)

```python
import time
import pigpio
MOTOR_A1 = 25
MOTOR_A2 = 18

#connect to pigpiod daemon
pi = pigpio.pi()

# pi set frequency
pi.set_PWM_frequency(MOTOR_A2, 100)

pi.set_servo_pulsewidth(MOTOR_A1, 0)
pi.set_PWM_dutycycle(MOTOR_A2,255)
time.sleep(1)

#disconnect
pi.stop()

```

…the code executes without error, but the motors do not move. Any help would be greatly appreciated.

My current wiring setup:

MD -\> not connected  
VM -\> not connected

**DRV8835 -\> Pi Zero W**  
AIN1 -\> BCM 25 (Physical pin 22)  
AIN2 -\> BCM 18 (Physical pin 12)  
BIN1 -\>BCM 23 (Physical pin 16)  
BIN2 -\> BCM 24 (Physical pin 18)  
VCC -\> 3v3 Power (Physical pin 1)   
GND (VCC SIDE) -\> Ground 6

**DRV8835 -\> Motors/Battery**  
AO1 -\> Motor 1: Positive  
AO2 -\> Motor 1: Negative  
BO1 -\> Motor 2: Positive  
BO2 -\> Motor 2: Negative  
VIN -\> 4x AA Batteries: Positive  
GND (VIN SIDE) -\> 4x AA Batteries: Negative

---

<div class="post-metadata">

**Author:** ![Stephen](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/stephen/32/1599_2.png) [@Stephen](https://forum.core-electronics.com.au/u/Stephen)\
**Post date:** [2 August 2018 23:08 UTC](https://forum.core-electronics.com.au/t/using-the-drv8835-with-a-raspberry-pi-zero-w/3169/2 "2018-08-02T23:08:51Z")

</div>

Hi Daniel!

It would be really helpful if you had a photo of the wiring or a Fritzing picture of how its wired up just so its a little easier to understand. It looks like you need to provide logic power. How are you powering the Pi Zero? If you are powering the motor driver directly off the Pi perhaps it isn’t getting enough amps.

![image](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/2/2d3e2b9c3bdfc6a51cb122b177fbec8df0921917.png)

Try something like this for your code:  
[https://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/](https://sourceforge.net/p/raspberry-gpio-python/wiki/PWM/)

or you could adapt this motor driver library to work for you:

> **[pololu/drv8835-motor-driver-rpi](https://github.com/pololu/drv8835-motor-driver-rpi)**
>
> Python library for the Pololu DRV8835 dual motor driver kit for Raspberry Pi B+ - pololu/drv8835-motor-driver-rpi

Give that a shot and get back to me

---

<div class="post-metadata">

**Author:** ![Daniel67286](https://avatars.discourse-cdn.com/v4/letter/d/3da27b/32.png) [@Daniel67286](https://forum.core-electronics.com.au/u/Daniel67286)\
**Post date:** [8 August 2018 07:59 UTC](https://forum.core-electronics.com.au/t/using-the-drv8835-with-a-raspberry-pi-zero-w/3169/3 "2018-08-08T07:59:30Z")

</div>

Sorry for the late reply.

I followed this DRV8833 tutorial for my current setup: [https://www.linuxcircle.com/2015/06/02/how-to-drive-2-dc-motors-with-raspberry-pi-2-gpio-and-drv8833-chip/](https://www.linuxcircle.com/2015/06/02/how-to-drive-2-dc-motors-with-raspberry-pi-2-gpio-and-drv8833-chip/)

While it is for the older DRV8833 chip, I changed a couple of things to try and make it work. I just cannot for the life of me find a tutorial on using the DRV8835 with the Raspberry Pi.

I’m pretty sure that I’m providing logic power through the VCC pin on the DRV8835. I’m powering the motors off of 4x AA batteries, and I’m powering the Pi off of an iPad wall charger. As for using RPi.PWM, I’m not exactly sure how to make it work with two motors. I can’t find any schematics for the DRV8835 HAT thing that the library you linked to is for. Any idea what pins I would use?

Below are photos of my wiring setup:

 ![IMG_1905](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/a/a11670b936dadaa2493ab93e62a547778c1b3873.jpeg)  
 ![IMG_1909](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/f/f01604998e095aad7fbb665069f3d9503b96977f.jpeg)  
 ![IMG_1911](https://canada1.discourse-cdn.com/flex028/uploads/core_electronics/original/2X/9/962df4083094ac78c67d3df34c23eb6d7b6daca9.jpeg)

---

<div class="post-metadata">

**Author:** ![Stephen](https://yyz2.discourse-cdn.com/flex028/user_avatar/forum.core-electronics.com.au/stephen/32/1599_2.png) [@Stephen](https://forum.core-electronics.com.au/u/Stephen)\
**Post date:** [9 August 2018 23:11 UTC](https://forum.core-electronics.com.au/t/using-the-drv8835-with-a-raspberry-pi-zero-w/3169/4 "2018-08-09T23:11:07Z")

</div>

Hey Daniel,

Could you make a Fritzing drawing and export it as an image to share so I can see how everything is hooked up? It’s pretty hard to tell in the photos what is connected to what.

Thanks!
