I am looking to get this micro pump.

enter image description here

I was wondering what else I would need in order to run this from my raspberry pi? Do I need a relay and/or an additional power source. What all is needed to drive this and pump water on command.

  • Is not possible to make circuit with a transistor and a relay ? It s not safe ?
    – Kkkkkkkm
    Commented Feb 21, 2017 at 17:28

2 Answers 2


You need to get a good power supply. Preferably one that can supply you with 5v for the Pi and 6 or 12 for the pump, but that is in an ideal world. In your case your Pi will run off a 5v power supply and your motor MUST run on a separate power supply.

Looking at the biggest motor there 12V @ 5.8Watt you will need at least a 750mA power supply. That is not so bad and you can find 1A ones really easy and cheap or even the one supplied or recommended for that motor.

enter image description here

The image demonstrates the concept of using a transistor to switch the motor on and off. This circuit ONLY works with DC currents!

  • D1 - Flyback diode- Protects the transistor from back emf when the motor gets turned off and is very important here.(In this case between the + and - of the voltage input , where the diodes white mark is closer to the +, which means current flows out this way but cannot enter this way, so to speak. just to be safe as the internal circuit is unknown here)
  • Q1 - A transistor - You can try and reuse a transistor from a broken PCB or you can buy cheap ones. Just loop up the specification sheet first and make sure it can handle the load you want. In this case more than 12volts with at least 1A current. But such a diode will need a heatsink, so to avoid a heatsink, aim for 5A or more. This circuit uses a NPN transistor.
  • R1 - The specification sheet will also tell you the minimum and maximum voltage needed to turn on the transistor. Even if you are on target use a small resistor always.

The nice thing is that you can control the speed of the motor, which is true with model because the specification sheet says the applied voltage (GREY WIRE) controls the speed. While the circuitry is powered by (RED WIRE) its own constant voltage. You can even connect the (YELLOW WIRE) to the GPIO set to INPUT, and this will tell you the RPM of the Motor. 1 Pulse is 1 revelotuion and counter per minute. Again use a Resistor on the INPUT GPIO to make sure that voltage is not less than 3.3v and not more than 5v. (GREEN WIRE) Set the direction of the motor, please refer to the manual.

For calculations on the PWM you will need to ask on Electronics Stack Exchange for the details as there are some calculations based on the all the elements.

Using a relay needs very similar considerations and cannot just be triggered with the GPIO pin because relays use electromagnet coils that also generate back emf that can damage the GPIO pin. Relays also need a transistor, seperate voltage and flyback diode. You can replace the motor here with a Relay if you wish. Then just connect the relays switch PINS to the power source of the motor, preferable inbetween negative. The TIP120 can handle up to 60Volts and 5A current at 60Volts. When dropping to 12volts you get a nice 25A upper limit (OHMS LAW)

Arduino based example for reference.

enter image description here

  • Why must the raspberry pi and the pump be on different power sources? Is there a way for it to be on the same power source?
    – RubyNerd
    Commented Feb 8, 2014 at 2:18
  • ONly different power sources if the voltages are different. You can use the same power source, but make sure it more than what Pi and MOtor need at full load. So maybe a 3A~5A switching power supply. Wire the Pi and motor direct to power supply.
    – Piotr Kula
    Commented Apr 29, 2014 at 11:31

That sounds interesting! But you will not get along without an additional power supply. Input voltages of 6 or 12V are beyond of what the Raspberry can handle and with powers in the range of 1.2 - 7.1 W you will have currents of 200 to ~500 mA.

I'm not an expert at all, but I'd assume that you will need at least a suitable transistor (with a GPIO pin at the base) to control the pump and probably a clamp diode to protect the circuit.

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