A simple 5V relay

Hi, I have a 5V relay that looks just like this, http://img.dxcdn.com/productimages/sku_121354_1.jpg, and I have no idea what it does or how to use, and all the tutorials online weren’t very comprehensive.

If anyone could give me a run through or point me to a tutorial using just basic wiring, I’d be very thankful.


  • to ground
  • to 5volt S (signal) to an output pin.

Product page mentions TTL, so a HIGH on the Arduino pin could be relay off (LOW = on).

These modules use ~80mA, so one is ok, two maybe, three maybe not. Leo..

Please have a look at one my post, that explains how to connect a relay module.

I used a separate power source to power the relay as my relays are 12v.

a relay is a simple device. when it comes to the Ardino, it has three parts. coil power, control power and contacts power.

the main part is the coil. this is a coil. an coil is coiled wire. you may know of a coil because they are used in motors. solenoids. speakers, electro-magnets, and, yup, relays. Some motors can be generators and generators have coils too.

so, read on coil basics.

now, you have to run POWER to the coil. in most cases, you should never attempt to power a coil from an Arduino pin. speakers or buzzers, maybe, motors NEVER. relays, NEVER. what happens is that you have to drive the coil with power and once it reaches a point, there is an electromagnetic field that is created. you changed the input power into a different form of energy.

when you stop driving that coil and the magnetic field collapses, it turns into an uncontrolled generator and that magnetic field will collapose adn charge the coil, it can charge the coil and the coil can deliver voltages that are MUCH higer than you put into the coil. this is called EMF, or in the case of a motor where the magnetic field is collapsing, Back-EMF.

where does it go ? depends where you power the coil, if you tried to power it from a pin on the Arduino, it will go back into the arduino. this will often destroy the pin if not the whole Arduino.

we we do is to add a Diode in reverse. it is blocking when under normal use, but when the back-emf spike happens, the diode shorts the coil back to itself.


we recomend you use a transistor or a FET. there are a lot of resutls to such a google search. basicly, you have a resistor between your pin and the device. in the case of a transisor, you have to calculate power for the coil and then use a ratio of controlled power and input power. you have to input power to the transistor in the correct ratio to make it work. the beautiful thing is that you have to provide a tiny fraction of the power, milliAmps, to driver amps. the ardino is designed for this. as for an FET, you only need to provide voltage, so it is MUCH more efficent than a transistor on the Ardino side.

when you use an FET or transistor, (I' refer to them as FET/T ) you really only care what you have to do to make it work. the FET/T can control 100 VOLTS, but you only need to feed it a tiny signal. for the Transistor, you have to feed it a current proportional to the power, but for an FET (this is sloppy engineering) you have to feed it voltage equal to the supply voltage. since you cannot provide 100 volts from a common chip, they make special FET's that work on LOGIC LEVEL, or 5 volts. this is also TTL in case you see that term. you feed it 5 volts and internally, it can control the 100 volts. in many cases, the model will have an L in it. an IRF530 does not, an IRL530 does. and whomever is packaging the starter kits with a IRF530 should have someone step on their foot.

as you can see, there is a great deal of isolating the coil from the Ardino. So much so that pople want to use more isolation, such as an opto-isolator. isolation means that the two circuits NEVER - EVER, that is like they never share any wiring, incluidng grounds.

however, the cheap e-bay relays have a common ground with an opto. pretty silly design.

so, now you have a coil that creates a magnetic field from one power supply, NOT the same power supply as the Arduino and NOT teh same power supply as the rest of the sensitive electronics unless you have some filtering between them.

and you have a control signal that is not on the same power supply as the coil.

that leaves the contacs from the relay. the relay coil creates a magnetic field. that electromagnet pulls on a plate that is connected to contacts. those contact are isolated from the coil and do not share any common connection. they can be designed for massive amps or micro-amps. we do not care because they are isolated from the control side wiring.

[/ramble mode]

RELAYS : on the case of a relay is a bunch of numbers. this is because it can be used in many ways. it can be used to complete a circuit for an incandescent light. this is a RESISTIVE load, just like a resistor heater. it can be used to complete a circuit for a motor. this is an INDUCTIVE load, all the same problems with back-EMF apply, but in this case the relay contacts are designed for the spike. can they can be used for AC and for DC. since an inductive load is not the same as a resistive load, and since AC acts differently than DC, you have to select a relay that is rated for your load. often the coil voltage is part of the model number, or shown at the coil if there is a schematic printed on the relay.

The keyes relay module the OP linked a picture at, has all conditioning needed to be driven directly by an arduino output pin.

blimpyway: The keyes relay module the OP linked a picture at, has all conditioning needed to be driven directly by an arduino output pin.

yes, but that was not his request.

tell a man how to connect a relay and you get his project to work for him

teach him how a relay works and you educate him for a lifetime.

Thanks @dave-in-nj!