Go Down

Topic: How do I connect a relay? (Read 96875 times) previous topic - next topic


Dec 03, 2007, 05:10 pm Last Edit: Dec 03, 2007, 05:10 pm by Norwegian_User Reason: 1
I am trying to learn how to use the Arduino and are trying to use my christmas lights blinking using the source of the Blink example.

The christmas lights runs on 12V så I thought i would put a Solid State Relay betwen the power and Arduino.

How should i connect my relay to the Arduino board? It needs minimum 3V to work.


Try to read this :



Hi, I don't think that relay will work for switching low voltage dc., you'll need a different style ssr for that.


+1 digger
You'll need a SSR for the specific DC voltage you're trying to control.  If all you're controlling is +12V you can just use a transistor and turn it on and off with the arduino, provide an external +12V to the transistor tie the grounds together and you're done. If the transistor mentioned in the following article is not enough then a mechanical relay is your next cheaper step.

High current loads


Dec 04, 2007, 11:54 am Last Edit: Dec 04, 2007, 12:05 pm by myozone Reason: 1
That circuit should work -  BUT WATCH OUT FOR THE MAINS (240 volts) on your bread board !! DANGEROUS !! IF you are controlling a 240 voltsAC to 12 V transformer via your relay for your lights! . If you are controlling 12V DC you will need another type of relay as mentioned above.


Woah I didn't think of that having 240vac in there.

Don't breadboard the AC with the DC use another board, preferably a insulated terminal board.  Or keep the arduino connections off the breadboard.

The SSR needs 3 -32 vdc and not much current 3.4ma at 5vdc so the arduino will do fine.  DC ground goes to terminal 4 and the arduino digital output goes to terminal 3, you can pick any digital output. If you use the blinking led example you can watch the light blink when you power on the arduino.



Dec 09, 2007, 03:03 pm Last Edit: Dec 09, 2007, 03:06 pm by mrmeval Reason: 1
Believe it or not I have exactly that relay. You made me remember I had one.

First get that LED blinking. Make it blink!

Then remove the resistor and LED and replace it with the 3-32v control input of the SSR, be sure polarity is correct.  Negative to ground and positive to the digital output.

I have an old clamp on lamp that IMHO sucks, the clamp is useless. So I cut the hot lead and stripped the two ends.  Then I hooked one lead of the hot lead to the AC terminal on the SSR and the other lead went to the other terminal. Polarity does not matter.

I plugged the lamp into a socket and it merrily blinked a CCFL bulb.


It's bad to blink Mr. CCFL as he does not like this and I drove him to suicide!
AWWWWW Poor Mr CCFL died in the name of science!

But incandescents work just fine. ;)

Earlier I managed to extend the Arduino's IO ports so that I have 16 extra minus the four control ports. In general I have 12 (though with some program trickery I can recover two of those four for other uses). With 16 SSRs I can have some fun with any AC powered device. ;)


Apr 15, 2008, 12:19 pm Last Edit: Apr 15, 2008, 12:21 pm by thekidd Reason: 1
I just got excited reading this post. I have a similar project I am currently working on with the Arduino that requires a relay. I need a way to hard boot a PC. Would the above part work fine?

I found this on Mouser: http://www.components.omron.com/components/web/PDFLIB.nsf/0/08509325F0FDF7BE85257201007DD5BB/$file/G3TC_0607.pdf

Would any additional components need to be used to shut the power off for 10-15 seconds and then bring it back on?

I'm thinking of a relay as follows:
1) Relay is normally on when Arduino does not apply 5V to the output pin.
2) Arduino code sets the output pin high for 10-15 seconds to allow the system to completely shutdown.
3) When finished the code sets the output pin to its normal low value to turn the PC back on.
3) It accepts power on/off commands via Serial interface (I'll be using C# on the PC side for control).

Makes me wonder if I should just pull the PC case apart and just hook up the reset pins to Arduino to allow Arduino to just reset the damn thing.


I'm in the same game as TheKidd.

I use Director which can chat to Arduino via the serial xtra.  My application needs to keep telling the Arduino that everything's ok so Arduino keeps the power coming.  In the event of a software failure, Arduino will 'pull the plug' for a maybe 30secs then power everything back up.  The Mac will think there's been a power cut and spring back into action.  A minute or so later my application will start reassuring Arduino that all's well with the world and they'll continue their day happily together.  :D

All I need is a simple SSR circuit that will look after the power for the Mac.

In my reading so far there seems to be some potential issue about switching transformers... which I assume will include the Mac.

any experts in this field?




Beardy, thanks for bringing up something I didn't even think about. Granted I was gonna go through the Arduino on the battery backup but forgot to think about what would happen if the UPS failed. Thanks for bringing that to my attention.

I guess keeping the system on normally whether through transformer or motherboard reset/power/sleep switch was always the idea. My main objective is to save the system from having to come home to turn it back on after a power outage.

I just ordered a few different transformers so I'll report how that goes either way.


Apr 26, 2008, 05:37 am Last Edit: Apr 26, 2008, 05:38 am by Daniel2 Reason: 1

for the folks talking about running a DC load on an solid state relay- you have to check the specs to see if it will work.

The big SSR's are based on SCR's and triacs, which will just latch "ON" when they get DC.

There's a series of small industrial solid state relays  that are easy to find. The generic name/number for 5V to DC output is "ODC5", meaning 5V in will control a DC load. Similarly, "OAC5" controls an AC load. these relays are ideal for small things like a 100W light bulb, or a solenoid running on 24V. They also make input modules called.. wait for it.... "IDC5" ( 5V DC input).

The advantage of all these modules is you get optical isolation between the Arduino and the load. This is an industry standard, and lots and lots of companies make them. You can get them new for about $10 a piece, or on ebay cheaper. Here's a few links:

OPTO brand ODC5

Same module from Allied Electronics

Grayhill brand ODC5 as sold by Digikey: about $9. This one can switch up to 60V DC at 3A from a single 5V input. No PWM, mind you!.

And here's a whole page describing some of the OPTO brand ODC/IDC modules.

These modules are a very good design solution where you have a few bucks to spend, need a lot of outputs, and want something reliable fast.



Is there any benefit to using these solid state relays over just wiring a diode into the circuit of a mechanical one?
They seem so much more expensive!

I am also wondering, if anyone would like to weigh in:
I'm about to order parts for a project in which I need to switch 120VAC to a 2A device, and 24VDC to a solenoid, in addition to a lot of relays to other low amperage devices. Is there any benefit to using small .5A relays for the low amperage devices and 12A relays for the 120VAC (all 5VDC coils), other than price, or should I just order all 12A relays if they cost the same?



I'm NO expert - but you know that already, so I can't help with your questions.

Just to say that I understand the mechanical relays can bounce when the contacts close which can spike sensitive equipment and if you have a high current draw on them at switch on, the contacts take quite lot of electrical stress (arcing?) so tend to burn out prematurely.  

That's all I've got.  More expert information would be useful here too.



Can I Just directly connect the relay?


Can I Just directly connect the relay?

Directly connect it to what?  The Arduino?  The mains?  What sort of relay?

You can sometimes connect a relay coil directly to an Arduino output pin, if the relay coil draws less than 40mA.  You will still need a back-EMF protection diode.

Go Up