Control Relay With Arduino
Control Relay With Arduino
Control Relay With Arduino
A relay is called an electromagnetic switch.Which can be operated by a low electric current that can
convert into much larger electric current. As an input signals the voltage and current applied to the coil for
opens or closed the contacts of electromagnetic switch .
The definition of Relay is: Using electromagnetic attraction activate the contact, which can be produced by
giving an electric current that exceed the specified value flows to the electromagnet.
When the current passes through the coil it generates electric field . Which makes close and opens (makes or
break) the contact with fixed contact.
Here we are controlling relay with arduino with simple program and switching the arduino code for blinking
the led. For controlling DC motor with Relay Click control-dc-motor-using-relay-arduino.
When the relay is not energized . Check resistance across NC and COM terminal with multimeter.The
resistance across them is '0 ' (zero). If the resistance across them is zero then the NC terminal is fine.
When the relay is not energized . Check resistance across NO and COM terminal with multimeter.The
resistance across them is several M ( mega ohms ). If the resistance across them is in M then the NO
terminal is fine.
Relay is energize
Energize the relay by using any external appropriate voltage source for rating of relay coil. Make sure your
voltage source is connected with right polarity. When it is connected and relay is energized listen the voice
of click.
when relay is energized. When connect the probes of multimeter with NC and COM. You find opposite
condition of de-energized. Here you got infinite resistance or resistance in M. In energized case if
resistance is in M then your NC (normally closed ) terminal of relay is working fine.
when relay is energized. When connect the probes of multimeter with NO and COM. You find opposite
condition of de-energized. Here you got zero resistance across this terminal. In energized case if resistance
you got is zero then your NO (normally open ) terminal of relay is working fine.
Remember
One of the most important things we should also find is our relay coil resistance. This is for measuring
current.
First of all we should find the coil in relay. Mostly it is at pin 2 and 5 as labelled . If not then you have
to check resistance at every pin.
Between these two pins you got resistance between 100 to 10 K. Here i found 4200 ohms resistance.
V = I.R
so I = V/R = 12/4200
I = 28 mA.
Arduino can drain 20 mA current and need 28mA to switch relay. So we use npn P2N2222A transistor.
If you supply 5v directly to the coil of 12volt relay using IO pin of arduino maybe the current is not
enough to switch the latch since 5v / 400 ohm = 0.0125 A or ~13mA compare to typical 30mA of 12v relay.
So you have to use a transistor as a switch so that you can use 5v source of arduino to switch on 12v source
to power the relay. Any 12v source would be fine if it is able to provide current larger than 30mA.
If you use 5v relay and use arduino IO pin to drive the relay directly, the coil resistor is around 70 ohm
which needs ~71mA to work. This time 71mA excess the absolute 40mA current limit of arduino IO pin. It
will likely damage your arduino. So again, you have to use transistor as a switch to amplify the current apply
to the relay coil.
Ib = Ic / hfe
Ib = 0.028/75 = 0.00037 A
this is not in standard resistor so you use 12k or 12.5k resistor with arduino pin and transistor.
int pin = 6;
void setup() {
pinMode(pin,OUTPUT);
void loop() {
digitalWrite(pin,HIGH);
delay(1000);
digitalWrite(pin,LOW);
delay(1000);
}
You have successfully completed one more Arduino "How to" tutorial and you learned how to use Relay
with arduino.