nat.andrews
Posts: 2
Joined: Mon Aug 20, 2012 2:46 am

Will An Ebay Relay Board work with the pi?

Mon Aug 20, 2012 2:47 am

Something similar to this


http://www.ebay.com.au/itm/New-5V-8-Cha ... 021wt_1139

I Notice that it has a vcc line, 5v in here, but would the 3.3v output from the pi be enough to trigger the relays?

Thanks

fruitloaf
Posts: 84
Joined: Sun Feb 05, 2012 11:41 am

Re: Will An Ebay Relay Board work with the pi?

Mon Aug 20, 2012 6:40 am

I hope it will work, I've bought a very similar 2 relay board but it hasn't arrived yet.

TarjeiB
Posts: 157
Joined: Thu Jul 12, 2012 3:33 pm

Re: Will An Ebay Relay Board work with the pi?

Mon Aug 20, 2012 7:35 am

As did I - let's cross our fingers ;)

User avatar
Jim JKla
Posts: 2218
Joined: Sun Jan 29, 2012 11:15 pm
Location: Newcastle upon Tyne UK

Re: Will An Ebay Relay Board work with the pi?

Mon Aug 20, 2012 7:38 am

Keep us in the loop let us all know if they work. ;)
Noob is not derogatory the noob is just the lower end of the noob--geek spectrum being a noob is just your first step towards being an uber-geek ;)

If you find a solution please post it in the wiki the forum dies too quick

domesday
Posts: 258
Joined: Fri Oct 21, 2011 5:53 pm
Location: UK

Re: Will An Ebay Relay Board work with the pi?

Mon Aug 20, 2012 8:49 am

It should work, but the relay coils will require 5V. So you will need to power the board with 5V, there are transistors on there for switching the coils so they should switch with the Pi 3.3V GPIO outputs.

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Will An Ebay Relay Board work with the pi?

Mon Aug 20, 2012 9:20 am

I don't like the look of this requirement:
Each one needs 15-20mA Driver Current.
If that is right, then even an AVR would have problems driving all 8 relays at the same time.

nat.andrews
Posts: 2
Joined: Mon Aug 20, 2012 2:46 am

Re: Will An Ebay Relay Board work with the pi?

Mon Aug 20, 2012 1:23 pm

1.6 Amps (Max) to power the relays alone, just need a beefier 5v supply. 3amp should be sufficient.

From my understanding the relays are powered from the vcc line on the board. The transistors switch (using the 3.3v output from the pi) the 5v to power the relay.
Last edited by nat.andrews on Mon Aug 20, 2012 1:25 pm, edited 1 time in total.

bcatalin
Posts: 22
Joined: Mon Jan 30, 2012 9:45 am

Re: Will An Ebay Relay Board work with the pi?

Mon Aug 20, 2012 1:24 pm

I have a similar board ( 4 relays) and is working fine directly connected to the Pi. I'am using the board to
control my irrigation system over the internet using Pi. The system has been tested for 2 weeks on cold and now it has one week in full production and is working like a charm. It is very nice to control everything from miles away.

nickorossa
Posts: 71
Joined: Wed Mar 14, 2012 12:42 pm
Location: Swindon, UK, Planet Earth.

Re: Will An Ebay Relay Board work with the pi?

Mon Aug 20, 2012 5:12 pm

nat.andrews wrote:1.6 Amps (Max) to power the relays alone, just need a beefier 5v supply. 3amp should be sufficient.

From my understanding the relays are powered from the vcc line on the board. The transistors switch (using the 3.3v output from the pi) the 5v to power the relay.

At 15-20ma, then that equates to a maximum of 160mA for 8, not 1.6A. Either that of my maths is screwed up again.


N.

fruitloaf
Posts: 84
Joined: Sun Feb 05, 2012 11:41 am

Re: Will An Ebay Relay Board work with the pi?

Mon Aug 20, 2012 5:18 pm

nickorossa wrote:
nat.andrews wrote:1.6 Amps (Max) to power the relays alone, just need a beefier 5v supply. 3amp should be sufficient.

From my understanding the relays are powered from the vcc line on the board. The transistors switch (using the 3.3v output from the pi) the 5v to power the relay.

At 15-20ma, then that equates to a maximum of 160mA for 8, not 1.6A. Either that of my maths is screwed up again.


N.
You're correct or we're both screwy. My reading of the circuit is that the GPIO pins provide a control signal and the relays themselves are powered by the 5V line which unlike the rest of the GPIO pins you can draw a reasonable amount of power from. The 15-20mA powers the relays and unless you have a really power stressed Pi I imagine it should be able to cope driving that number of relays though if it doesn't you can just provide another 5V power source.

Hugh Jarse
Posts: 46
Joined: Mon Mar 05, 2012 5:03 pm

Re: Will An Ebay Relay Board work with the pi?

Tue Aug 21, 2012 3:48 pm

My recollection of the current limitations was that you cannot exceed more than 51ma total GPIO output without affecting the voltage regulator. In addition, I think a maximum of 16ma per pin is stated.

Either of these would make me concerned enough to add an interface layer between the GPIO and this relay board (assuming this is not already done by the board input).

fruitloaf
Posts: 84
Joined: Sun Feb 05, 2012 11:41 am

Re: Will An Ebay Relay Board work with the pi?

Tue Aug 21, 2012 4:02 pm

Hugh Jarse wrote:My recollection of the current limitations was that you cannot exceed more than 51ma total GPIO output without affecting the voltage regulator. In addition, I think a maximum of 16ma per pin is stated.

Either of these would make me concerned enough to add an interface layer between the GPIO and this relay board (assuming this is not already done by the board input).
These relays have a transistor interface and are powered from the 5V line which I believe you can draw more power from. At least I'm assuming you can since you can power the board via this pin - I *think* I saw a safe limit of ~120mA from this.

Hugh Jarse
Posts: 46
Joined: Mon Mar 05, 2012 5:03 pm

Re: Will An Ebay Relay Board work with the pi?

Tue Aug 21, 2012 4:33 pm

I interpreted the

"Each one needs 15-20mA Driver Current."

as an external interface requirement for the driving the board, rather than a power (supply) requirement.

Hopefully this will be fine then.

TarjeiB
Posts: 157
Joined: Thu Jul 12, 2012 3:33 pm

Re: Will An Ebay Relay Board work with the pi?

Wed Aug 22, 2012 8:39 am

I did order one of the ones mentioned above with 2 relays on, which need a coil current - but it hasn't arrived yet.

I did however also order a couple of these mosfets, and have now tested it successfully!

I took an USB wire and plugged into the RPi, connected the plus and minus to one end of the board (the plus is just a passthrough and not neccessary) and the Gate to GPIO 23.

Result: 0V through when GPIO 23 was low, 4.91V through when the GPIO 23 was high. Success! This also means it needs no power from the RPi, just the GPIO signal.

I am going to connect it to a 12-48V step up converter though, which I bet has a coil inside and there's no diode protection other than the internal diode - hope it's fast enough to not burn my GPIO's with a return current when it turns off...

TarjeiB
Posts: 157
Joined: Thu Jul 12, 2012 3:33 pm

Re: Will An Ebay Relay Board work with the pi?

Wed Aug 22, 2012 8:46 am

Hugh Jarse wrote:I interpreted the

"Each one needs 15-20mA Driver Current."

as an external interface requirement for the driving the board, rather than a power (supply) requirement.

Hopefully this will be fine then.
The coil needs 5V, from the 5V pin, or USB, or wherever. This is the bit that will take 15-20mA per relay.
The switch to tell the transistor to turn the 5V on and off and actually activate the relay, can use 3.3v from the GPIO and doesn't require any major amount of current, it's just a switch signal.

It still needs *some* amount of current to register as triggered, but I'm guessing GPIO will do the trick. I'm certainly going to test it when I get it :)

pihead
Posts: 12
Joined: Sun Aug 26, 2012 1:22 am

Re: Will An Ebay Relay Board work with the pi?

Sun Aug 26, 2012 8:06 pm

According to this site: http://jxdz.en.alibaba.com/product/4389 ... 73_5V.html

The SRD-5VDC-SL-C relays on that board draw 0.36 watts, which equates to 72 mA each.

The board doc on eBay indicates 15-20 mA drive current - this should be the current that you are expected to provide at the inputs to the board, not the current being drawn by the relays. The current required for the relays is 8x72=576 mA, but you'll need overhead because relays draw more current when you are activating them. If you are planning on being able to trigger all eight relays at the same time, the inrush current could be more than twice the steady-state current.

You can get around this in a couple of ways. Get a 5 volt supply that can handle the maximum inrush current, or use an electrolytic capacitor on the 5 volt rail to supply the extra current when the relays are being triggered. If the relays are not being triggered frequently, the capacitor approach is usually more energy efficient (bigger power supplies tend to waste more power than smaller ones) and keep your footprint small. Something like a 100 or 250 microfarad, 15 volt capacitor should do it.

Given a drive current of 15-20 mA, this would appear to be a board with optoisolators on its inputs - it takes about that amount of current to drive the LED in an optocoupler. As long as the input is optically coupled and not tied to 5 volts, you should be good - but you need to make sure that you limit the current into the optocouple with a resistor. Depending on the voltage drop of the LED, a resistor value in the 120 ohm range should work - but do the math, take some measurements to make sure that you're not overloading the Pi's outputs (or frying the LEDs in the optoisolators).

If these aren't optoisolated, or if they are some how tied to the 5 volt lines on the relay board, make sure to either use 3.3 -> 5 volt driver-converters between the Pi and your relay board, or else limit the voltage on the interface pins to 3.3 volts with a zener diode or clamping circuit. Otherwise, you're gonna have an overcooked Pi!

For some ideas on how to protect inputs, here's a pointer to an Arduino tutorial - beware that the Pi is limited to 3.3 volts, not 5 volts, but the principles and fixes are similar - just aim for 3.3 volts instead of 5: http://ruggedcircuits.com/html/ancp01.html

Here's a "Tips and Tricks" for 3.3/5 volt interfacing- see Tip #10 - #12: http://www.newark.com/pdfs/techarticles ... sBrchr.pdf

And a specific tutorial for the Pi: http://elinux.org/RPi_Tutorial_EGHS:GPI ... n_Circuits

My favourite method of isolation, whenever possible, is using opto-isolators. Done properly, these give kilovolt-and-better isolation and absolute level conversion. The elinux.org tutorial discusses these. If the board already does this (and it looks like it does, as the devices along the top of the boards have four pins - a simple transistor would have only three) - you're 'golden'.

TarjeiB
Posts: 157
Joined: Thu Jul 12, 2012 3:33 pm

Re: Will An Ebay Relay Board work with the pi?

Sun Sep 02, 2012 4:38 pm

Well I just tried one of these relays with limited luck :/

The input for switching can't be many mA, as as soon you set "out" direction on a GPIO pin, it will turn the relay on, no matter if it's 1 or 0.

I measured 152 mV when 0 and it kept the relay on...
Unexporting also kept the relay on.

I had NO load on! I don't know if this may "flip the switch" back if there's load on.

I didn't try to set direction to "in" as I'm afraid to break something, but I may try later and see if that turns it off again.

TarjeiB
Posts: 157
Joined: Thu Jul 12, 2012 3:33 pm

Re: Will An Ebay Relay Board work with the pi?

Wed Sep 05, 2012 1:35 pm

I've done some further testing here with resistors and whatnot (it's a miracle I haven't fried the Pi...)

The relay is ALWAYS on if the GPIO direction is set to "out". High or low does not matter.
If I set direction "in" it turns off immediately, just as if I disconnect the GPIO wire.
I've tried a load of resistors from the GPIO both to ground, to 3v3 and in line with GPIO -> relay in. They all make it stay ON.

The only time it was actually off, was when I put a 47k resistor from the GPIO to the IN on the board, then the switch LED glows dimly, but the relay does not switch on. However, setting the GPIO pin to HIGH does not make the LED glow brighter or the relay switch on.

What's wrong? I don't get it - it works really well if I use "in/out" as a switch, but not as long as it's state is "out" even though the measurements say 3.3v HIGH and 150mV LOW. Is my Pi broken somehow? Could the relay be broken somehow?

It's this one: http://cgi.ebay.co.uk/ws/eBayISAPI.dll? ... 0735738629

fruitloaf
Posts: 84
Joined: Sun Feb 05, 2012 11:41 am

Re: Will An Ebay Relay Board work with the pi?

Wed Sep 05, 2012 3:30 pm

I have to say that my relay board doesn't show the same symptoms as yours though its not the same one. I accidentally ordered a 5V board (wasn't paying attention and bought from the wrong tab I had open when looking through them doh) so I have a simple transistor in the way to do the level shifting but when its off its pulled to ground.

Maybe you need to try a pull down like below?


Gpio--------------Relay
|
R 1k
|
Ground

TarjeiB
Posts: 157
Joined: Thu Jul 12, 2012 3:33 pm

Re: Will An Ebay Relay Board work with the pi?

Wed Sep 05, 2012 4:34 pm

fruitloaf wrote: Maybe you need to try a pull down like below?


Gpio--------------Relay
|
R 1k
|
Ground
I tried this just now, with a 4.7k pulldown. The "in 1" on the has 3.3v when GPIO is high, and it has 126mV when the GPIO is low. Which seems more than sufficient to keep it saturated. I've also tried 12k, 100k, and also directly from the gate of the transistor to the ground with a 12k, all with the same result... The relay stays on.

PS. As long as I have any resistor connected between the gate and ground or GPIO and ground, it will also stay on even if I set direction to "in" or disconnect the GPIO itself... What's happening?

It's this one:
Image
I can't quite understand the LED stuff and whatnot though.

TarjeiB
Posts: 157
Joined: Thu Jul 12, 2012 3:33 pm

Re: Will An Ebay Relay Board work with the pi?

Wed Sep 05, 2012 5:06 pm

[email protected] wrote: OK. The way it's wired is to be active low. So set the GPIO to output and write 0 to turn the relay on, and write 1 to turn it off..

HOWEVER.... It's being fed from a 5v supply and that 5V will sink into a GPIO pin at 3.3v and likely destroy it (in time - you might be "getting away" with it for now).

You really need to undo that jumper and connect the input side to +3.3v and the drive side to +5v.

And is the module you have the same as those photos on ebay? I'm guessing there are compnents on the underside as there are not enough on the top side to match the circuit diagram given...

-Gordon
The module is exactly like the one on Ebay - here's the image:
20120905_185632.jpg
20120905_185632.jpg (49.04 KiB) Viewed 9273 times
There are no components on the underside, just a few tracks in the PCB.

I connect the 5v pin to the "VCC" pin, the GPIO 23 to the "in1" pin, and ground to the "GND" pin.
The relay then turns on, and won't turn off untill I disconnect the GPIO pin or set it to "in".

I'm unsure of which jumper you mean, does the 5V pin go through the transistor and to the "in1" pin?
I've read that the GPIO on the Pi is not 5v tolerant, so I have taken great care that the 5v has never been connected to anything else than the "VCC" pin and no connections to the GPIO.

User avatar
[email protected]
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: Will An Ebay Relay Board work with the pi?

Wed Sep 05, 2012 5:13 pm

TarjeiB wrote:
[email protected] wrote: OK. The way it's wired is to be active low. So set the GPIO to output and write 0 to turn the relay on, and write 1 to turn it off..

HOWEVER.... It's being fed from a 5v supply and that 5V will sink into a GPIO pin at 3.3v and likely destroy it (in time - you might be "getting away" with it for now).

You really need to undo that jumper and connect the input side to +3.3v and the drive side to +5v.

And is the module you have the same as those photos on ebay? I'm guessing there are compnents on the underside as there are not enough on the top side to match the circuit diagram given...

-Gordon
The module is exactly like the one on Ebay - here's the image:
20120905_185632.jpg
There are no components on the underside, just a few tracks in the PCB.

I connect the 5v pin to the "VCC" pin, the GPIO 23 to the "in1" pin, and ground to the "GND" pin.
The relay then turns on, and won't turn off untill I disconnect the GPIO pin or set it to "in".

I'm unsure of which jumper you mean, does the 5V pin go through the transistor and to the "in1" pin?
I've read that the GPIO on the Pi is not 5v tolerant, so I have taken great care that the 5v has never been connected to anything else than the "VCC" pin and no connections to the GPIO.
I was refering to the jumpers on the circuit diagram, but looking at the board, I'd say it was different from the circuit diagram as there is not enough components - no opto isolator for a start...

So what happens when you drive the GPIO high as an output? does it stay on?

Maybe it's actually broken... Given that the board is not the same as the circuit diagram, then who knows!?!

-Gordon
--
Gordons projects: https://projects.drogon.net/

TarjeiB
Posts: 157
Joined: Thu Jul 12, 2012 3:33 pm

Re: Will An Ebay Relay Board work with the pi?

Wed Sep 05, 2012 5:17 pm

[email protected] wrote: So what happens when you drive the GPIO high as an output? does it stay on?

Maybe it's actually broken... Given that the board is not the same as the circuit diagram, then who knows!?!

-Gordon
It stays on when I drive GPIO high, and stays on when it's low... 3.3V high and 126mV low and it's saturated all the same. I'm also wondering if it may be broken, just so strange since both relays act the same, as I get the exact same results on "in2" (there's two on the same board) :(
Also, it turns off like a champ if I pull off the GPIO pin. Maybe the transistor is just too sensitive, if there's such a thing?
I have a simple MOSFET which seems to work like a charm, I may just have to use that instead...

fruitloaf
Posts: 84
Joined: Sun Feb 05, 2012 11:41 am

Re: Will An Ebay Relay Board work with the pi?

Wed Sep 05, 2012 5:50 pm

That's the board I have but I used a transistor to drive it as from my reading of the circuit it puts 5V into the GPIO line via the status LED. If you look VCC goes to R1 which goes via a diode and LED to the GPIO.

My reading of that (and I'm far from an electronics expert) is that when your GPIO is high the LED will be lit as you are still getting 5V - 3.3V into it and LEDs will show a usable amount of light down into low volt levels. When low you are sinking the 5V into GPIO. I think that the R1 resistor is what is limiting the current and stopping you from blowing up your Pi. I may of course be completely wrong about the above :)

I'm using a transistor and a couple of resistors to drive the input successfully.

TarjeiB
Posts: 157
Joined: Thu Jul 12, 2012 3:33 pm

Re: Will An Ebay Relay Board work with the pi?

Wed Sep 05, 2012 6:00 pm

fruitloaf wrote:That's the board I have but I used a transistor to drive it as from my reading of the circuit it puts 5V into the GPIO line via the status LED. If you look VCC goes to R1 which goes via a diode and LED to the GPIO.

My reading of that (and I'm far from an electronics expert) is that when your GPIO is high the LED will be lit as you are still getting 5V - 3.3V into it and LEDs will show a usable amount of light down into low volt levels. When low you are sinking the 5V into GPIO. I think that the R1 resistor is what is limiting the current and stopping you from blowing up your Pi. I may of course be completely wrong about the above :)

I'm using a transistor and a couple of resistors to drive the input successfully.
Yes! That sounds similar to what I've seen some times - I was thinking I just didn't understand it.

However the GPIO is just GPIO -> R 1k -> Gate on the transistor and no other tracks on either side as far as I can see, does power really flow back through the gate of a transistor?

If this is the case I would just drop the LEDs alltogether, but as far as I can see this will break all contact with GND?

Maybe if I removed only the green one, it shouldn't break anything at least...

*EDIT* Looked again and the VCC doesn't go into R1 as far as I can tell, it goes to the green LED, into its own resistor and then to GND... The R1 resistor is only connected to the GPIO input (on the actual board).

*EDIT2* Just tried without the green LED and no difference.
Last edited by TarjeiB on Wed Sep 05, 2012 6:22 pm, edited 1 time in total.

Return to “Automation, sensing and robotics”