Electronic – arduino – Driving a Sainsmart Relay using Raspberry Pi

arduinogpioraspberry pisolid-state-relay

I am actually a software engineer and not really familiar with wiring. I've been playing around with a Raspberry Pi Model B, and am looking to hook up a 2 PRONG Extension Cable to a Sainsmart 8 Channel Solid State Relay.

I am driving the GPIO pins from RPIO (Python). What I want to do is hook up a basic night light as the first channel output from the SSR and control it from GPIO pin 17. The problem is, I can't even get this to work. I am able to get the LED to light up pretty easily, but there seems to be no output. I've tried driving the relay on a HIGH and LOW signal, but no dice.

My wiring diagram is shown below… Apologies for it being very rudimentary… Any ideas what may be wrong? Is my relay bad?

Also note, I've several mechanical relays too and they all seem to do the same thing.

Also, I've been told that the GROUND side of a 2 PRONG cable is the side where the insulation has labeling. I'm assuming the GROUND part of the 2 prong cable is plugged into the top part of the output channel of the relay and VCC on the bottom. Can someone confirm with me?

I've also tried this with an Arduino, and it doesn't seem to work either. Sorry for the convoluted post, but this has been driving me nuts for the past couple of weeks!

EDIT: The LED on the board does turn on, but I haven't had luck powering something separate off from the port. And yes, I have tried powering it from a separate 5V supply.

enter image description here

Best Answer

This is very old now but I keep getting the link in search results so I thought I would comment in case it helps anyone else reading this as I am.

In the original diagram it looks like the questioner is thinking that the 2 pins of the relay that his wire is attached to provide current and ground to run a light. They Don't ... Its just a switch so you hook the hot wire of a light to one side and hook that same wire to the other side of the relay. When the relay is powered it switches the switch on and the current can flow thru the relay just as if it were a light switch. Terrible drawing coming :)

Ground-plug-on-cord------is optional ------------Ground of light/ appliance

Common- plug-on cord ----------------------------Common (usually white) light

Hot wire -----one side of relay---- other end of hot wire to other side of relay

So in my case I did this: Took my light and carefully cut just the black wire and left the green and white wires connected as they were. Then I hooked one end of the black wire to one of the terminals on the relay and the other end of the black wire to the other terminal of the same relay. Then I plugged the power cord into an outlet. When the relay is closed power flows to the light and it lights (if the light switch is on obviously) when the relay is open no current can flow and ther is no power to the light.

Its not the relay that is supplying power to the light. That comes from the wall outlet. The relay is just enabling or disabling power from flowing thru the black wire by connecting or disrupting the path for electricity to flow.

YMMV Be careful when working with AC power.

But switching AC power with a SainSmart relay and a raspberry pi is quite straightforward once you understand a little about it.