1

I asked a questions about controlling a water pump with the pi and in one of the answers (https://raspberrypi.stackexchange.com/a/32014/19436) he mentioned I could get one power supply to power both the Pi and the Pump. How would one go about taking a power supply and connecting it to two different things? Would this require building your own power supply?

EDIT: So it seems as though two power supplies is the way to go using a relay. I am trying to understand how to use a relay... Is this circuit sensible for what I would like to do? Green is ground, yellow is 5V and blue is GPIO.

enter image description here

3

An easy way to do this is to buy a powerful power supply (in regards to your previous question) like this one: 5V DC 3A power supply and either cut off the barrel plug - leaving you with a + and a GND wire (which is which you can easily determine with a voltmeter or by looking at the polarity of the plug and how it's wired). You then connect the positive +5V wire both to your PI (one of the 5V pins on the GPIO header, i.e. pin 2 or 4) and your relay board, and the GND wire to one of the many GND pins on the Pi as well as to the GND of the relay. Note however that doing this means the Pi and the relay board are linked in circuit and not fully electrically isolated, which defeats the purpose of the optocoupler on the Sainsmart relay board I referred to in my answer to your previous question.

If you want to full separate the two circuits, you keep your original USB wall wart for the rPi, and you get a separate supply for the relay board and pump. In this case, don't connect the separate supply's GND to the rPi's ground - the optocoupler ensures the two circuits are fully separated. Oh, and get yourself a primer on electronics, I can recommend Forrest Mims' handbook as a quick but thorough read.

EDIT: You might be able to power your relay & pump through the GPIO 5V pin if you buy a powerful enough USB 5V power supply for your rPi (would need to be 3A or more at least if this is for a B(+), 4A for an rPi 2) - the 5V supply has a 2A polyfuse which sets the upper limit for the current provided. Check this forum post on raspberrypi.org for more details. But be careful - you could pull too much current for the rPi to keep running reliably, and, as with everything electronic, take care in testing your setup step by step to avoid making a costly mistake (read: fry your rPi). Especially when working with the 5V GPIO pin it is easy to accidentally short it with another pin, potentially causing damage to that pin or the entire processor.

EDIT TWO: Got myself a bit mixed up there in all the options, but basically you have 4 things to provide power to:

  1. The rPi (typically powered via USB)
  2. The opto-coupler on the board using the 4pin header's VCC - typically powered using the 5V (or 3V3 volt) pins on the GPIO header
  3. The relays (either powered from the same 5V supply as the opto-coupler when you put the jumper across the 3-pin header's VCC and JD-VCC, or separately powered by removing that jumper and supplying 5V to JD-VCC, the latter would fully isolate the GPIO pin from the relay)
  4. The pump itself - my answer above shows how you can do this with a separate or joint 5V power supply, but you could just as well use a 12V supply or 9V supply if you have those handy. This power supply gets its positive wire attached to the middle screw terminal of the relay, and either the left or the right terminal (but not both) go to your pump.

You would need a common ground between 1&2, and if you leave the JD-VCC/VCC jumper in place, you would need to also need a common ground for 3. #4 can be independently grounded.

Check this link on raspberrypi.org for a lengthy discussion on how to set up such a relay board: https://www.raspberrypi.org/forums/viewtopic.php?t=19222

  • So this would mean there would not be anything plugged into the mini-usb port then? I use a breakout, is there any reason I can t connect the 5V pin to the bread board and then connect 5V wire to that part of the bread board? – TheBlindSpring May 28 '15 at 21:35
  • Now you need to be more specific - which 5V pin, which wire, and which part of the breadboard (in other words - what does that connect to) are you talking about? – Phil B. May 28 '15 at 21:55
  • Added some more wording to deal with your last question in the comment – Phil B. May 28 '15 at 22:05
  • 1
    We should probably move this discussion to chat - let me answer your last Q and if you have more Qs, we'll move it over. There is a 3-pin and a 4-pin header. The 3-pin header has a jumper on it and is for the supply current to the circuit you are trying to switch - you either connect JD-VCC with VCC to make this both powered from the same source, or supply 5V and GND to the JD-VCC and GND pins. The 4-pin header has VCC and GND to power the relay, and an IN1 and IN2 which you connect to your GPIO pins to switch the individual relays. The relay is double-throw, so each relay has 3 screw .... – Phil B. May 29 '15 at 16:52
  • 1
    .... terminals, the middle one is the line in, the left and right ones are the line out (at least in your application). You can connect your pump power supply's +5V line to the middle terminal, and a wire from either the left or the right (but not BOTH) terminal to your pump. Now using your GPIO pin you can switch the relay to either direct the 5V current via the left or the right terminal, effectively either supplying or not supplying current to the pump. – Phil B. May 29 '15 at 16:56

Your Answer

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

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