2

So, I would like to connect a water pump to my Pi and programatically turn the pump on and off.

I am looking at this pump: http://www.cooking-hacks.com/immersible-pump-water-tube-for-open-garden-and-open-aquarium

It says "3.5-12V DC input voltage".

Does this mean that setting this up would be as easy as connecting the positive end of the pump to a programmable GPIO pin (and have then negative side going to ground) and setting the pin high to turn the pump on and low to turn it off? Here is a quick diagram I (very quickly) threw together.

enter image description here

I am sure this is too simple because most people i see are using all sorts of extras like resistors or motor driver chips, etc.

Main Question: So is it as simple as I think? If not, could some explain why it won't work this way?

Bonus Question: If not, could someone explain how I would hook it up?

In Reference to Question Powering a 3-12V water pump on raspberry pi

I saw this question and couldn't quite make sense of what the OP was asking. In this scenario I have no relay or a breadboard power supply (unless the OP is referring to getting power from one of the GPIO pins). What really threw me off though was the sentence "Is it possible, to rspi to breadboard power supply usb, and a pump to it's 5V output?"

I am not sure if rspi is a type-o or an acronym but I don't know what that means. And I am not sure what a breadboard power supply usb is either or if it is even one thing. And wouldn't plugging the pump into the 5V output just constantly turn on the pump?

So I did see this question I just wasn't really sure how much of it was applicable.

It would be awesome if someone could explain/edit that question (That is if I'm not just being stupid and not understanding his question).

TheBlindSpring
  • 159
  • 2
  • 9
  • As Phil's answer goes: No. Don't even try. You'll fry the Pi for no reason. Take a look it this answer http://raspberrypi.stackexchange.com/a/28201/19949 – Ghanima May 28 '15 at 17:48

2 Answers2

5

NO. That setup won't work. The GPIO pins are not suitable to drive equipment directly, due to the fact that:

  1. They can only provide a very limited current (up to 50mA, although this might be higher on the rPi2)
  2. They have no protection against flyback currents etc., so driving a load with a motor or relay in it will possibly kill your rPi

You will need the following:

  • A suitable powersupply to provide sufficient current to the pump. Given the broad range of voltages the pump accepts, you could get 1 powersupply at 5V and supply both the rPi as well as the pump from this supply. Whatever you do, make sure the grounds of your rPi and your pump are connected together (especially if you use separate power supplies).
    • A relay to switch the pump (you don't mention the Amp rating of the pump, so I can only guess the specifications here)
    • If the switching current for the relay is too high for the GPIO pins, you might need to put a transistor in in between the relay and the GPIO pins to help switch the relay. If the power needs of the relay are not too big, you could potentially switch the pump with just the transistor.
    • A resistor (typically 10kOhm) on the GPIO line to further limit the current on that line to avoid overloading the GPIO pin.
    • Depending on the make and model of the pump, you might need to put a flyback diode across its + and - terminals - this will allow the flyback current generated by the dead weight of the motor to flow safely back into the motor itself
    • A flyback diode across the relay for the same reasons as above.

Net - this is not straightforward (but also not difficult). You might get better answers on the Electrical Engineering Stackexchange site - however, they will not design this for you - there are tons of people doing aquarium pumps with Pi's/Arduino's so you should easily find reference designs in a quick Google search (e.g. this one)

Phil B.
  • 5,043
  • 15
  • 30
  • Thank you for this really detailed answer. I will start by saying I have very little understanding of electronics (bought the Pi to start learning). As for the Amp rating of the pump, I only have the link to the pump and I dont know where else I would find that information. I will definitly check out EE Stack Exchange. I am not looking for it be designed for me, just ask stupid questions like why I need a relay for the pump or what a relay even is? Would those be appropriate questions for EE SE? And lastly, thank you for answering my questions (as trivial as they were). – TheBlindSpring May 28 '15 at 19:15
  • EE.SE will answer any question, as long as it is formulated properly and shows enough effort put into prior research (i.e. don't ask for stuff you could have googled yourself). That said, I took a quick look at the link you provided - they are very short on technical details, but: 1) They say the power output of the pump is 0.5W-5W, which leads me to believe that at 5V supply you'd be dealing with 1A of current (P=V*I), so your setup needs to be able to provide at least 1A, likely more during peaks. Also, they sell an entire kit (Arduino-based), could be better than trying to do it yourself – Phil B. May 28 '15 at 19:21
  • I thought about a kit, but I figured it better I try to actually learn why the kit works the way it does. Im glad you found the power output from that link, thanks for that. – TheBlindSpring May 28 '15 at 19:26
  • Also @Phil B. You said "If the power needs of the relay are not too big, you could potentially switch the pump with just the transistor." I don't quite get this, are you saying I wouldn't need a relay at all? – TheBlindSpring May 28 '15 at 19:34
  • Correct - but this is where my expertise ends - there are transistors that can handle quite a bit of load, but if this 1A-1.5A pump is not too strong, that I don't know. BTW, you can buy Sainsmart Relay boards like this one which would take care of the relay & transistor part for you - and don't cost much ($2 in the US). That board actually uses an optocoupler instead of a transistor which is even better as it isolates the rPi power from the relay/pump power so you don't even have to connect the GNDs together. – Phil B. May 28 '15 at 20:25
  • Does using the Sainsmart Relay only elimnate the transistor, or does it also eliminate the resistor and fly back diodes? – TheBlindSpring Jun 17 '15 at 14:35
  • My Sainsmart Relay (4 relay board) has 4 Diodes on it already (D1-D4) - I assume those are flybacks. I don't see a resistor on any of the INx lines - so I would put a 1k Ohm resistor on the wire between the GPIO pin and the INx input of the board. – Phil B. Jun 17 '15 at 16:38
0

Google is your friend and should be your first stop. Be sure to choose Images as you will get schematics and pictures that can lead to the hosting page. Most solution issues with I/O apply to RPi and Ardunio equally. The output pins similar have limits. Exceeding them will damage the controller.

Here is an example of a Google search for your issue. You can find many more yourself. https://electronics.stackexchange.com/questions/64575/turning-water-pump-on-off-using-arduino-uno-r3 Also several sites that sell RPi and Ardunio boards and shields offer tutorials for free that advance your knowledge base.