1

I'm in possession of a pi zero w. I have purchased two L9110s modules and connected 2 coin vibration motors (80mA) on each of them. The modules are powered by an external power battery bank rated 5V and 2.1A while the pi zero is powered by its own power adapter .

The DC motors work perfectly well when only 2 of them are active. If I use more than 4 GPIO (6 are needed for 3 motors to function) the motors stop working. As soon as I disconnect 2 GPIO corresponding to a single motor the 2 remaining motors continue to work fine. I have also tried to connect to different GPIO on each motor but I can not drive more than 2 motors.

In another experiment I have tried to power more than 2 DC motors using transistors and an external power supply with just 1 GPIO needed per DC motor to work which worked perfectly fine for two motors. As soon as the third motor was connected I got the exact same results as the above.

TL;DR How many DC motors can a pi zero w support? I know for a fact Adafruit advertises their B+ model with a hat capable of supporting up to 128 DC motors but I found no example with more than 2 motors for a pi zero w.

Update:

Here's the image of 3 motors connected to GPIO (the fourth is offline)

Here's the code I'm using in python

import time
import RPi.GPIO as GPIO

#DC motor 1
coinmotor1=17
coinmotor2=27

#DC motor 2
coinmotor3=23
coinmotor4=24

#DC motor 3
coinmotor5=5
coinmotor6=6

#DC motor 4,deactivated
#~ coinmotor7=13
#~ coinmotor8=19

# Setup pins with BCM numbering!
GPIO.setmode(GPIO.BCM)

#activate warnings
GPIO.setwarnings(True)

#figured I could use a list instead of setting up each coin motor itself
coinList=[coinmotor1,coinmotor2,coinmotor3,coinmotor4]
#I can even append the list more pins
coinList.append(coinmotor5)
coinList.append(coinmotor6)
print'list is: ',coinList


#setup all pins
GPIO.setup(coinList,GPIO.OUT)

def deactivate_all():
    GPIO.output(coinList,0)
    #~ GPIO.output(coinmotor1, False)
    #~ GPIO.output(coinmotor2, False)
    #~ GPIO.output(coinmotor3, False)
    #~ GPIO.output(coinmotor4, False)
    #~ GPIO.output(coinmotor5, False)
    #~ GPIO.output(coinmotor6, False)
    #~ GPIO.output(coinmotor7, False)
    #~ GPIO.output(coinmotor8, False)

def activate_right(a,b,c,d,e):
    deactivate_all()
    #~ GPIO.output(coinmotor1, False)
    #~ GPIO.output(coinmotor2, False)
    #~ GPIO.output(coinmotor3, False)
    #~ GPIO.output(coinmotor4, False)
    #~ GPIO.output(coinmotor5, False)
    #~ GPIO.output(coinmotor6, False)
    #~ GPIO.output(coinmotor7, False)
    #~ GPIO.output(coinmotor8, False)
    if a==1:
        GPIO.output(coinmotor1, 1)
        print'a ',right
    if b==1:
        GPIO.output(coinmotor3, 1)
        print'b ',right
    if c==1:
        GPIO.output(coinmotor5, 1)
        print'c ',right
    if d==1:
        GPIO.output(coinmotor7, 1)
        print'd ',right
    #~ if e==1:
        #~ GPIO.output(coinmotor9,True)

def activate_left(a,b,c,d,e):
    deactivate_all()
    #~ GPIO.output(coinmotor1, False)
    #~ GPIO.output(coinmotor2, False)
    #~ GPIO.output(coinmotor3, False)
    #~ GPIO.output(coinmotor4, False)
    #~ GPIO.output(coinmotor5, False)
    #~ GPIO.output(coinmotor6, False)
    #~ GPIO.output(coinmotor7, False)
    #~ GPIO.output(coinmotor8, False)
    if a==1:
        GPIO.output(coinmotor2, True)
        print'a ',left
    if b==1:
        GPIO.output(coinmotor4, True)
        print'b ',left
    if c==1:
        GPIO.output(coinmotor6, True)
        print'c ',left
    if d==1:
        GPIO.output(coinmotor8, True)
        print'd ',left
    #~ if e==1:
        #~ GPIO.output(coinmotor10,True)

if __name__ == "__main__":
    print('Starting motor sequence!')
    right='right'
    left='left'
    while True:
        try:

            activate_right(1,0,0,0,0)
            time.sleep(0.5)

            activate_right(0,1,0,0,0)
            time.sleep(0.5)

            #~ activate_right(0,0,1,0,0)
            #~ time.sleep(0.5)

            #~ print'd ',right
            #~ activate_right(0,0,0,1,0)
            #~ time.sleep(0.5)

            #~ print'a ',left
            #~ activate_left(1,0,0,0,0)
            #~ time.sleep(0.5)

            #~ print'b ',left
            #~ activate_left(0,1,0,0,0)
            #~ time.sleep(0.5)
            #~ print'c ',left
            #~ activate_left(0,0,1,0,0)
            #~ time.sleep(0.5)

            #~ print'd ',left
            #~ activate_left(0,0,0,1,0)
            #~ time.sleep(0.5)


        except(KeyboardInterrupt):
            # If a keyboard interrupt is detected then it exits cleanly!
            print('\nFinishing up!')
            deactivate_all()  
            GPIO.cleanup() # cleanup all GPIO 

enter image description here

  • Seems very strange. Is it a motor problem? Power problem? do all 3 motors run just from the power bank. Maybe its a software logic problem. I can see many people talking about this topic on the Pi forums and don't seem to have any problems. – Piotr Kula Feb 25 at 15:20
  • Do you have an example of pi zero w working with more than 2 DC motors? That would help a lot. – Mike Feb 25 at 15:24
  • You have wired something incorrectly. The L9110s take negligible control current. If you want help please provide clear photos showing the connections. – joan Feb 25 at 15:34
  • Thanks a lot friend. Updated the original post. The power bank provides power to some leds and the modules while the raspberry pi zero w is powered from its wall adapter . – Mike Feb 25 at 18:27
  • 1
    If you want the Pi to signal a device using a GPIO there needs to be a common ground between that device and the Pi. The L9100s ground needs to be connected to a Pi ground. The simplest way is to connect a Pi ground to the breadboard ground. – joan Feb 25 at 19:03

Your Answer

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

Browse other questions tagged or ask your own question.