Saturday 16 May 2015

Arduino Lesson 13 : Controlling External Relays

Intro to topic :

Now its time to talk about little bit of external hardware we can control or attach with arduino boards to control other hardware or boards. One of the most used automatically operation switches is relays which is used in electronics and many smart applications to control so here is tutorial you can follow and know how to control relays through Arduino

Hardware required :

  1. Arduino UNO board.
  2. Relay (with coil rating with 6VDC Or 5VDC)
  3. Connecting wires/Jumper wires.
  4. PC to configure arduino board (with arduino software installed).
  5. Bread board.



Explanation to Circuit :

As we have to control external circuit or element through relay first of all we have to consider the relay structure its working principle and how to operate it for automation of things.




Here i have posted two pictures of most commonly used DC relays after applying 5VDC to its coil terminals the relay coil will get energized and the movable pin will get connected with NO point and after releasing the voltage the movable pin will gets to its start position with NC pin so this is the key principle to remember while working with relays of any kind.

The circuit we have shown is used to operate the relay with Arduino board directly by applying 5Vdc and Gound to jack1 and middle pin will goto the transistor base pin which will amplify the arduino Current of 50ma max to 200ma round about and which will be enough to energize the relay coil. The led1 will only indicate the ON and OFF the state of relay and can be omitted.


Steps to follow :


  1. Connect the Circuit according to schematic image on bread board.
  2. Plud the Middle pin of jack1 to arduino pin 5.
  3. Connect the 5v and groung connections correctly.
  4. Use Qn3904 or D400 transister (Recommended and tested).
  5. Check polaroty of Transister before applying to any Circuit.
  6. The resisters and LED part of circuit is not much essential so you can ignore it the circuit will still work better.
  7. open up the Arduino IDE in PC and upload the following code.



Code to be uploaded :

int relay =5;

void setup() {
  pinMode(relay, OUTPUT);     
}

void loop() {
                                             digitalWrite(led, HIGH);   // turn the relay on (HIGH is the voltage level)
  delay(2000);               // wait for a  2 second
  digitalWrite(led, LOW);    // turn the relay off by making the voltage LOW
  delay(2000);               // wait for a 2 second
}


Once you uploaded the Code you will clearly can listen the voice of TIK TIK from relay after every two seconds and more you can test the continuity of relay ports with DMM(digital multimeter) or apply any load to get on and off for every two seconds.


If you have any more things to ask let it be in comments i will try to more explain it.

No comments:

Post a Comment