# How can i drive this 5v Relay board with RPi?

Beginner here, so this problem came up:

I got a 250vac 30A relay board which seems to require 5v to be driven.
It has 4 input pins: GND, IN-, IN+, VCC
What are the IN- and IN +?

My rpi output pin does not seem to be able to triger the relay when connected in the IN+ (although the board's led does turn on and off)
Here is a pic of the 4 pins: Here is the ebay link: Ebay Item Link

Please note that my relay (pic #1) has 4 connection pins while the other two (pic #2 and #3) have 3 pins.

update:
Thanks for the plenty of answers, I went through all of them, then went back and tested the things you guys suggested.
The GND and IN- pins are indeed connected through the jumper present in just behind them. I think it's in place in case you want to power the 5v input from another source on VCC and GND, then fire the relay with the IN+ and IN- connected to the GPIO and GND respectively.

That said, it seems like although i am powering the board with 5v on its VCC and GND, the switch wont fire unless it has 5v on IN+. I tried connecting the board to a usb 5v source like this (jumper shorting GND:IN-):

5v+ : VCC
GND : GND


Then got a wire of the same 5v+ and touched the IN+ pin. The switch fired whenever the pin touched 5v.

Update 2:
I tried to replicate the same connection on the RPi 5v rail, (5v:VCC, GND:GND, test 5v: IN+) the relay does not fire. (jumper shorting GND:IN-)

I guess i reached the bounds of my E.E. knowledge, please advise, what am I missing?
Is it an Amperage issue?

• what are you connecting to the GND+VCC pins? – dandavis May 15 '17 at 14:23
• you should ask on the manufacturer's website on how to use it. My best guess is, you supply VCC with 5V and drive IN+ and IN- with some voltage or current. – user3528438 May 15 '17 at 14:32
• Check with a meter but I think that jumper on the board connects IN- to GND. So all you need to do is supply the correct voltage/current on the IN+ pin. (plus power and ground). If you can read the part number off the opto-isolator (the 4 pin part just above IN+ and VCC) then that should give you the requirements. Also check the power requirements for the relay by finding that data sheet and make sure that your +5V source can supply sufficient current. – Andrew May 15 '17 at 14:36

Here is a likely schematics of your relay module:

Relay to Raspberry connection:

VCC to +5V
IN+ to GPIO
IN- to GND
GND to GND


GPIO is configured as push/pull output, no pull-up, no pull-down. Relay is turned on by writing 1 to the port.

Alternate connection if the first one can't activate relay:

VCC to +5V
IN+ to +5V
IN- to GPIO
GND to GND


GPIO is configured as open-drain output, no pull-up, no pull-down. Relay is turned on by writing 0 to the port.

As voltage between IN+ and IN- is more then 2V, GPIO is never forced above 3.3V, so it should be pretty safe.

• there's an LED on the board, as mentinoed by OP... – dandavis May 15 '17 at 14:59
• Unlikely schematic. Probably the LED is in parallel with the coil (with a series resistor, of course). Otherwise the 3V Rpi output would not work. Connecting GND to MCU GND negates much of the value of the opto. It's best to keep the relay supply separate from the MCU supply. What software did you use for that schematic? It's nice. – Spehro Pefhany May 15 '17 at 15:09
• You are right, DS1 is probably LED. So if the suggested connection is not working, this one should: VCC to +5V, IN+ to +5V, IN- to GPIO, GND to GND. In that case, relay is turned on by writing 0 to the pin. – Damir Škrjanec May 15 '17 at 15:10
• Rpi is 3V so it may or may not be marginal with the setup there. Might have to reduce the series resistor to the opto. Without a schematic or specs we are guessing about the cheap Chinese board. – Spehro Pefhany May 15 '17 at 15:11
• @DamirŠkrjanec VCC to +5V and GND to GND, OK. But, Wont IN+ to +5V and IN- to GPIO be like shorting 5v ->GPIO? wont that damage the Pi taking into account that RPi's GPIOS work on 3.3v? (it's the only proposed connection method i have not tried yet) – krasatos May 16 '17 at 12:03

Your module has an optocoupler between the inputs and the relay. This type of device has a LED in one side and a phototransistor in the other side, which is driven by the light generated when you make some current flow through the LED. Therefore, I guess that the inputs IN+ and IN- should be used as in the image below:

This devices lacks information about how much current should flow in the LED for a proper switching of the output. This would be necessary to calculate the resistance's value. If possible, try to specifies the part number name of the optocoupler, then would be possible to take a look in the datasheet. But 10mA it is usually a good value for current in the input, so it would gives you a resistance around 500 Ohm, if you have 5V at your I/O. So, you can choose 470 Ohms or 560 Ohms, which are the most common around 500.

• AFAIK these modules have a transistor that drive the optos (Q1 in the images), so the user does not have to drive the LED directly. – Wesley Lee May 15 '17 at 14:35
• It's hard to be sure but it looks like the input lines go direct to the opto isolator. I'd guess Q1 is controlling the relay, it's unlikely it would be driven directly from the opto output. – Andrew May 15 '17 at 14:39
• You want ~10mA after allowing for the LED voltage drop. 500 Ohms at 5V is assuming no voltage drop over the LED in the optocoupler. – Andrew May 15 '17 at 14:41
• @Andrew you are right, I forgot the voltage drop in the diode. But anyway, you will have something like 8mA~9mA with 500Ohm. – Luis Possatti May 15 '17 at 14:50
• modules should not require any math to use; if the board tell you 5v, it should self-limit – dandavis May 15 '17 at 14:51

So i found a work-around and would like to share it in order to get your comments on its safety.

I realised that the relay (lets call this relay Relay1) wouldn't fire with the 3.3v from the GPIO but only by with 5v (~1a) on the IN+ pin.

I had a relay board laying around from another project that would work on 3.3, had it tested before (lets call it Relay2). I could not use *Relay2*for the current project as its rated for 10a max and my water boiler is ~20a.

So i made a second circuit, with an extra 5v source, which i connected to the Relay1's VCC and GND pins.
Then took a wire from the source's 5v+, ran it through Relay2's COM port,
and another wire from Relay2's NO to Relay1's IN+ pin.

This way when the RPi operates Relay2, it would close the second cirquit and send 5v to Relay1's IN+ pin and operating it (closing the 220v circuit) succesfully.

Now, i know this is not the optimal way to solve it and i used an extra relay board and an extra power suply but it does work.
My question is: is it safe to use? Is there any thing i have overlooked that might present a hazzard?