dhester
Posts: 20
Joined: Mon Jul 16, 2012 8:35 pm

Re: Sainsmart relay

Wed Mar 27, 2013 9:48 pm

Fixedd I haven't any experience in making PCBs so do you have a breadboard layout for your solution?

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Sainsmart relay

Tue May 28, 2013 3:37 pm

I fail to see why any special interfacing is required. The relay board has opto isolators for driving the relays and they can be triggered directly from the Pi since they represent one LED load or less. Also the opto input is isolated from the rest of the board so there are no special considerations.

Referring to the schematic at http://www.thesunrain.com/Amazon/2%20re ... module.pdf the RPI GPIO controlling pin would be connected to VCC, the RPI ground pin connected to INn and 5 volts is connected to JD-VCC. and of course ground is ground.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

User avatar
mahjongg
Forum Moderator
Forum Moderator
Posts: 13085
Joined: Sun Mar 11, 2012 12:19 am
Location: South Holland, The Netherlands

Re: Sainsmart relay

Tue May 28, 2013 5:48 pm

Richard-TX wrote:Referring to the schematic at http://www.thesunrain.com/Amazon/2%20re ... module.pdf
There are a couple of errors in that schematic.
One is that the LED's are placed in series so you need more than 3.3V to overcome their forward voltages. Here this is solved (in a way) by connecting them to 5V, instead of 3.3V. But that does mean that when the LED's are turned off the GPIO pin would be pulled up to nearly 5V (if no current is running through the LED's) if it were not for the fact that there are protection diodes in the GPIO that lead the current into the 3V3 supply. What I'm saying is that this isn't a good way to treat the GPIO, you shouldn't do it like that, although it probably will work. A much better solution is to only connect one LED, the LED in the opto-isolator, and not put a second (signalling) LED in series, then you can use 3V3 to power it, instead of 5V. The signalling LED with its own series resistor can be put across the coil windings. Which brings me to the second error, the coil winding is shorted in this drawing!

pjc123
Posts: 922
Joined: Thu Mar 29, 2012 3:37 pm
Contact: Website

Re: Sainsmart relay

Wed May 29, 2013 10:57 am

Richard-TX wrote:I fail to see why any special interfacing is required.
It was the topic that just wouldn't die.
My Raspberry Pi Project Page:

https://www.flaminghellmet.com/launch/

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Sainsmart relay

Tue Jun 04, 2013 6:01 pm

I just checked the relay modules that I received yesterday from Sainsmart. The boards I received matches the schematic save for the short across the coil. :D Having said all that, the 3 volt supply lights the leds and triggers the relays reliably so no issues there. The worst case scenario would be to replace or parallel resistor R1 with a another. Another option is to jumper across the indicator LED. Sainsmart mentions this in their documentation.

Another way to look at it is that one does not have to drive a LED (or optoisolator) to full brightness. It just has to be bright enough to work. In this case all that is needed is .6 volts at the base of transistor to turn it on fully.

Here is a corrected schematic.
Attachments
2-relay.JPG
2-relay.JPG (11.69 KiB) Viewed 7158 times
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Sainsmart relay

Tue Jun 04, 2013 6:46 pm

The 8 relay board does need a little help if it is to be triggered from 3 volts. What I opted to do was to eliminate R7. There just isn't enough current there to reliably fully turn on the transistor when supplied with 3 volts. Sometimes that isn't enough. so changing the 1k to a lower value may be needed. Simply adding another resistor across R1 is likely all that is needed to rebias the transistor.
Attachments
8-relay.JPG
8-relay.JPG (10.96 KiB) Viewed 7153 times
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Sainsmart relay

Mon Jun 10, 2013 2:18 pm

The 8 relay board that I am referring to that needs some modification done is the signal relay board with the yellow cased relays. The blue cased relay boards work just fine without any additional glue and is safe for use with the Rpi (assuming it is wired correctly). I have been switching a two relay board every 3 seconds all weekend.

Image
This board needs to have the driver transistor rebiased to trigger from 3 volts.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

vinsanity
Posts: 6
Joined: Mon Jul 29, 2013 5:57 pm

Re: Sainsmart relay

Thu Aug 08, 2013 7:23 am

Do we think the Pi will handle 2 of these cards without requiring a separate 5V power supply? I need 16 relays for the project that I'm trying to do.

The only USB device I have is a EdiMax wifi card. On occasion I may connect a USB flash dongle, but no HDs or such.

Thanks to all. This thread has been extremely enlightening.

btidey
Posts: 1636
Joined: Sun Feb 17, 2013 6:51 pm

Re: Sainsmart relay

Thu Aug 08, 2013 1:12 pm

Although the logic input only needs a small current to activate it, the relay coils themselves need about 60mA each when turned on. So one 8 channel board could be taking 0.5A. That is really too much power to be taking from the GPIO if the Pi is being powered just via the microUSB as all this current flows through the polyfuse and could overload and trip it particularly when all 8 relays are switched on.

You could still use 1 supply assuming it has adequate overall capacity if you make sure the current to the relay board(s) is not flowing through the polyfuse. This can be achieved either by splitting the output from the supply or by powering the Pi via the USB or GPIO rather than the micro USB. Splitting is better in the sense it leaves the Pi protected by the polyfuse.

vinsanity
Posts: 6
Joined: Mon Jul 29, 2013 5:57 pm

Re: Sainsmart relay

Thu Aug 08, 2013 10:32 pm

I'm still trying to wrap my head around when current is being pulled given the polarity reversal of the relays. Does it make a difference that I never plan on having more than 1 of the 16 relays on at a time?

btidey
Posts: 1636
Joined: Sun Feb 17, 2013 6:51 pm

Re: Sainsmart relay

Fri Aug 09, 2013 10:30 am

When a logic input is high then no current flows through opto and coil is not driven so almost 0 current. When a logic is low then opto feeds about 2mA back through the logic and the coil is driven pulling another ~60mA from the supply.

So the current drawn is approximately n x 62mA where n is the number of relays on. If you can guarantee that only a few relays are on then that obviously limits the total current drawn. However, if each relay is driven by a separate GPIO then this guarantee is 'software' so may not be worth a lot especially during testing!

If you truly wanted only 1 relay on at a time then you could consider using 4 GPIO outputs plus 1 enable into a 1 of 16 decoder chip to drive the relays. That means only 5 pins used and no chance of activating more than the selected one.

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Sainsmart relay

Fri Aug 09, 2013 1:40 pm

I recently came across a blue Sainsmart relay board that started to fail after being in place for a week. The LEDs on the board were not allowing enough current to flow through the opto-isolator. I wound up jumpering them out. My other (made later?) boards are fine. I think that this early board was made with sub-standand LEDS and transistors.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

updowndown
Posts: 18
Joined: Fri Jul 19, 2013 8:49 am

Re: Sainsmart relay

Tue Aug 20, 2013 1:13 pm

I've used the 2 module relay board of the same design and I made a tutorial on using it as well as relay modules on their own (be warned, as it's a little lengthy at 10 minutes):

http://youtu.be/b6ZagKRnRdM

If you're just interested in using the board, jump to around the 6 minute mark.

Hope that helps!
Raspberry Pi Tutorials at: www.youtube.com/user/updowndown

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Sainsmart relay

Wed Aug 21, 2013 2:29 pm

Update:

After 1 month of continuous use, the newer board started to fail as well. Measurements indicate that the indicator leds have changed over time not allowing sufficient current to flow through them. So now all of the indicator leds are now jumpered out. I am driving the relay boards with a MCP23017. To see what the issue is I connected a pot to the trigger line and measured the voltage needed to transition the relays from ON to OFF. It was amazing where that trigger point was. It was down near .25 volts. I expected levels similar to TTL but that is not the case.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

btidey
Posts: 1636
Joined: Sun Feb 17, 2013 6:51 pm

Re: Sainsmart relay

Wed Aug 21, 2013 3:12 pm

What supply voltage were you using? It is not so much the trigger voltage that counts but more about the current through the OPTO input. That needs to be > 0.5mA in my experience. With a 5V supply that is easy to achieve, but using 3.3V with drop over the LED, and OPTO that doesn't leave much margin across the resistor. Losing the LED should help quite a bit.

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Sainsmart relay

Mon Aug 26, 2013 3:04 pm

Supply voltage for the logic is 3.3 volts. I tried 5 volts but the trigger point is about the same.

What Sainmart should have done was make the circuit so that it could be sink or source activated.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

KenT
Posts: 758
Joined: Tue Jan 24, 2012 9:30 am
Location: Hertfordshire, UK
Contact: Website

Re: Sainsmart relay

Mon Aug 26, 2013 5:01 pm

I have been looking around for relay boards, most of them have the opto isolator connected to Vcc and therefore need the Pi to pull the input to 0 vollts. (think that is sinking, its been a long time since Uni......)

I was wondering why that is, all I could think of is that it would enable the use of open collector outputs on computers, but surely open collector went out with the ark.
Pi Presents - A toolkit to produce multi-media interactive display applications for museums, visitor centres, and more
Download from http://pipresents.wordpress.com

derickrd
Posts: 4
Joined: Wed Jul 04, 2012 12:45 am

Re: Sainsmart relay

Mon Aug 26, 2013 5:40 pm

Hi all,

Have you ever tried the Sainsmart 2 channel SSR 3V - 32V with a raspberry? How would I connect it to the RasPi? I am afraid to buy a lot of these and found out that I need something else to make it work with the RasPi.

Link to the relay card:
http://www.sainsmart.com/arduino-compat ... no-r3.html

I saw a lot of posts of guys using the 5V ones, but none on these. Is it safe to use these?

Thanks a lot.

derickrd

kweenie
Posts: 29
Joined: Mon Dec 23, 2013 4:00 pm

Re: Sainsmart relay

Sat Jan 18, 2014 3:58 pm

i made a board according to the drawing but it does not work at all , connecting a relaycard directly works ...............
parts i used were the same as the list ( 12k/10k and 3904)
point a ( raspberry gpio ) gets connected to two ends of resistors and the 12k connects to transistor center
the 10k directly to ground and the transistor leg that goes to ground ( seen from the top and flat side up the right hand leg)
the left leg of the transistor connects to the relay input .

i hope someone is going to produce this stuff , it makes me crazy ! ( i have shaky hands :) )

grahamed
Posts: 277
Joined: Mon Jan 30, 2012 7:01 pm

Re: Sainsmart relay

Sat Jan 18, 2014 4:31 pm

Hi

Derrickrd - the spec on the link says the maximum input current (I assume that means LED current) is 18mA which is pretty high. Mind you some of the other specs look pretty weird.


kweenie - I assume that you are looking at the single npn transistor, grounded emitter, resistor on base, load in collector with top end of load going to 5V inverting configuration, but I can't understand description. Normally you need only 1 resistor. Link to diagram? Try using a LED in place of opto so you can see it working?

Have a look at [url][http://www.raspberrypi.org/forum/viewto ... 481725/url] for non-inverting configurations (one is a bit controversial I know).

I apologise if I have misunderstood your problem.

kweenie
Posts: 29
Joined: Mon Dec 23, 2013 4:00 pm

Re: Sainsmart relay

Sat Jan 18, 2014 8:55 pm

the diagram is on page 1 of this thread a 2,2 and 10 resistor is used there .
at the bottom of page 1 is a link to a working interface ( with a list of stuff to use )
i fail to understand what i did wrong or maybe it is a fake thing?
the transistor switches when i apply battery voltage to it.
electronics is just not for me i guess i am too old and too stupid .
thanks for the reply i never expected an answer .
i tried to describe the connections on the transistor as i used it .
i will try to draw i diagram and then post it but in practice its like the diagram

User avatar
Richard-TX
Posts: 1549
Joined: Tue May 28, 2013 3:24 pm
Location: North Texas

Re: Sainsmart relay

Sat Jan 18, 2014 10:20 pm

kweenie wrote: electronics is just not for me i guess i am too old and too stupid .
No way. You are no different than a young person. Keep plugging away. You will be fine.

The last person I gave encouragement to went on to get his Phd in Electrical Engineering and has a few patents under his belt.

Richard - no degree - just learned it.
Richard
Doing Unix since 1985.
The 9-25-2013 image of Wheezy can be found at:
http://downloads.raspberrypi.org/raspbian/images/raspbian-2013-09-27/2013-09-25-wheezy-raspbian.zip

kweenie
Posts: 29
Joined: Mon Dec 23, 2013 4:00 pm

Re: Sainsmart relay

Tue Jan 21, 2014 6:41 pm

hopefully some young person will start to produce these boards , someone that understands all this printing and etching stuff.
it would be even better if this board would have the other stuff as well and a base for omrom relays ( easy replacement)
i know these are big but they last ...................
i just do not have the knowledge to make this stuff but without it the raspberry is worth nothing for home automation .
my relay from china arrived and i threw it away less than half an hour later , its really crappy stuff :)
for me its strange that with so many raspberries sold noone is making that .........

kweenie
Posts: 29
Joined: Mon Dec 23, 2013 4:00 pm

Re: Sainsmart relay

Sun Jan 26, 2014 10:10 am

i got another relay ( from china) and it works without any interface , the power was taken from the gpio as well no need for interface boards or separate power cords .
guess i have to find some little program that switches relays every few seconds for a week so it imitates years of operation, before it gets used in "real life"

The Big L
Posts: 4
Joined: Wed Mar 05, 2014 1:39 am

Re: Sainsmart relay

Wed Mar 05, 2014 1:56 am

I was trying to get my 2-channel, 5v SainSmart relay board (http://www.sainsmart.com/arduino-pro-mini.html) working with my Pi. I'm a bit of a novice at some of this, so I blithely followed the first online tutorial I found on the subject. The advice was to make the following connections on the main 4-pin header:

Pi -> SainSmart
5v -> VCC
GPIO -> IN1
GND -> GND

...all the while leaving the JD-VCC/VCC jumper in place. Well, it worked, sort of. Every once in a while though the Pi would become unstable, reboot, or otherwise behave erratically. I began to suspect that something unsavory was going on. I came upon this thread, and I even understood parts of it. :D After watching updowndown's youtube video, things started making a bit more sense. So I promptly removed the JD-VCC/VCC jumper, and changed the wiring thusly:

Pi->SainSmart
5v->JD-VCC
GND->GND

(and on the 4-pin header):
3.3v->VCC
GPIO->IN1

And...no luck. The LED indicator on the relay lit up properly, but the relay would not energize. I tried both relay modules on the board, and neither worked. I'm left wondering which of the following options would be the best:

1. Power the JD-VCC part with a separate 5v source (not from the Pi). I'm not sure if this will help, since I'm not sure whether the problem is that the Pi can't supply the necessary 5v power to JD-VCC, or if the 3.3v is inadequate on the VCC.

2. Jump the LED's to see if that gives enough breathing room.

3. Buy another $5 SSR that is known to work just fine with the Pi (I've had good luck with the cheapo Foteks).

Any advice?

Return to “Interfacing (DSI, CSI, I2C, etc.)”