0
\$\begingroup\$

I'm working on a project that involves an Arduino Uno and some external electronics. I have a 12 V power supply that will connect to an outlet, and I want to be able to control this power using a relay connected to the Arduino (i.e. the Arduino will control the voltage that turns the switch on or off).

Though I understand it theoretically, I have no idea what I'm actually looking for. I was hoping someone here could point me in the right direction. All my searching has brought me to larger components. I was hoping I could find something that would fit on a typical breadboard. Do relays like this exist? Or is there another, easier method of doing what I'm trying to do?

EDIT: I went to RadioShack and tried to pick out things that fit the descriptions you guys described. Here's what I got:

Relay: http://www.radioshack.com/product/index.jsp?productId=2062480

Diode: http://www.radioshack.com/product/index.jsp?productId=2036270

Transistor: http://www.radioshack.com/product/index.jsp?productId=2062610

I also picked up some 1.5k Ohm and 1k Ohm resistors.

Will these work with the circuit diagram below?

\$\endgroup\$
  • 1
    \$\begingroup\$ $1.19 for an 1N4004??? I hope you got good service. The relay is rated for 1A, is this sufficient for you? The coil current and/or resistance is not specified, I guess it will be 50 .. 100 mA. Your Arduino 5V supply must deliver this 9extra) current. With a 1.5k resistor the base current will be ~ 2mA, so the minumum Beta of the transistor is 50. I don't think you will find any transistor that does not satisfy this requirement. \$\endgroup\$ – Wouter van Ooijen Jun 6 '12 at 6:35
  • \$\begingroup\$ I'm trying to power this: amazon.com/Trico-11-100-Windshield-Washer-Pump/dp/B000CB69ZW/…. I couldn't find anything about the current necessary to power it though. Any idea if 1A will do? \$\endgroup\$ – Mason Jun 6 '12 at 6:45
  • \$\begingroup\$ @Wouter - Don't you remember Tandy we had in The Netherlands and Belgium until 20 years ago? The components were individually packaged in a package which cost 5 times the component. Radio Shack is next to useless, but seems to be everywhere, that's why people go there. I looked up a few transistors, some didn't even mention HFE, but the "tech specs" always mention "Supported languages: English". Bah. \$\endgroup\$ – stevenvh Jun 6 '12 at 6:45
  • \$\begingroup\$ @stevenh: I lived near the Hague and Delft, which both had a rich set of component stores, both new and surplus. Even Amersfoort, where I live now, has a sort-of component store (besides myself:) I am probably spoiled. \$\endgroup\$ – Wouter van Ooijen Jun 6 '12 at 7:36
  • 1
    \$\begingroup\$ @mason: A quick google hits alibaba.com/showroom/windshield-washer-pump-12v.html , which shows some pumps using 3.5A, so I would not trust 1A being enough. Maybe the label on the pump has some info, or you can measure it? \$\endgroup\$ – Wouter van Ooijen Jun 6 '12 at 7:37
3
\$\begingroup\$

What are those "larger components"? The only larger thing is the relay, and most relays will fit on a breadboard.

enter image description here

This is how you control the relay (the coil is shown next to the diode), it assumes you can connect the 12V's ground to the Arduino's. Resistor, transistor and diode are normal, small components. This relay is just a few cm long, wide and high. It can switch 10A and 230V. If you tell us more about what you want to switch I can give you more directed advice.

edit re your shopping
The relay requires 90mA from your 5V power supply. That will add a couple of hundreds of mW in the Arduino's voltage regulator. At 12V in that would be 630mW, which is a pity. If you have 12V in it would have been better to use that for a 12V relay.

The TIP31 transistor is overkill. It's a power transistor, and they don't have very high \$H_{FE}\$ (the current gain). Next time go for a TO-92 general purpose transistor like the BC547. The BC547B variant has an \$H_{FE}\$ of minimum 200. Go for a high \$H_{FE}\$. This one is still OK at an \$H_{FE}\$ of 100, but I would take a safety factor, and calculate with 40. Then the base current has to be 90mA/40 = 2.25mA. A 1k\$\Omega\$ base resistor will give you 4.3mA, so that's OK.

\$\endgroup\$
  • \$\begingroup\$ @clabacchio - Sure. Put isolation tape over the wires. Make sure you have a clean and clear wiring. I've done it with optocouplers, where I taped a small plastic box over them. \$\endgroup\$ – stevenvh Jun 5 '12 at 7:26
  • \$\begingroup\$ @clabacchio: I never would, but is that releveant? Mason wants to switch 12V. A more revlant point might be the current involved, using a breadborad with more than say 1A requires some extra measures (like soldering a copper wire instead of using the traces). \$\endgroup\$ – Wouter van Ooijen Jun 5 '12 at 13:42
  • \$\begingroup\$ @WoutervanOoijen: Sorry, missed the 12 V specification, and somehow implied outlet -> mains \$\endgroup\$ – clabacchio Jun 5 '12 at 13:46
  • \$\begingroup\$ @clabacchio, Wouter - I made the same assumption first. Wouter, are we both talking about this breadboard? There are no traces, just wires. I use 0.8mm wire for this, enough for several amperes. \$\endgroup\$ – stevenvh Jun 5 '12 at 13:50
  • \$\begingroup\$ @stevenvh: no, when I think about breadboard I mean the solderless one (that's why the comment). But probably because we have a different name for PCB-like ones \$\endgroup\$ – clabacchio Jun 5 '12 at 13:53
2
\$\begingroup\$

You want to switch a 12V power using an Arduino? I assume the 12V is isolated, so you want to use the 5V from the arduino to eanble the relay. Hence you need a relay with a 5V coil, that can switch at least 12V DC (nearly all can). You are still one spec short: the relay must be rated for the (12V) current that it must switch, which is up to you to decide.

Two small but important points remain: firstly a relay is a coil and switching a coil off will cause a voltage spike, which can be deadly for electronics. Hence you need a diode in parallel with the relay coil (but in the direction that does not cause it to short the coil in normal operation). This diode must be raed for the current consumed by the coil. 1N4148 (100mA max) and 1N4004 (1A max) are often used, but likely anything from your junkbox will do.

Last point: it is unlikely that your Arduino outputs can deliver the current required by the relay coil, so you will need a buffer/amplifier, again rated for the relay coil current. A simple BJT + base resistor, or a FET (no base resistor needed) or (part of) a chip like ULN2003 or ULN2803 wil do.

Stevenvh's diagram shows a BJT solution, for the case that your 5V and 12V share a common ground, in which case you can use a 12V relay.

\$\endgroup\$
  • \$\begingroup\$ Thanks for the detailed answer! I made an edit above. Do the parts I list meet all of these requirements? I read the specs on all of them, but I was still a little unclear on what some of them meant. Thanks again! \$\endgroup\$ – Mason Jun 6 '12 at 3:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.