IOT Based Home Automation System

296
IOT Based Home Automation System

Components Used

Powered byMouser Electronics
  • Bluetooth Module HC-05

    Bluetooth is a wireless communication protocol used to communicate over short distances. It is used for low power, low cost wireless data transmission applications over 2.4 – 2.485 GHz (unlicensed) frequency band.

    713-113020008

  • 360 Servo Motor AC/DC

    AC, DC & Servo Motors Parallax Feedback 360 Servo

    619-900-00360

  • PIR Sensor

    PIR motion sensors sense the Infrared signal radiated from moving objects including human or animal body. It is generally used to detect the presence of human or animal motions.

    474-SEN-13968

  • Arduino UNO

    Arduino UNO

    782-A000073

  • Screw

    Screw

    × 1

    Screws & Fasteners TAPTITE SCREW

    568-B-SCREW-1-8

  • Wire

    Wire

    × 1

    Hook-up Wire 788133 RED 100 FT

    602-788133-100-03

  • Buzzer 5V

    Buzzer 5V

    485-1536

  • Red LED 5mm

    Standard LEDs - Through Hole Red Round

    941-C503CRCSCYAZAAA2

  • Green LED 5mm

    Standard LEDs - Through Hole LED HIGH BRIGHTNESS

    755-SLA580ENT3F

  • USB type A Connector USB 2.0

    USB Connectors USB 2.0 type A plug 4 pin Horizontal TH

    490-UP2-AH-4-TH

  • DC Toy or Hobby Motor

    Adafruit Accessories DC Toy/Hobby Motor 130 size

    485-711

  • SPDT Slide Switche

    Slide Switches Large-sized Type 1P2T

    113-LSSA12VB

  • Epoxy glue

    Chemicals Scoth-Weld Epoxy Adhesive DP2216, Gray, 41.5mL Duo-Pak

    517-7100262036

  • Insulation Tape

    Adhesive Tapes 3M Temflex Vinyl Electrical Tape, 3/4in x 60ft x .006in, Black. Sold per Roll

    517-165

  • White LED 5mm

    Standard LEDs - Through Hole 5mm Thru Hole LED White for 12VDC

    593-LTH5MM12VFR4400

  • CARDBOARD-BOX

    Printers BLUEMARK X1 CARDBOARD-BOX

    651-5147528

  • metallic wire

    × 1

    to make the spring for the DIY switching mechanism

  • spring

    × 1
  • hinge

    × 1

    to hold the door in place

  • nails

    × 1

    to join the wooden walls and ply wood together

  • Plywood

    × 1

    it will help us to learn quickly

Making of the support structure

It has two compartments to represent a house with two rooms. The walls are made from plywood and the corners are made from wood for strength and stability. Joining of the wooden structures was made possible by use of nails.

Placing of sensors and other components

I used epoxy hardener to mount all the components onto the house. Insulating tape was used to cover all the wiring so as to improve it's appearance. Wires converge onto the Arduino UNO to their respective pins according to the circuit diagram;

Programming of the Arduino UNO:

#include <Servo.h>

#define SittingledPin 7 // LEDs for living room
#define BedroomledPin 8 //LEDs for Bedroom
#define SecurityledPin 13 // LED for security light
#define DoorPin 11 //servo_motor
#define Passcodecorrectled 12 //greenLed for correct passcode
#define Passcodeincorrectled 9 //redled for incorrect passcode
#define ACPin 10 //DC_motor
#define buzzerpin 4 // buzzzer for alarm
#define windowalert A3 //contact_for_window
#define intruderled 2 //redled_for_window

Servo myServo;

int state = 0;

void setup() {

  pinMode(windowalert, OUTPUT); //making window pressure sensor input
  digitalWrite(windowalert, HIGH);

  pinMode(SittingledPin, OUTPUT); // making living room LEDs ouput
  digitalWrite(SittingledPin, LOW);

  pinMode(BedroomledPin, OUTPUT); // making Bedroom LEDs ouput
  digitalWrite(BedroomledPin, LOW);

  pinMode(SecurityledPin, OUTPUT); // making Securitylight LEDs ouput
  digitalWrite(SecurityledPin, LOW);

  pinMode(DoorPin, OUTPUT); // making servo motor connected to door ouput
  digitalWrite(DoorPin, LOW);

  pinMode(buzzerpin, OUTPUT); // making buzzer pin ouput
  digitalWrite(buzzerpin, LOW);

  pinMode(intruderled, OUTPUT); // making LED for window trigger alert ouput
  digitalWrite(intruderled, LOW);

  pinMode(Passcodecorrectled, OUTPUT); // making correct password LED ouput
  digitalWrite(Passcodecorrectled, LOW);

  pinMode(Passcodeincorrectled, OUTPUT);// making incorrect password LED ouput
  digitalWrite(Passcodeincorrectled, LOW);

  pinMode(ACPin, OUTPUT); // making air conditioner(DC motor) pin ouput
  digitalWrite(ACPin, LOW);

  Serial.begin(9600);
  myServo.attach(DoorPin);
}

void loop() {

  if(Serial.available() > 0){
    state = Serial.read();
  }

   if (state == '0'){ //if bluetooth module receives number 0
    digitalWrite(SittingledPin, LOW);   //turn OFF living room LEDs
    Serial.println("LED: OFF");
    state = 0;
   }
   else if(state == '1'){   //if bluetooth module receives number 1
    digitalWrite(SittingledPin, HIGH);  //turn ON livingroom LEDS
    Serial.println("LED: ON");
    state = 0;
   }

   else if (state == '2'){   //if bluetooth module receives number 2
    digitalWrite(BedroomledPin, LOW);//turn OFF BEDroom LEDS
    Serial.println("LED: OFF");
    state = 0;
   }
   else if(state == '3'){   //if bluetooth module receives number 3
    digitalWrite(BedroomledPin, HIGH);//turn ON BEDroom LEDS
    Serial.println("LED: ON");
    state = 0;
   }
   
   else if(state == '5'){   //if bluetooth module receives number 5
    digitalWrite(SecurityledPin, HIGH); //turn ON Security light LEDS
    Serial.println("LED: ON");
    state = 0;
   }

   else if(state =='6'){
    myServo.write(135); //make servo motor rotate anticlockwise
    delay(200);

    myServo.write(90); //make servo motor stop rotating
    state = 0;
   }
   
   else if(state == '7'){   //if bluetooth module receives number 7
    digitalWrite(Passcodecorrectled, HIGH); //turn ON correct passcode LED
    digitalWrite(buzzerpin, HIGH); //turn ON buzzer
    delay(700);
    digitalWrite(Passcodecorrectled, LOW); //turn ON correct passcode LED
    digitalWrite(buzzerpin, LOW); //turn OFF buzzer
    delay(200);
   
    myServo.write(45); //make servo motor rotate clockwise
    delay(200);

    myServo.write(90); //make servo motor stop rotating
    state = 0;
   }

   else if (state == '8'){  //if bluetooth module receives number 8
    digitalWrite(ACPin, LOW); //turn off DC motor
    Serial.println("AC: OFF");
    state = 0;
   
   }
   else if(state == '9'){   //if bluetooth module receives number 9
    digitalWrite(ACPin, HIGH);   // turn ON DC  motor
    Serial.println("AC: ON");
    state = 0;
   }

   else if(state == '4'){   //if bluetooth module receives number 10
    for(int x=0; x<3; x++){
    digitalWrite(Passcodeincorrectled, HIGH); //turn ON incorrect passcode LED
    digitalWrite(buzzerpin, HIGH);
      delay(250);
    digitalWrite(Passcodeincorrectled, LOW); //turn OFF incorrect passcode LED
    digitalWrite(buzzerpin, LOW);
    }
    state = 0;
   }
}

How the device works

By clicking the Connect icon, I connect my device to my system via my blue-tooth module.

Sitting button - this, when clicked, send a command to my Arduino to light the LEDs connected to the sitting room area.

Bedroom button - this, when clicked, send a command to my Arduino to light the LEDs connected to the Bedroom area.

Keypad - this allows the user to input a password to open the door

Open icon -this, when clicked, send a command to my Arduino to open the door (turn servo motor counterclockwise) and light the green LED and also activate the buzzer simultaneously only after the correct password has been put, otherwise the door won't open and the red LED will blink three times with 250ms delay, also the buzzer will buzz three times simulataneously.

 

A/C - this, when clicked, send a command to my Arduino to rotate the DC motor.

 

Here's a demonstration of the project (YouTube link):

Comments0

Join the discussion — share a question or tip.

Be the first to share your thoughts on this project.