Introduction: Relay Module for Arduino

I hope you all are familiar with relays (if not check this), in simple words these are kind of switches in which if we pass certain volts (according to relay's input voltage ratings) through coil terminals then NO and COM pins will get connected i.e. work as a closed switch through which we can connect higher volts current. 5 Volts relay need a 5V current through coil terminals to trigger, 12V needs 12V to trigger and same as for all others. More

How it can be used?..... Most basic example is that we can use a relay to control our house hold appliances(110-240V) through a microcontroller (like Arduino, which cannot handle such high voltage currents). As in case of Arduino which supplies a current of 5 volts through digital pins, a 5 volts relay is useful. You can put any one coil terminal to a digital pin of Arduino and other terminal to GND for the relay to be triggered... But no, its not a correct way. There may occur a voltage spike causing arcing on switch contacts when the coil is switched off, which may possibly damage the microcontroller or any other switching appliance. To solve this problem simply connect a diode, known as flywheel diode, across coil terminals which provide a path for the current.

If its so simple then why I had used transistors and resistors along with relays and flyback diodes in my project?... So the answer is that if you use single relay to be triggered from Arduino, it will work fine, but when you will try to control more than one relay it shall not work because due to low current in digital pins of microcontroller, when you trigger one relay some voltage will drop due to which the another relay shall not get the required voltage and it will not get trigger. To drive multiple relays from Arduino, 'transistor as a switch' is used. Follow the steps for that.

Step 1: Transistor As a Switch

Here I had used NPN transistor emitter follower circuit in order to trigger relays (kindly check this). Actually by using this circuit, Arduino is not required to provide voltage to relay coils (they get current from a different power supply), digital pins only give small signal volts to transistor's base pin which completes the circuit by which relay can be controlled.

Step 2: Materials Required

Components:-

  1. Relays : as per requirement
  2. NPN transistor (BC547 in my case) : same as number of relays
  3. 1k ohm resistor : same as number of relays
  4. 1N4007 diode : same as number of relays
  5. Power supply : 12V for 12V relays, 5V for 5V relays or as per ratings
  6. screw terminals (optional)
  7. Perfboard
  8. LEDs(optional)
Tools required:-
  1. Soldering Accessories
  2. Hot glue gun
  3. Insulation Tape
  4. Cutter and stripper
  5. Multimeter
  6. Screwdriver set
  7. Pliers
The power supply for relay board must not be of very low current ratings because if the current supplied is low then the relays might malfunction when triggered more than one. On low current, as the power is supplied to more n more relays, the voltage starts dropping and there comes a point when the voltage fall below the required voltage for relay to be triggered and will cause problem.

Step 3: Circuit Diagram

Follow the given circuit and I recommend to build it first on a breadboard. Check the circuit if working properly, if not, maybe your npn transistor doesn't support 'emitter follower circuit'. Try to set it up as a normal 'npn transistor as a switch circuit', it will work fine. Also make sure that flywheel diode is connected across relay coils in correct manner. Once it is working fine, solder it permanently on a perfboard or pcb. You can connect three screw terminal sockets for 'relay's NO', relay's COM' and transistor's base input via resistor' for ease. Also a Two screw terminal socket for 'supply'(for relay). I hadn't used three screw terminal sockets because I have to put this relay module into my project in which there is no need to unscrew those ever in future, so it will be a total waste of using these, I had soldered them via wire in my main driving circuit. Also you can add LEDs for indicating Relay's status.

That's all. Soon I will update this instructable by using transistor array ICs (like ULN2003) at place of npn transistors.

Kindly use 1K ohm resistor at place of 220 ohm resistor shown in schematic above and supply according to relay requirements at place of '9V' in schematic.