Home Security System using Arduino UNO in Proteus

Hello friends, I hope you all are doing well. In today's tutorial, we are going to design a Home Security System using Arduino UNO in Proteus software. It's the most commonly designed engineering project, especially in electrical, electronics and mechatronics engineering. Normally engineering students design it as a semester project during their engineering course.

So, today we will design a home security system from scratch in Proteus software. I have given the complete project below to download but I would suggest you to design it on your own so that you could understand it better. So, let's get started:

Where To Buy?
No.ComponentsDistributorLink To Buy
1Battery 12VAmazonBuy Now
2BuzzerAmazonBuy Now
3LM7805AmazonBuy Now
4OptoCouplerAmazonBuy Now
5RelayAmazonBuy Now
6Keypad 4x3AmazonBuy Now
7LCD 20x4AmazonBuy Now
8Flame SensorsAmazonBuy Now
9MQ-2AmazonBuy Now
10PIR SensorAmazonBuy Now
11Arduino UnoAmazonBuy Now

Home Security System: Project Description

  • Before going into the detail, let's first download the complete Proteus Simulation with Arduino Code, by clicking the below button:
Home Security System using Arduino UNO in Proteus

Let me first give you a detailed project description i.e. what we actually want to design? We want to build a Home Security Project, which should follow these security protocols:

  • Fire alarm: It should be able to detect the fire and sound an alarm to alert everyone at home.
  • Smoke alarm: It should detect the gas(smoke) and turn on the alarm(if detected).

The above-mentioned security protocols will be followed 24/7. Moreover, there will be two security modes in the project, named:

  • Secure Mode.
  • Normal Mode.

Let's have a look at both of these modes, one by one:

1. Secure Mode

  • This mode should be selected, when owners want to completely secure their home i.e. they are leaving home or while sleeping at night.
  • If the Secure Mode is selected, the project should follow the following security protocols:
    • Intruder Detection Alarm: It should detect the presence of any human being in the occupied premises.
    • Windows Security Alarm: If someone tries to break through the windows, the project should sound an alarm.
    • Door Security Alarm: If any intruder tries to break through the main door, it should again sound the alarm to alert everyone.

2. Normal Mode

  • This mode should be selected, when owners are at home and just want to take the basic security measures.
  • In this mode, only the Fire Alarm & Gas Alarm will work, while all other alarms will remain on standby.

Other Features

  • There should be an LCD, to display values of all parameters.
  • It should have a buzzer to generate an alarm, in case of emergency.
  • There should a Push Button to make switches between these security modes.

Here's the final simulation, which we are going to design in today's lecture:

So, these are our requirements, which we want to achieve in this Home Security Project. Now let's have a look at the components selected for this project:

Home Security System: Components Selected

Now let's have a look at the list of components, which I have selected for this Home Security Project. I will also briefly explain the purpose of using each component.

1. Arduino UNO

  • As clearly it's an Embedded Systems Project, so first of all we need to select a Microcontroller for our project.
  • As I have mentioned earlier, we will use the Arduino UNO Microcontroller board for designing this project.
  • Arduino UNO will act as the brain of the project and will control all sensors and modules.

2. Flame Sensor:

  • A flame sensor is used to detects the presence of fire.
  • The sensor basically consists of a photo-diode that detects the Infrared rays that emit from the fire. When it detects a fire, its output goes HIGH.

3. Gas Sensor (MQ-6)

  • MQ-6 Gas Sensor is used to detect the concentration of gases in the environment.
  • The sensor produces a potential difference proportional to the concentration of the particular gases.
  • The type of gas that it detects depends upon the material used in the sensor.
  • There are many gas sensors available in the market i.e. MQ-2, MQ-3, MQ-4 etc.
  • These sensors are available as ready-made modules for easy interfacing with the microcontroller.

4. PIR Sensor(HC-SR501)

  • HC-SR501 PIR sensor is used to detect any human being(intruder) in the Secure Mode.
  • It detects the IR radiations from the human movement & generates a pulse on its output.
  • The time period of the pulse could be varied by using the potentiometer on the sensor.

5. Vibration sensor(SW-420)

  • The SW-420 vibration sensor is used to detect any forced entry through windows.
  • In Secure Mode, if someone tries to open the window, the sensor will detect vibrations and will send a HIGH signal to the microcontroller.

6. Infrared Sensor

  • An infrared sensor will be placed at the door and someone tried to enter through that door, the sensor will detect it.
  • It consists of an IR transmitter and a photo-diode that are placed close to each other.
  • If any object movement occurs in front of the sensor, the IR rays hit the object and return back with a particular angle called incident angle.
  • This pulls the comparator output to ground or logic LOW.

7. LCD 20x4

  • LCD 20x4 will be used for displaying the values of all these sensors.
  • It will also display useful information i.e. which mode is selected.

8. Buzzer

  • A small 5V Buzzer is used to sound the alarm.

9. LM7805

  • LM7805 is a voltage regulator and is used to convert voltage from 12V to 5V.
  • Power sources(i.e. battery, adapter etc.) available are normally 12V, as it has become a standard.
  • Moreover, many components also operate at 12V like a buzzer or DC motor.
  • While microcontrollers and sensors work on 5V, so in Embedded projects, it's quite necessary to design a voltage regulator from 12V to 5V and in some cases 3.3V.
  • I normally prefer LM7805 for converting voltage from 12V to 5V.

10. Resistances(1kohm)

  • We need to use a few resistances of 1kohm.

11. Small LED

  • We will also use a small LED for power indication.

12. Capacitors(100uF)

  • We will also use few capacitors of 100uF, as it removes any noise/ripples.
So, these are the components, we are going to use for designing Home Security System. Now let's get started with designing the Proteus Simulation:

Proteus Simulation of Home Security System

As I have told you earlier, I am going to use Proteus software for designing this project. Proteus is an excellent simulation tool, where we will not only design the circuit of this project but will also test its output. I always design my programming algorithms on simulations as working on real hardware is too time-consuming. You should remove all your programming bugs in simulation and once confirmed then design your project in real hardware. So, let's start:

Install Proteus Libraries

Once you added all the libraries, now open your Proteus software.

Designing Circuit Diagram in Proteus

  • Now we need to design a circuit for our project, so select these components from Proteus Components Search Box.
  • First of all, let's design the voltage regulator circuit using LM7805, which will be simply converting the voltage from 12V to 5V.
  • As you can see in the above figure, I have used 12V Battery, while the output of LM7805 is showing 5V and I have also placed an LED for power indication.
LCD Interfacing with Arduino:
  • Next, we need to interface 20x4 LCD with Arduino UNO, so design the circuit as shown in the below figure:

Next, we need to interface five sensors with Arduino UNO, so let's add them to our Proteus simulation:

Sensors Interfacing with Arduino:
  • These are simple digital & analog sensors and are all powered up at 5V.
  • So, simply connect them as shown in the below figure:
  • The Flame Sensor is connected to pin A0 of Arduino UNO.
  • Gas Sensor is connected to pin A1 of Arduino UNO.
  • PIR Sensor is connected to pin A2 of Arduino UNO.
  • The Vibration Sensor is connected to pin A3 of Arduino UNO.
  • The Infrared Sensor is connected to pin A4 of Arduino UNO.

For simulation, ensure all hex files are uploaded to each sensor for proper working. You can upload the source code hex file to the Arduino, by pressing Ctrl+E or by right click --> Edit properties.

Buzzer & Push Button:
  • Finally, we need to add the Buzzer to sound the alarm in emergency cases, I have connected it to Pin A5 of Arduino UNO.
  • I have also connected a push-button for switching the modes, connected to Pin 7 of Arduino UNO, as shown in the below figure:
  • Here's the image of the complete Proteus Simulation for Home Security System:

Now let's design the Arduino programming code for Home Security Project:

Arduino Code for Home Security System

In the previous section, we have designed the Proteus simulation of the project, now let's design its Arduino Code to make it alive. Let's get started:

Initialization LCD Arduino Code

  • First of all, we need to define all our variables, as you can see in the code shown in the right figure.
  • I have included the Liquid Crystal Library, which is used to operate LCD.
  • Next, I have defined all my sensors to the respective pins and then initialized boolean variables for storing the output of sensors.
  • In the Setup loop, I have made the sensors' pins input pullup using the pinMode Arduino command.
  • Finally, displayed an initialization message on the LCD screen i.e. "Home Security System using Arduino UNO By TEP".
  • The message will display for around 1 second and then LCD will be cleared and the SensorDisplay function will be called, which will simply write sensors' names on the LCD screen.
  • Now compile your code and add the hex file in Arduino UNO and run your PRoteus simulation.
  • If everything goes fine, you will get results as shown in the below figure:

So far, we have just displayed the sensor's names, now let's read the sensors' data in the loop section:

Reading Sensors' Data

  • In the loop section, first of all, we need to read the sensors' data using the digitalRead command, as shown in the code.
  • After reading the sensor's data, I have called the SensorValues function, in which I have placed a check on each sensor's value and updated it on LCD.
  • It's quite straightforward code, if the sensor is giving HIGH output, I am displaying Yes on LCD and if it's LOW, I am simply printing No.
  • We haven't yet defined the modes, so the project will keep on reading the sensors and will display their respective value in the LCD.
  • As you can see in the below figure, if the TestPin of the sensor is HIGH, its respective value on LCD is showing "Yes" and if it's LOW then "No" is written.
  • Now, if you change any sensor's value, its respective value on LCD will be updated.

So, we have successfully interfaced our sensors with Arduino UNO and now it's time to add operational modes to our project.

Two Operational Modes

  • As I mentioned earlier, we need to add two operational modes in our project, and the push button will be used for conversion from one mode to another.
  • So, I have simply added an If loop in my code, as shown in the figure on the right side.
  • In normal mode, I have simply displayed the name of the mode at the first line of LCD.
  • While in secure mode, I am checking if either of the sensors goes HIGH, simply turn ON the Buzzer.
  • Although, you won't be able to hear the Buzzer sound in the below figure, but you can see Buzzer's Pin is HIGH because two of the sensors are giving a response. Check the video for Buzzer working.
  • We normally need to use an optocoupler or relay driver in between the buzzer and microcontroller as buzzers normally operate at 12V, but 5V buzzers are also available.
  • Here's the complete Arduino Code:
/* * All rights reserved to TEP www.TheEngineeringProjects.com */ #include const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; LiquidCrystal lcd(rs, en, d4, d5, d6, d7); #define Flame A0 #define Gas A1 #define Pir A2 #define Vib A3 #define Ir A4 #define Buzzer A5 #define Switch 7 boolean Fire, Smoke, Intruder, Window, Door; boolean Mode = false; void setup() { pinMode(Flame,INPUT_PULLUP); pinMode(Gas,INPUT_PULLUP); pinMode(Pir,INPUT_PULLUP); pinMode(Vib,INPUT_PULLUP); pinMode(Ir,INPUT_PULLUP); pinMode(Switch,INPUT_PULLUP); pinMode(Buzzer,OUTPUT); lcd.begin(20,4); pinMode(Buzzer, OUTPUT); lcd.setCursor(0,1); lcd.print("HOME SECURITY SYSTEM"); lcd.setCursor(0,2); lcd.print(" USING ARDUINO UNO "); lcd.setCursor(7,3); lcd.print("By TEP "); //delay(700); lcd.clear(); SensorDisplay(); } void loop() { Fire = digitalRead(Flame); Smoke = digitalRead(Gas); Intruder = digitalRead(Pir); Window = digitalRead(Vib); Door = digitalRead(Ir); Mode = digitalRead(Switch); SensorValues(); if(Mode==false) // Normal mode { lcd.setCursor(4,0); lcd.print("Normal Mode"); } else // Secure Mode { lcd.setCursor(4,0); lcd.print("Secure Mode"); if((Fire == HIGH) || (Smoke == HIGH) || (Intruder == HIGH) || (Window == HIGH) || (Door == HIGH)){ digitalWrite(Buzzer, HIGH); }else{ digitalWrite(Buzzer, LOW); } } } void SensorDisplay() { lcd.setCursor(0,1); lcd.print("Fire:"); lcd.setCursor(10,1); lcd.print("Smoke:"); lcd.setCursor(0,2); lcd.print("Door:"); lcd.setCursor(10,2); lcd.print("Window:"); lcd.setCursor(0,3); lcd.print("Intruder:"); } void SensorValues() { if(Fire == true){ lcd.setCursor(6,1); lcd.print("Yes");} else{ lcd.setCursor(6,1); lcd.print("No ");} if(Smoke == true){lcd.setCursor(17,1); lcd.print("Yes");} else{lcd.setCursor(17,1); lcd.print("No ");} if(Intruder == true){lcd.setCursor(11,3); lcd.print("Yes");} else{lcd.setCursor(11,3); lcd.print("No ");} if(Window == true){lcd.setCursor(17,2); lcd.print("Yes");} else{lcd.setCursor(17,2); lcd.print("No ");} if(Door == true){lcd.setCursor(6,2); lcd.print("Yes");} else{lcd.setCursor(6,2); lcd.print("No ");} }

Future Scope of Home Security System

  • Embedded has taken over the whole world because of its user-friendliness and low cost.
  • Instead of hiring security guards(which is quite expensive), now smart homes in modern societies are equipped with such home security systems.
  • Modern Home Security systems are even linked with local police or security agencies for emergency help.
  • Moreover, these security systems are not bound to homes only, nowadays offices, banks, shopping malls etc. are all equipped with such smart security systems.

Future Work on Home Security System

  • Today, we have designed a very simple Home Security System, where we interfaced few sensors and have only placed a Buzzer.
  • We will continue this project and will add smart features to it.
  • Let's have a look at few features, which we can add to this project:
    1. We can interface the GSM module to send messages, in case of emergency.
    2. We can add more sensors i.e. ultrasonic sensors, different types of Gas sensors in it.
    3. We can also improve our code by using interrupts instead of polling.
    4. We can also add a camera for facial recognition.
    5. To improve the security, we can add a keypad and only authorized persons will have the access to enter.
    6. The fingerprint sensor can also be used for identification purposes.

So, that was all for today. I hope you guys have enjoyed today's project. If you have any questions/queries, please ask in the comments and I will try my best to resolve them asap. Thanks for reading, take care. Bye :)

2 Relay Module Interfacing with Arduino

Hello everyone! I hope you all will be absolutely fine and having fun. Today, I am going to provide a detailed discussion on 2 Relay Module Interfacing with Arduino. First of all I would like to explain you that what is relay and how to use it and then we will move forward towards 2 relay module interfacing with Arduino. I have already controlled relay with 555 timers. 2 relay module consists of two relays. Relay is basically an electronic device or a switch which is used to open and close the circuits electronically. A relay controls an electric circuit by opening and closing contacts in another circuit. When the relay contact is normally open (NO), there will be an open connection when the relay is not energized. When the relay contact is normally closed, there will be a closed connection even when the relay is not energized. We can use relays to control the smaller currents in different electronic circuits. 2 relay module has two relays. One relay can control two AC/DC device simultaneously. That means 2 relay module can control four AC/DC devices at a time. 2 relay module is normally used to control the DC motors in different projects e.g. robotics, automation, embedded projects etc. It can control two DC motors simultaneously. Moreover, we can also use it for different applications e.g. to control DC/AC fans, AC/DC lights, AC/DC bulbs and a lot more. The further detail about 2 relay module interfacing with Arduino will be given later in this tutorial.

2 Relay Module Interfacing with Arduino

2 Relay Module is an electronic device consists of two relays as its major components. Relay is a switch which makes or loses the connection between two different circuits. A single relay is capable of controlling two AC/DC devices simultaneously. So, 2 relay module is able to control four AC/DC devices at the same time. Mostly it is used to control the DC motors. It can also be used in different projects e.g embedded projects, robotic, automation, power etc. 2 relay module is shown in the figure given below.
1. Relay Proteus Simulation
2. 2 Relay Module  Components
  • A complete list of the components used while designing 2 relay module is shown in the figure given below.
3. 2 Relay Module  Input Pins
  • 2 relay module has five (5) input pins in total, each perform different action.
  •  All of its pins are provided in the table shown in the figure below.
4. 2 Relay Module  Input Pins Description
  • We must know about the functions of each pin.
  • 2 relay board/module input pin functions are listed in the table shown in the figure below.
  • Both IN1 and IN2 comes from the micro-controller (Arduino UNO in this case).
  • IN1 pin controls the 1st relay attached on 2 relay module.
  • IN2 pin controls the 2nd relay attached on 2 relay module
5. 2 Relay Module  Output Pins
  • 2 relay module has three (3) output pins for each relay.
  • Its output pins are given in the table shown in the figure given below.
6. 2 Relay Module  Output Pins Description
  • Each output pin of 2 relay module has its own functions.
  • 2 relay module pin functions are listed in the table given in the figure shown below.
  • NO pin is normally open pin and device attached to this pin will not work if the relay is not energized.
  • COM is a common pin i.e. ground pin.
  • NC is normally closed pin and device attached to this pin will start working even if the relay is not energized.
7. 2 Relay Module  Compatibility
  • 2 relay module is compatible with different micro-controllers.
  • Some of those micro-controllers are provided in the table shown in the figure given below.
8. 2 Relay Module  Circuit Diagram
  • Circuit diagram of 2 relay module is given in the figure shown below.
9. 2 Relay Module  Interfacing with Arduino Wiring Diagrams
10. 2 Relay Module  Interfacing with Arduino Actual Diagrams
  • I have provided the complete wiring diagram for 2 relay module interfacing with Arduino.
  • Wiring diagram is shown in the figure given below.
11. 2 Relay Module  Interfacing with Arduino Source Code & Description
  • If you are new to Arduino software then you must have a look at How to write Arduino code.
  • You just need to copy and paste the source code given below in your Arduino software.
  • The complete source code for 2 relay module interfacing with Arduino is given below.
int relay1 = 6;
int relay2 = 7;  

void setup() {
  
  pinMode(relay1, OUTPUT); 
  pinMode(relay2, OUTPUT);
}

void loop() {

   digitalWrite(relay1,LOW);
   delay(1000);
 
   digitalWrite(relay1,HIGH); 
   delay(1000);
   
   digitalWrite(relay2,LOW); 
   delay(1000);
   
   digitalWrite(relay2,HIGH); 
   delay(1000);
}
  • First of all I have defined relay pins.
  • Then I have changed the mode of these pins to output.
  • After that I have turned on and off both of the relays with the delay of 1 sec or 1000 msec.
  • So, that was the brief description about the source code for 2 relay module interfacing with Arduino.
  • You can download the wiring diagram and complete Arduino source code here by clicking on the button below.

12. 2 Relay Module  Features
  • The most common features associated with 2 relay module are provided in the table shown in the figure given below.
13. 2 Relay Module  Application
  • 2 relay module applications are given in the table shown in the figure below.
In the tutorial 2 Relay Module Interfacing with Arduino, we have learnt about the components used in the design of 2 relay module. We have also learnt about the 2 relay module interfacing with Arduino. I have provided the complete Arduino source code, you can control this module using the same code. I hope you have enjoyed the tutorial. If you have any problem you can ask us in comments. Out team is 24/7 available for you. I will share different informative engineering topics in my upcoming tutorials. So, till my next tutorial, take care and bye :)

Line Following Robot using Arduino

Hello everyone, I hope you all are fine and having fun with your lives. Today, I am going to share a very basic project named as Line Following Robot using Arduino. I have designed a three wheeler robot and have placed IR sensors beneath it to detect the black line and then I have made it move over this Black Line.

This Line Following Robot is not doing any extra feature i.e. turning or rotating back. It will just simply move in the straight line. I have also posted a short video at the botton of this tutorials which will give you better idea of how this robot moves. You should first read this tutorial and design the basic robot and once you are successful in designing the basic Line Following Robot then you should have a look at my recent Project Line following Robotic Waiter in which I have designed a Robotic waiter which follows the line and also take turns on different tables. So, let's get started with Line Following Robot using Arduino.

Line Following Robot using Arduino

  • First of all I have designed the Mechanical model of the robot, which has three wheels on it.
  • Its a triangular method in which the motors were attached to the front two wheels and the back wheel is a caster wheel, which is present in the middle of the robot.
  • Here's the image of front wheel coupled with the DC Gear Motor:
  • Now let's have a look at the rear caster wheels, shown in below image:
  • Finally, I have used Acrylic as the body of the robot.
  • Here's the assembled version of our Line Following Robot:
  • Now that we have the mechanical design of our robot and we have assembled it completely.
  • So, now comes the electronics part where we are gonna place the DC Motor Driver Circuits and will also place the IR sensors.
  • I have used Arduino board for programming of this Line following Robot.
  • First of all, I have designed the 2 relay baord for DC motors.
  • Its circuit diagram is shown in below figure:
  • We also need a voltage divider circuit because we need such a power supply from which we can get 5V, while our source battery is of 12V.
  • So, in order to do that I have used 7805 Regulator IC and have designed a simple circuit as shown in below figure:
  • Now placing all the components over the Line following Robot, it looked like something as shown in below figure:
  • Here's the Arduino code which you need to upload in your Arduino board:
#define motorL1 8
#define motorL2 9
#define motorR1 10
#define motorR2 11

#define PwmLeft 5
#define PwmRight 6

#define SensorR 2
#define SensorL 3
#define Sensor3 A0
#define Sensor4 A1

#define TableA A4
#define TableB A2
#define TableC A5
#define TableD A3

int OriginalSpeed = 200;
int TableCount = 0;
int TableCheck = 0;
int RFCheck = 10;

void setup() 
{
  Serial.begin (9600);
 
  pinMode(motorR1, OUTPUT);
  pinMode(motorR2, OUTPUT);
  pinMode(motorL1, OUTPUT);
  pinMode(motorL2, OUTPUT);
  
  pinMode(PwmLeft, OUTPUT);
  pinMode(PwmRight, OUTPUT);
  
  pinMode(SensorL, INPUT);
  pinMode(SensorR, INPUT);
  pinMode(Sensor3, INPUT);
  pinMode(Sensor4, INPUT);
  
  pinMode(TableA, INPUT);
  pinMode(TableB, INPUT);
  pinMode(TableC, INPUT);
  pinMode(TableD, INPUT);
  
  MotorsStop();
  
  analogWrite(PwmLeft, 0); 
  analogWrite(PwmRight, 0);
  delay(2000); 
 // Serial.println("fghfg");
  
}

void loop() {
  MotorsForward();
  PIDController();
}

void MotorsBackward()
{
    digitalWrite(motorL1, HIGH);
    digitalWrite(motorL2, LOW);
    digitalWrite(motorR1, HIGH);
    digitalWrite(motorR2, LOW);
}

void MotorsForward()
{
    digitalWrite(motorL1, LOW);
    digitalWrite(motorL2, HIGH);
    digitalWrite(motorR1, LOW);
    digitalWrite(motorR2, HIGH);
}

void MotorsStop()
{
    digitalWrite(motorL1, HIGH);
    digitalWrite(motorL2, HIGH);
    digitalWrite(motorR1, HIGH);
    digitalWrite(motorR2, HIGH);
}

void MotorsLeft()
{
    analogWrite(PwmLeft, 0); 
  analogWrite(PwmRight, 0);
    digitalWrite(motorR1, HIGH);
    digitalWrite(motorR2, HIGH);
    digitalWrite(motorL1, LOW);
    digitalWrite(motorL2, HIGH);
}

void MotorsRight()
{
      analogWrite(PwmLeft, 0); 
  analogWrite(PwmRight, 0);
    digitalWrite(motorR1, LOW);
    digitalWrite(motorR2, HIGH);
    digitalWrite(motorL1, HIGH);
    digitalWrite(motorL2, HIGH);
}

void Motors180()
{
    analogWrite(PwmLeft, 0); 
    analogWrite(PwmRight, 0);
    digitalWrite(motorL1, HIGH);
    digitalWrite(motorL2, LOW);
    digitalWrite(motorR1, LOW);
    digitalWrite(motorR2, HIGH);
}

void PIDController()
{
  if(digitalRead(SensorL) == HIGH){analogWrite(PwmRight, 250);analogWrite(PwmLeft, 0);}
  if(digitalRead(SensorR) == HIGH){analogWrite(PwmLeft, 250);analogWrite(PwmRight,0);}
  if((digitalRead(SensorL) == LOW) && (digitalRead(SensorR) == LOW)){analogWrite(PwmRight, 0);analogWrite(PwmLeft, 0);}
}
  • Now that's all, here's the video for Line Following Robot using Arduino which will give you better idea:
That's all for today. I hope you have enjoyed this Line Following Robot using Arduino and are gonna use it in your projects. feel free to ask in comments, if you got into any trouble. Thanks for reading. Take care !!! :)

Home Automation Project using XBee & Arduino

Hello friends, I hope you all are fine and having fun with your lives. Today, I am going to share a new Home Automation Project using XBee & Arduino. Home Automation Project is a most commonly designed project by the engineering students. So, that's why I have thought to create a complete Home Automation Project so that engineering students can get benefit out of it.

We all know about automation which is originated from automate or automatic. In automation the task is done automatically and you don't need to control it. In normal Home automation project, there are few sensors which are displayed wirelessly to user and there are few controls like user can ON or OFF Lights, Fans etc via remote or mobile App.

In this Project, I have used Arduino UNO board and I have designed its complete working simulation in Proteus software, so that users got sure that its working perfectly. Because we have to work a lot in designing this complete working simulation of home Automation Project that's why its not free but you can buy it for a small price of $50. In this price, you will get the compelte Arduino code along with the working Proteus Simulation. But before buying this project, must have a look at the details below so that you are sure what you are buying. So, let's get started with Home Automation Project using XBee & Arduino.

Home Automation Project using XBee & Arduino

  • You can buy the complete working Proteus Simulation along with the Arduino Programming Code by clicking the below button.
  • You can pay via Paypal and the download link will be instantly available to you and if you don't have the PayPal account then use our Contact Us Form and we will find some other way for you.

Buy This Project

1: Overview
  • First of all, let's have an overview of this Home Automation Project.
  • In this Project, I have designed two simulations, one simulation is for Remote using which we are gonna control our appliances and the second simulation is for the controlling of these appliances.
  • So, when you press buttons from your remote section, a wireless command will be sent to the control board and it will turn ON or OFF the respective load.
  • Moreover, there's an LCD on the Remote on which you will also check the values of the sensors.
  • So, in simple words, the remote will be in your hand and using this remote you can easily turn ON or OFF your appliances and can also check the status of your different sensors wirelessly.
  • Let's first have a look at the remote section:
Remote Control:
  • In Remote Control Section, I have used the below main modules:
    • Arduino UNO: Microcontroller Board.
    • KeyPad: Commands will be sent by clicking this Keypad's buttons.
    • LCD (20 x 4): For Displaying Sensor's Data & Commands.
    • XBee Module: It's an RF Module used for sending wireless commands.
  • Now when you click any button on your Keypad, a command is sent from Arduino to XBee Module and the XBee module then forwards that command to other XBee on the Control Unit.
  • Moreover, when the Control Unit sends the Sensors' data on xbee then Arduino receives that data and then displayed that data on LCD.
  • Here's the block diagram of Remote control section which will give you a better idea of its working:
  • Here's the Proteus Diagram of our Remote Section:
  • In the above Proteus Simulation of Remote Control, you can see that we have Arduino UNO board which is connected with LCD, KeyPad and XBee Module.
  • Working of this Remote section will be discussed in the later section.
  • Now let's have a look at the Control Unit Side of Home Automation Project.
Note:You must also have a look at below tutorials because I have interfaced these modules separately with Arduino as well: Control Unit:
  • In the previous section, we had an overview of the Remote section, now let's have a look at the Control Unit.
  • The Control Unit is the Unit which is being controlled by the Remote Control.
  • The Main components of Control Unit are:
    • Arduino UNO: Microcontroller Board.
    • Relays: Used to control the appliances. I have added eight relays so you can control eight appliances.
    • Lamps: Indicating the Bulbs.
    • DC Motors: Indicating the Fans.
    • Smoke Sensor: Used to detect the Smoke.
    • Flame Sensor: Used for Fire detection.
    • DS18B20: Used to measure atmospheric temperature.
Note:
  • On this Control unit, the Arduino UNO is getting the data from the smoke sensors and then sending this data via XBee to Remote Control.
  • We have seen in the previous section that this data is then displayed over LCD.
  • Moreover, when any button is pressed from the Remote Control, the command is received by this Arduino via XBee.
  • On receiving this command, Arduino UNO then turns ON or OFF the respective relay which in turn ON or OFF the respective appliance.
  • Here's the block diagram of this control unit:
  • You can see in the above block diagram that I have connected three sensors with Arduino and Arduino is receving their values and then sending these values to the remote control via XBee.
  • Moreover Relays are also connected to Arduino and then loads are further connected to these Relays.
  • So, Arduino is controlling these Relays which in turn are controlling the loads.
  • I have used eight relays and hence eight loads.
  • The Loads I have used are all DC loads because Proteus doesn't have AC active loads in it but you can place AC loads as well.
  • Here's the Proteus Simulation of Control Unit:
  • You can see all the modules are present in it.
  • Eight relays are present on the right side and their outputs are going into the loads.
  • I have used four lamps and four DC Motors.
  • Now let's have a look at their operation.
Note:You should also have a look at below tutorials in which I have interfaced these sensors separately with Arduino:
2: Operation
  • I have already mentioned their operation in above section so I am not gonna discuss it in detail.
  • But let's have a little talk about their operation.
  • First I am gonna discuss the operation of Remote Control:
Remote Control:
  • The remote Control has an XBee module which is used for wireless communication.
  • The Keypad has buttons on it so now when you press button "1" on the keypad then the Signal is sent via XBee to Control Unit.
  • The control unit will automatically turn on the first load when it will receive the command from button "1" of Remote Control.
  • When you press "1" for the first time then the first load will turn ON but when you press button "1" again then the first load will go off.
  • So, its like if you want to turn it ON then press it and if you want to turn it OFF then press again. (Quite simple :P)
  • As there are eigth loads, so button "1" to "8" are working for loads "1" to "8" respectively.
  • Moreover, when sensor's data come from control unit then it is updated in the LCD of Remote Control.
  • Now let's have a look at the operation of Control Unit:
Control Unit:
  • As the Control Unit is concerned, it keeps on waiting for the command from remote and whenever a command is received from the Remote Control, it turns ON or OFF the respective load.
  • Moreover, it also sends the data of sensors continuously to the Remote Control.
  • For this wireless communication, XBee is used here.
3: Working
  • This is the last section of this project where will will have a look at the working of the project.
  • I haven't divided this section in parts instead I have create a video which will explain the working in detail.
  • Here's the First look of Remote section image while working:
  • Now when the Sensor's data come from the remote Section then it will be displayed in the LCD as shown in below figure:
  • You can see in the above figure that both sensors are detecting and the temperature is also displayed in the LCD.
  • Now the complete working of this project is shown in the below video which will give you complete idea of this project:
Note:
  • If you buy this project and you are unable to run it properly then we will provide you free service and will make it work on your laptop perfectly. :)
So, that's all for today. I hope you have liked this Home Automation Project and are gonna buy this one. But again before buying it must read this tutorial and also watch the video so that you get complete understanding of this project.

DC Motor Direction Control with Arduino in Proteus

Hello friends, hope you all are fine and having fun with life. Today, I am going to share DC Motor Direction Control with Arduino. I have designed a complete simulation in Proteus, which will help you in understanding the controlling of DC motor. I would recommend you to first read How to Control relay in Proteus ISIS which will help you in understanding the functionality of relays because in today's tutorial, I have used relays to do the DC Motor Direction Control. I have already posted a tutorial on DC Motor Drive Circuit in Proteus ISIS.

So, for DC Motor Direction Control, I have used Arduino UNO baord, so you should also download this Arduino Library for Proteus so that you can use Arduino boards in Proteus software. I have also provide the simulation and the code for DC Motor Direction Control but I would recommend you to design it on your own so that you learn from it. If you have any problem then ask in comments and I will try to resolve them. In this project, I have used Serial Terminal. So, whenever someone, sends character "C" on serial terminal then the motor will move in Clockwise Direction and when someone sends character "A" then it will move in Anti-clockwise Direction and will stop on character "S". Anyways, lets get started with DC Motor Direction Control with Arduino in Proteus ISIS.

DC Motor Direction Control with Arduino in Proteus ISIS

  • You can download the Proteus simulation for DC Motor Direction Control by clicking the below button:
Download Proteus Simulation for DC Motor

  • So, now let's move on with designing it, first of all get the below components from Proteus and place them in your workspace:
  • Now, design a circuit in Proteus software, as shown in below figure:
  • You can see in the above figure that I have used two relays which I have used for DC Motor Direction Control.
  • Moreover, there's a Virtual Terminal through which I am sending the commands.
  • I have used Arduino UNO board for DC Motor Direction Control through Virtual Terminal. You should download the Arduino Library for Proteus so that you can use it in Proteus.
  • Now upload the below code in your Arduino software and get the hex file. You should read how to get the Hex file from Arduino.
int Motor1 = 2;
int Motor2 = 3;

void setup() {
  pinMode(Motor1, OUTPUT);
  pinMode(Motor2, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  if(Serial.available())
  {
    char data = Serial.read();
    Serial.println(data);
    if(data == 'C'){MotorClockwise();}
    if(data == 'A'){MotorAntiClockwise();}
    if(data == 'S'){MotorStop();}
  }
}

void MotorAntiClockwise()
{
  digitalWrite(Motor1, HIGH);
  digitalWrite(Motor2, LOW);
}

void MotorClockwise()
{
  digitalWrite(Motor1, LOW);
  digitalWrite(Motor2, HIGH);
}

void MotorStop()
{
  digitalWrite(Motor1, HIGH);
  digitalWrite(Motor2, HIGH);
}
  • In the above code, I have designed three functions which I am calling on Serial receive.
  • The code is quite self explanatory but if you got problem then ask in comments and I will resolve them.
  • Once everything's done then run your simulation and if you have done fine then it will start working as shown in below figure:
  • Obviously, you can't see a moving DC motor in an image but you can get the idea from Relays position in above figure. :)
  • The below video will give you the better idea of How it works.

So, that's all for today. Hopefully now you have got the idea of How to do DC Motor Direction Control with Arduino in Proteus ISIS. In the next tutorial, I am gonna add speed control of DC Motor. So, till then take care and have fun. :)

Intelligent Energy Saving System

Hello friends, hope you all are fine and having fun with your lives. Today, I am going to share a complete project with you guys. Its an Intelligent Energy Saving System which I designed around two years ago. So, today I thought to share it so that others could also get benefit. In this project, I have used Arduino UNO board for programming purposes. Its not much complicated project but is the basic for many complex projects.

Energy, is a small word, but is the problem of whole world. Particularly when we are talking about electrical energy. IF you consume more electrical energy then you will get quite huge bill at the end of the month. :P So, there's always work done on reducing the consumption of electrical energy and also we compare energy costs from different providers. As a human, suppose you turn ON your room fan, then normally you forget to turn it OFF and thus your bill keeps on increasing. So in order to avoid this, automation is the only tool which comes in handy. Like there must be such system which automatically detects whether someone is still in the room or not and if there's no one then lights got OFF automatically. In this way, you can quite easily reduce your electricity cost. This same concept is presented in this project, let's have a complete look over it. :)

Overview of Intelligent Energy Saving System

  • In this project, we have designed a complete room and used two inductive loads i.e. bulbs and one fan.
  • Now the purpose of this project was to save the energy so we used two IR sensors for counting.
  • Now, if there's no one present in the room then the loads will automatically turn OFF and when someone will enter in the room then the loads will automatically turn ON.
  • Moreover, we have also added a counter functionality in it i.e. the project will also count the number of people present in the room.
  • All these parameters will also display on the LCD attached with Arduino.
Components Used

I am mentioning here the components used in designing this project. I am not giving the exact values as you will get them in the circuit diagrams. Here's the list:

  • Arduino UNO
  • IR Sensors
  • 16 x 2 LCD
  • 100W Bulbs
  • 12V Fan
  • 2 Relay Board
  • 7805 (IC Regulator)
  • LED (Indication)
  • Resistance
  • Capacitors

Circuit Diagrams of Intelligent Energy Saving System

Suppose you are designing this project then the first thing you are gonna need is the circuit diagrams for the project so here I am gonna show you all the circuit diagrams step by step so let's start:

1: Interfacing of Arduino with LCD
  • First thing we are gonna need is the interfacing of Arduino with LCD. LCD used in this project is 16 x 2.
  • I have first designed the simulation in Proteus as its always better to design the simulation before going into real hardware.
  • Now upload the below code into it, just to test that whether its working fine or not:
    #include <LiquidCrystal.h>
    LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

    void setup()
    {

    lcd.begin(16, 2);
    lcd.print("www.TheEngineer");
    lcd.setCursor(0,1);
    lcd.print("ingProjects.com");
    }
    void loop() {}
  • Now run it and if everything's gone fine then you will get something as shown in below figure:
Note:
2: Circuit diagram of 2 Relay Board
  • Next thing we are gonna need is the two relay board. Using these relays we are gonna turn ON or OFF our loads.
  • Here's the circuit diagram for 2 relay board.
  • As you can see in the above figure, I have used two relay board, where both the relays are controlled bt simple logic operators.
  • Now instead of these logic operators, you need to give Arduino Pins here.
  • I have made the first relay ON while the second relay is OFF.
  • In the above figure, relay outputs are open so you can place anything here as its gonna act as switch. So, in our case the loads will be placed after this relay.
3: Circuit Design of Buzzer
  • Next circuit design which we need to understand is the buzzer circuit design.
  • Its quite simple and similar to 2 relay board. I have also published a detailed post on How to Design a Buzzer in Proteus ISIS, which will be quite helpful.
  • Here' I am gonna explain it lightly, so let's have a look at the circuit diagram of buzzer:
  • You can quite easily understand the above figure, where I have shown both the ON and OFF states of buzzer.
4: Circuit Diagram of IR Sensor:
  • In this project, I have used two IR sensors, both are placed on the door one after another. You can read more about the designing of IR Sensor on my post Circuit Diagram of IR Sensor using 555 Timer.
  • I have named them Entering IR Sensor and Leaving IR Sensor.
  • The logic behind these two sensors is that, when someone enters in the room then he will first pass the Entering IR Sensor and then will hit the Leaving IR Sensor and if someone is leaving the room then he will first pass the Leaving IR Sensor and then will cut the Entering.
  • So, in this way I am counting the persons if someone entering in the room I simply increment and if someone's leaving then I decrement.
  • Now, if number of people in the room becomes zero then I turn OFF all the lights and the fan, and if there even one person in the room then I turn ON the lights and fan.
  • Here's the circuit diagram of IR Sensor:
  • IR transmitter and Receiver are not available in Proteus so that's why I have used the button so when you press the button, its like someone cut the beam of IR sensor, and you will get below result:
 
5: Complete Circuit Diagram of Intelligent Energy Saving System
  • Now that we have designed the individual circuit diagrams, next thing we are gonna do is the assembly of complete project.
  • So, here's the complete circuit diagram of this project:
  • As you can see in the above figure, I have used two IR Sensors. The first IR Sensor is for entering in the room while the IR sensor is for leaving the room.
  • Next is the buzzer circuit which is also quite simple and I have explain in detail above.
  • LCD will display the no of people in a room and will also display either the bulb is ON or OFF, and also about Fan status.
  • I haven't shown the relay circuit in above figure as it will not fit in the space and I think you guys can place it easily.

Programming Code for Intelligent Energy Saving System

  • The code designed for this project is developed in Arduino software.
  • Code is as follows:
#include <LiquidCrystal.h>
#include <OneWire.h>
#include <DallasTemperature.h>
 
#define ONE_WIRE_BUS 8
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

float celsius, fahrenheit;

int Sensor1 = A0;
int Sensor2 = A1;

int Bulb = A5;
int Fan = A4;
int Buzzer = A3;

int Counter = 0;
int Sen1Check = 0;
int Sen2Check = 0;

void setup(void) 
{
    Serial.begin(9600);
    digitalWrite(Bulb, HIGH);
    digitalWrite(Fan, HIGH);
    digitalWrite(Buzzer, HIGH);
    pinMode(Sensor1, INPUT);
    pinMode(Sensor2, INPUT);
    pinMode(Bulb, OUTPUT);
    pinMode(Fan, OUTPUT);
    pinMode(Buzzer, OUTPUT);
    
    
    lcd.begin(20, 4);
    lcd.setCursor(0, 1);
    lcd.print("Temp = ");
    lcd.setCursor(0, 0);
    lcd.print("Counter = ");
    lcd.setCursor(12, 0);
    lcd.print("Persons");
}

void loop() 
{
  CheckEntry();
  CheckLeaving();
  lcd.setCursor(7, 1);
  sensors.requestTemperatures();
  lcd.println(sensors.getTempCByIndex(0));
  lcd.setCursor(12, 1);
  lcd.print(" degC");
  lcd.setCursor(10, 0);
  if(Counter >= 0){lcd.print(Counter);}
  if(Counter < 0){Counter = 0;}
  
  if(Counter > 0)
  {
      digitalWrite(Bulb, LOW);
      digitalWrite(Fan, LOW);
      digitalWrite(Buzzer, HIGH);
      lcd.setCursor(0, 2);
      lcd.print("Fan : ON ");
      lcd.setCursor(0, 3);
      lcd.print("Bulb : ON ");
  }
  
  if(Counter < 1)
  {
      digitalWrite(Bulb, HIGH);
      digitalWrite(Fan, HIGH);
      digitalWrite(Buzzer, HIGH);
      lcd.setCursor(0, 2);
      lcd.print("Fan : OFF");
      lcd.setCursor(0, 3);
      lcd.print("Bulb : OFF");
      
  }
  

}


void CheckEntry()
{
    if(((digitalRead(Sensor1) == LOW) || (Sen1Check == 1)) && (Sen2Check == 0))
    {
        while(digitalRead(Sensor1) == LOW);
        Sen1Check = 1;
     
        if(digitalRead(Sensor2) == LOW)
        {
            Counter++;
            Sen1Check = 0;
            while(digitalRead(Sensor2) == LOW);
        }
    } 
}


void CheckLeaving()
{
    if(((digitalRead(Sensor2) == LOW) || (Sen2Check == 1)) && (Sen1Check == 0))
    {
        while(digitalRead(Sensor2) == LOW);
        Sen2Check = 1;
       
        if(digitalRead(Sensor1) == LOW)
        {
            Counter = Counter - 1;
            Sen2Check = 0;
            while(digitalRead(Sensor1) == LOW);
        }
    } 
}
  • Coding isn't much difficult for this project, but still if you get into some trouble ask in comments and I will check it out.
  • Here's the complete video for this Intelligent Energy Saving System, which will explain all about the project.
That's all for today. I hope I have helped you guys in some way. Till next tutorial, take care ALLAH HAFIZ :)

How to Control Relay in Proteus ISIS

Hello friends, hope you all are fine and having fun. In the previous posts, we have discussed DC motor Control in Proteus ISIS and after that we have discussed the Stepper Motor Control in Proteus ISIS and finally we had a look at Servo Motor Control in Proteus ISIS. Now when you talk about motors control then first thing came in mind is Relay, because relay is the best way of controlling any motor. In today's post, we are gonna have a look at How to Control Relay in Proteus ISIS. Relay is a key components of any electronics or electrical circuit and is usually a problem for the engineers and students. Although, its not as difficult as it seems so I thought to post about it.

In today's post, we will first simulate the Relay in a simple circuit in which when you run the simulation, the relay will automatically got activated and after that we will go in a bit detail and will control relay using a logic, i.e. when you provide +5V to it then the relay will go activated and when you give GNd then it will de-energize. I will explain it below in detail how to use it with Microcontroller. Moreover, if you are planning to work on Relay then you should also check What is a Relay and How to use it? and should also have a look at Relay Interfacing with Microcontroller using ULN2003 and finally must check this one as well Relay Control using 555 timer in Proteus ISIS.If you have any questions. related to it then ask in comments and I will try my best to reply your queries. Let's get started with designing of control relay in Proteus ISIS.

Simple Control Relay Circuit in Proteus ISIS

  • First of all, we are gonna simulate a simple control relay circuit in which we will manually turn on or off the relay.
  • Open Proteus ISIS and select the below components, as shown in below figure, from the components library of Proteus, if you don't know how to do it then check our earlier posts on Proteus.
  • Now, design a circuit as shown in below figure:
  • The circuit is self explanatory, first we have used a simple 12V battery to power up the simulation, after that there's a small led attached, which will indicate that whether proper power is supplied to the system or not. Next is our relay, which is named as RL1 in the above figure.
  • After the relay, we have placed a simple 12V lamp, so now when the relay will be energized, this lamp will glow up and when the relay is de-energized, the lamp will remain off. As in the above figure, the simulation is off, that's why the lamp isn't glowing.
  • After designing the circuit, now click on the run button and if everything goes fine, then the lamp will glow as shown in below figure:
  • So, now you can see the small led is also ON, I have used green that's why its showing green color indicating that power supply is working.
  • If you compare the off state and on state simulation then you will see that the Relay is now connected with second terminal and thus completing the circuit for lamp and lamp is also now glowing.

Complex Relay simulation in Proteus ISIS

  • Now, we are gonna design a bit more complex control  relay simulation in Proteus ISIS, it's not much complicated but needs a bit more care while simulating.
  • In previous section, we have seen a simple circuit which is operated manually means in order to turn it on or off you have to turn on or off the power supply but normally, it is required that the relay must be controlled by some microcontroller automatically.
  • As the microcontrollers normally work on 5V so in order to control a 12V relay using 5V microcontroller, we need to use transistor. In that case, when you give +5V the relay got actuated and when you give GND then relay get turned off.
  • So, first of all get these components from the Arduino components library.
  • Now, design the circuit as shown in the below figure:
  • As this tutorial is about relays so I haven't used microcontroller here, instead I used this logic state, it will work same as microcontroller. So the above circuit is quite similar to the simple circuit we have seen in the above section. The only difference here is the NPN transistor.
  • Now, we are not providing the supply directly to the relay, instead we are providing it via this transistor. So, when the logid state is zero means ground, the transistor won't work and the supply cant reached to the relay and when we make the logic 1 means +5V on the base of transostor, then the relay circuit will complete and the relay will be energized.
  • Now run the simulation, the off state is shown below:
  • In the above figure, you can see that the led goes on because the power is supplied to the circuit but the lamp is still OFF and the relay is also not energized because the logic state is a low level i.e. 0.
  • Now click on the logic state to make it on high level i.e. +5V, the on state is shown in below figure:
  • Now you can see that as we make the logic state high, now relay got connected and the lamp is also ON. So by comparing both ON and OFF states, you can easily get the idea how the relay is operating.
Note:
  • If you are planning on using the relay with microcontroller, then simply remove this logic state and connect the base of transistor with the output pin of microcontroller and when you low the microcontroller pin relay will get de energized and and when you make the pin high, it will get energized.
    • That's all for today, hope you have got something out of it. In the next post I will show how to simulate a DC motor using relay. Till then take care. :))

Relay Interfacing With Microcontroller using ULN2003A

Hello friends, I hope you all are doing great. In today's tutorial, I am going to explain the Relay Interfacing with Microcontroller using ULN2003A. In the previous lecture, we have discussed the detailed Introduction to Relay along with its working. Now we are going to practically interface the relay with a microcontroller to design an automatic switch. Relay is a key component in almost every electronic circuit. It can be used as a switch and can also be used as a voltage regulator.

The microcontroller I am going to use here is PIC18F4552 but you can use any other Microcontroller. You just need to change the syntax of coding but the logic will remain the same. Here, I am using ULN2003A to control the relay and from this relay, we can control anything.

So, let's get started:

Where To Buy?
No.ComponentsDistributorLink To Buy
1LEDsAmazonBuy Now
2RelayAmazonBuy Now
3ResistorAmazonBuy Now
4ULN2003AmazonBuy Now

Relay Interfacing With Microcontroller

  • I am using a 12V relay, meaning we need to provide a 12V at its input coil, in order to get it energized.
  • In simple words, when we send the +12V signal from our PIC microcontroller, it will actuate the relay coil and the relay output gets connected and when we make the input LOW, the coil de-energized.

Now, the question is ???

  • But the real question is PIC gives 5V at its high signal but the relay operates at 12V so how to convert this 5V signal into 12V?

What's the Solution ???

  • The solution to this problem is ULN2003A.
  • ULN2003A is used in between the PIC and the relay, so when the PIC sends the HIGH signal i.e. 5V, ULN converts it to 12V, sends it to the relay and the relay gets actuated.

Circuit Diagram of Relay with ULN2003A

  • Here's the circuit diagram for this complete project:

  • Resistance R1 is used as a pull-up resistance.
  • LED is used for the indication, when the relay is actuated LED goes ON otherwise OFF.
  • The programming portion is not much, just send high and low signals from PIC to ON and OFF the relay.

That's all for today guys. If you guys have any problem in any part of this tutorial ask in the comments, and I will reply to your queries. Till next tutorial ALLAH HAFIZ .... :))

Introduction to Relay

Hello everyone! I hope you will be fine and having fun. Today, I am going to give a detailed Introduction to Relay. In this tutorial, we will learn the basics of relays, the working principle of relays, the types of relays and their applications in detail.

A relay is a simple automatic switch that opens and closes the circuit(either electronically or mechanically) based on its input signal. A relay is an electromechanical switch that uses electromagnetism from a small current or voltage to switch higher current or voltage for different appliances. When a relay is in a Normally Open (NO) state, no current passes through it and when the relay is energized, the current starts to flow and we can say the relay is in a Normally Closed state. You should also have a look at Relay Interfacing with Microcontroller using ULN2003.

A Relay is used to control high-power devices with small current devices i.e. microcontrollers. When a small voltage is applied(normally from microcontrollers) to the input coil of a relay, it gets energized and the relay output changes its position from NO to NC. Relays are also used for protection purposes i.e. overload, reverse, under current, over current etc.

Now let's have a detailed overview of What is Relay???

What is a Relay?

Relay is an automatic switch, which opens and closes the circuit electronically. It uses electromagnetism from small voltage to provide higher voltages. It has two basic contacts i.e. NO (Normally Open) and NC (Normally Closed). When input voltage is applied across its coil, NC changes to NO and NO changes to NC. When input voltage is supplied, we say that the relay is energized. It has several features e.g. it can be used for switching smaller voltage to higher. But it can not be used in power-consuming devices. It has a wide range of applications. It can be used in home appliances, electronic circuits where there is a need of protection, robotics for controlling its motors for the proper motion and many more. A basic relay is given in the figure shown below.

1. Relay Pins
  • Relay has total five (5) pins with different individual functions.
  • Three pins are at one side of the structure.
  • The other two pins are on the opposite side of the structure.
  • All of these pins are provided in the table given in the figure shown below.
  • I have also made a relay pin configuration diagram.
  • Pin configuration diagram is shown in the figure given below.
2. Relay Pins Description
  • Each pin has different functions to perform.
  • So, we must know about each of the function before using it, for the better use of it.
  • All these pin descriptions are listed in the table shown in the figure below.
3. Relay Internal Structure
  • Internal structure of any electronic device leads to the better understanding about its working principle.
  • I have made a completely labeled internal structure of relay along with its pin configurations.
  • Relay internal structure is shown in the figure given below.
4. Relay Pinout
  • If you want to know about the pin configuration of any electronic device you must have a look at its pinout diagram.
  • Pinout diagram helps us to understand the pin configurations in a better way.
  • I have made a pinout diagram which contains relay animation, internal structure and the real image.
  • Relay pinout diagram is given in the figure shown below.

5. Relay Working Principle
  • Relay works on a pretty simple principle.
  • Initially when the power is not supplied and relay is in normally open condition, its contact will be opened.
  • When relay is in normally closed condition, its contact will be closed.
  • When power is supplied to its coil, it gets energized and its normally open condition is changed to normally closed and normally closed condition is changed to normally open.
  • If we want to control the device via relay through a software then we have to attach this device to its normally open terminal.
  • When the relay gets energized, that device will be turned on for the appropriate operation.
  • Working principle of array can be understand from the visuals given in the figure shown below.
  • Initially, when the power is not supplied and you can see the relay has normally closed contact as shown in the figure give below.
  • As I have told earlier, when we supply power the normally closed contact will changed its state to normally open contact and vice versa.
  • The explanation of the above step is given in the figure shown below.
  • From the above figure, you can see contact has been changed to normally open contact.
6. Relay Functions
  • Relay has the three basic functions to perform.
  • All of these three functions are provided in the table given in the figure shown below.
  • Air conditioning control (to limit & control a very high power load) are the examples of on/off control of the relay.
  • Limit control includes motor speed control (to disconnect it if it is moving with slow or faster than the desired speed).
  • Test equipment is an example of logic operation, which connects the device with no. of test points.
7. Types of Relays
  • This section will focus on the major types of relays commonly used these days.
  • There are several different types of relays.
  • The basics types are listed in the table given in the figure shown below.
  • Electromagnetic Relay is made up of magnetic, electrical and mechanical components. It has operating coil and mechanical contacts. When AC or DC supply is provided its mechanical contacts get either open of close. An electromagnetic relay is given in the figure shown below.
  • Solid State Relay consists of solid state components. It is used to perform switching operation without any movement in its parts. Its power gain is higher than the electromagnetic relays because it requires low power as in input and provides high power at the output. Solid state is given in the figure shown below.
  • Hybrid Relay is made up of electronic components and electromagnetic relays. Its input part consists of electronic circuitry which performs rectifications tasks. Its output part consist of electromagnetic relay. Hybrid relay is given in the figure shown below.
  • Thermal Relay works on a very simple principle based on heat effect i.e. the rise in ambient temperature changes one position of the contact to another. Mostly it is used for the motor protection purposes. It consists of temperature sensors and control elements. Thermal relay is given n the figure shown below.
  • Reed Relay has two magnetic strips. These strips are known as reed. These are sealed with a glass tube. The reed acts as blade as well as an armature. When magnetic field is applied to the coil. It wraps around the tube and reed start to move to perform the switching operation. Reed relays are given in the figure shown below.
8. Relay Applications
  • Relay has a wide range of application in real life.
  • Some of the major applications are listed in the table given in the figure shown below.
  • Relay can also be used in relay boards for controlling either DC or stepper motor.
  • One relay can control a single device, since two relay module has two relays so it can control two device simultaneously.
  • Two relay board is given in the figure shown below.
  • TV remote is another example of relay applications.
  • TV remote is given in the figure shown below.
  • Relay can also be used in mobile robots to control their motion properly.
  • Visuals for the above step is given in the figure shown below.
9. Relay Simulation in Proteus
  • I have made relay simulation in Proteus ISIS in order get a better idea about it.
  • As the relay is energized, LED will be turned ON.
  • A simple relay simulation in Proteus is given in the figure shown below.
  • I have also made another relay simulation in Proteus ISIS as shown in the figure below.
  • When the relay gets energized, LED will be turned ON, as shown below.
In the tutorial, Introduction to Relay, I have discussed the basics of relay. This is a fully detailed article the basically focuses on the the basics of relay including its pins configurations, its functions, types, working principle and many other things. I hope you have enjoyed the tutorial and I am sure you will appreciate my efforts. If you have any sort of problem you can freely ask us in comments anytime. Our team is always there to help you and to entertain you. I will also try my level best to answer your questions. I will share further interesting topics in my upcoming tutorials. Till my next tutorial, take care and bye :) strong>
Syed Zain Nasir

I am Syed Zain Nasir, the founder of <a href=https://www.TheEngineeringProjects.com/>The Engineering Projects</a> (TEP). I am a programmer since 2009 before that I just search things, make small projects and now I am sharing my knowledge through this platform.I also work as a freelancer and did many projects related to programming and electrical circuitry. <a href=https://plus.google.com/+SyedZainNasir/>My Google Profile+</a>

Share
Published by
Syed Zain Nasir