Arduino Password Security System With Magnetic Door Sensors

40,220

271

40

Introduction: Arduino Password Security System With Magnetic Door Sensors

In this Instructables guide I will show you how to make your own password security system by using the Arduino uno board and some magnetic door switches. I made my own circuit by using the ATmega328 micro controller but this is an optional step. In this guide I will help you to make it easily on breadboard by using the Arduino uno board, and I will give you some extra tips on how you can make your own Arduino-based custom circuit.

By using this system you will be able to arm and disarm the security system. You can disarm it by typing the correct password and pressing the '*' button. If you want to change the current password, you can do it by pressing the 'B' button, and if you want to skip or abort an operation you can do it by pressing the '#' button. It also has a buzzer for making various tones during operation.

You can arm the system by pressing the 'A' button. System will give you 10 seconds to leave from your place, after 10 seconds the system will be armed. You can put as many windows magnetic switched you want. In this tutorial I will use two for windows and one for door. When a window opens, and the system is armed, you will hear the alarm tone from buzzer. You can still disarmed it by typing the correct password. When a door opens the system will give you 20 seconds to give the correct password. After 20 second you will hear the alarm tone. The system also uses an ultrasonic sensor that can detect motion.

Watch the operation video:

This device was made only for educational and presentation purpose reasons, it can't be used in real life. If you want to use it on your home's make sure that it's enough safe , for example use a metal box and put the power cables "inside the wall".


Let's get started!

Step 1: What You Will Need

For this project you will need:

  • Arduino uno board
  • High contrast LCD display 16x2
  • Keypad 4x4
  • 10~20k potentiometer
  • 3x (or more) magnetic door switch
  • 3x (or more) 2 pins screw driver circuit
  • HC-SR04 Ultrasonic sensor

(ONLY) If you want to make your own custom - Arduino based - circuit you will also need:

  • DIP socket for atmega328
  • 16Mhz crystal osc
  • 2x 22pF ceramic, 2x 0.22uF electrolytic capacitors
  • 1x 10K resistor
  • DC power jack
  • pcb prototyping board
  • 5V power source

And one box to fit them all!

Tools:

  • Something to cur the plastic box
  • Hot glue gun
  • Drill for opening holes on the box

Step 2: The Circuit

The connections are pretty easy, watch the above image with the breadboard circuit schematic.

Some notes:
High contrast LCD:

  • Pin1 - Vdd to GND
  • Pin2 - Vss to 5V
  • Pin3 - Vo (to middle pin of the potentiometer!)
  • Pin4 - RS to Arduino pin 8
  • Pin5 - RW to GND
  • Pin6 - EN to Arduino pin 7
  • Pin11 - D4 to Arduino pin 6
  • Pin12 - D5 to Arduino pin 5
  • Pin13 - D6 to Arduino pin 4
  • Pin14 - D7 to Arduino pin 3
  • Pin15 - Vee (to right or left pin of the potentiometer)

Keypad 4x4:

From left to the right pin:

  • Pin1 to Arduino pin A5
  • Pin2 to Arduino pin A4
  • Pin3 to Arduino pin A3
  • Pin4 to Arduino pin A2
  • Pin5 to Arduino pin 13
  • Pin6 to Arduino pin 12
  • Pin7 to Arduino pin 11
  • Pin8 to Arduino pin 10

Step 3: The Code

Here's the code, embedded using Codebender!

Try downloading the codebender plugin and clicking on the Run on Arduino button to program your Arduino with this sketch. And that's it, you've programmed your Arduino board! If you want to make any changes in the code below just click the "Edit" button.

For example you can change the default password "8520" at line 32.

Note: If you will not use the Codebender IDE for programming your Arduino board you will need to manual install additional libraries in your Arduino IDE. Where to find it? Search the web, don't ask me... Or just use the easy and simple way of Codebender.

Step 4: Make Your Own Custom Arduino - Based Circuit

Now that you have successfully test your new project with the Arduino uno board, you can start making your own Arduino-based custom circuit! The procedure it's easy, but you will need some extras skills for making it.

So, I will try to give you some tips here to try it out by yourself:

  • 10K resistor must be connected between 1st (reset) pin and 7th (Vcc) of the Atmega328 micro controller.
  • 16MHz crystal oscillator must be connected at pins 9 and 10, labeled as XTAL1 and XTAL2
  • Connect to each pin of oscillator one 22pF capacitor. The other pin of capacitors goes to pin 8 (GND) of micro controller.
  • Remember to connect the second power line of the ATmega328 with your power source, pins 20-Vcc and 22-GND.
  • All other information for the Arduino pinout can be found at the second image above.
  • If you will use power source above 6V: Use the LM7805 with two 0.22uF electrolytic capacitors (on input and output pins) to take 5V from your 12V power source. This is important! Do not provide more than 6V on your custom circuit!!! It will burn your Atmega micro controller and lcd circuit.

Step 5: Put It in a Box

Take your time and configure your box to fit your circuit. You can make it as big (or small) you want.

Step 6: Well Done!

That's it! You have successfully completed this guide and now you have your own Arduino security system with password.

You can find more Arduino tutorials and cool projects here.

I hope you liked this, let me know in the comments!

Automation Contest 2016

Participated in the
Automation Contest 2016

Sensors Contest 2016

Participated in the
Sensors Contest 2016

Be the First to Share

    Recommendations

    • Big and Small Contest

      Big and Small Contest
    • Make It Bridge

      Make It Bridge
    • For the Home Contest

      For the Home Contest

    40 Comments

    0
    masher38
    masher38

    11 months ago

    Hi. Not sure if you are still supporting this project. I am in the process of building it - made a few minor changes to accommodate a 3x3 keypad, an I2c display and a relay to power an external siren - and it is all working perfectly. Thank you for an excellent piece of code.
    However, I am struggling with one last bit: here in the UK, burglar alarms are not allowed to sound for more than 20 minutes before resetting (to prevent annoyance to locals). I have tried and tried to figure out a way of doing this, but to no avail - my coding skills are somewhat lacking! Would you be able to help?
    Thanks.

    0
    maxkofe65
    maxkofe65

    Question 2 years ago on Step 1

    Quick question: I'm guessing the "Custom Circuitry" takes up less space than the Uno but is the custom circuitry necessary or is it fine just running the Uno in the box?
    Awesome project though. I'll be testing it with a HC-SR501 PIR.
    Nice work!
    I edited in a delay to allow the alarm to be disabled after entering the premises.
    //Alarm.......................................................................................................
    void alarmFunction() {
    retry: //label for goto
    tempPassword = "";
    lcd.clear();
    i = 6;
    unsigned long previousMillis = 0;
    const long interval = 500; //This is the length of the buzzer "ON" sound.
    boolean buzzerState = false;
    int count = 10;
    //......................................................................................My edit
    delay(9000); //Delays the alarm when entering to allow enough time for Password.This Stops everything!
    //Disable alarm with reset button..............................................................My edit
    1
    oh221663
    oh221663

    Question 2 years ago

    how to adapt I2C and a RIFID with a servo

    0
    angjeleski1
    angjeleski1

    2 years ago

    WOW, This was amazing. I have almost zero knowledge, but managed to adapt i2c display and use the library for it.
    I have question that was asked by few members but not answered.
    I would like to connect siren trough relay. For example, wired to pin 11. Where can i modify the code to activate the siren on Alarm state?

    0
    oh221663
    oh221663

    Reply 2 years ago

    How?, already use this, but I dont know how to put it in this code.
    HELP!!!!

    0
    oh221663
    oh221663

    Reply 2 years ago

    Ohhhh I m using an Arduino Mega

    0
    jisaac6
    jisaac6

    3 years ago

    Hi,
    please team I need your help in detecting why my code is not sending the value of voltage in the sms alert received. Please kindly find below my code, once the threshold is reached, the gsm sends an sms to my line but it does not contain the value of the battery voltage; it only displays 0.0V. please help me fix this:.....................................
    .........................
    #include <SoftwareSerial.h>
    #define LIMIT 23.0 // Change it to your favoured value in Celsius.
    #define NUM_SAMPLES 10
    SoftwareSerial GSMSerial(9, 10);//Connect 9 to TX of GSM and 10 to RX of GSM
    int sum = 0;
    unsigned char sample_count = 0;
    float voltage = 0.0;
    void setup() {
    // Setting up the Arduino.
    GSMSerial.begin(19200); // Setting the baud rate of GSM Module
    Serial.begin(19200); // Setting the baud rate of Serial Monitor (Arduino)
    delay(10000);
    GSMSerial.print("ATE0\r");
    GSMSerial.print("AT+CMGF=1\r");
    delay(1000);
    GSMSerial.println("AT+CNMI=2,2,0,0,0\r");
    delay(1000);
    Serial.println("Finished Setup Section");
    }
    void SendMessage(){
    GSMSerial.println("AT+CMGF=1"); //Sets the GSM Module in Text Mode
    delay(1000); // Delay of 1000 milli seconds or 1 second
    GSMSerial.println("AT+CMGS=\"+2247064309xxx\"\r"); // Replace x with mobile number
    delay(1000);
    GSMSerial.print("POP Battery Bank Voltage is Low: ");// The SMS text you want to send
    GSMSerial.print(voltage,1);
    Serial.println(voltage);
    GSMSerial.println(" V");
    delay(1000);
    GSMSerial.println((char)26);// ASCII code of CTRL+Z
    delay(1000); //give module time to send SMS
    GSMSerial.println();
    Serial.println("Message Sent");
    delay(5000); // give module time to send sms
    }
    void loop() {
    // Arduino does this forever.
    while (sample_count < NUM_SAMPLES){
    sum += analogRead(0);
    sample_count++;
    delay(10);
    }
    float voltage = (((float)sum / (float)NUM_SAMPLES *30)/1024.0)*1.2;
    Serial.print("Battery Voltage is :");
    Serial.print(voltage, 2); //Reading the voltage to 1 decimal point
    Serial.println("V");
    delay (500);
    sample_count = 0;
    sum = 0;
    if(voltage<=LIMIT){
    SendMessage();
    delay(1800000); // wait for 1 Hour
    }
    }

    gsm arduino sms alert.PNG
    0
    HANNAHR80
    HANNAHR80

    4 years ago

    can i include GSM module to this model

    0
    alanisv
    alanisv

    Question 4 years ago on Step 2

    Hola me preguntaba de cuanto es el buzzer que no se indica su valor

    0
    nhattinh92
    nhattinh92

    5 years ago

    Hi there ! How if i want to add 2 pin to active and deactive system ? My mean is pin 12 == High to active, pin 13==High to deactive. I had added code but it's not work. Please help me. Thanks

    0
    KempaSwe
    KempaSwe

    6 years ago

    I can´t upload the code!

    Arduino:1.8.0 (Windows 10), Kort:"Arduino/Genuino Uno"

    C:\Users\kenny\Documents\Arduino\larm\Larm.ino: In function 'void loop()':

    Larm:54: error: 'systemIsArmed' was not declared in this scope

    systemIsArmed(); //Run function to activate the system

    ^

    Larm:57: error: 'systemIsUnarmed' was not declared in this scope

    systemIsUnarmed(); //Run fuction to de activate the system

    ^

    C:\Users\kenny\Documents\Arduino\larm\Larm.ino: In function 'void systemIsUnarmed()':

    Larm:92: error: 'systemIsArmed' was not declared in this scope

    systemIsArmed(); //by calling the systemIsArmed function

    ^

    Larm:99: error: 'changePassword' was not declared in this scope

    changePassword();

    ^

    C:\Users\kenny\Documents\Arduino\larm\Larm.ino: In function 'void systemIsArmed()':

    Larm:144: error: 'alarmFunction' was not declared in this scope

    alarmFunction(); //Call alarm!

    ^

    Larm:147: error: 'unlockPassword' was not declared in this scope

    unlockPassword(); //Disarm the system with correct password

    ^

    Larm:151: error: 'alarmFunction' was not declared in this scope

    alarmFunction();

    ^

    C:\Users\kenny\Documents\Arduino\larm\Larm.ino: In function 'void unlockPassword()':

    Larm:181: error: 'alarmFunction' was not declared in this scope

    alarmFunction(); //Times is up, ALARM!

    ^

    C:\Users\kenny\Documents\Arduino\larm\Larm.ino: In function 'void changePassword()':

    Larm:314: error: 'newPassword' was not declared in this scope

    newPassword(); //Password is corrent, so call the newPassword function

    ^

    exit status 1

    'systemIsArmed' was not declared in this scope

    This report would have more information with

    "Show verbose output during compilation"

    option enabled in File -> Preferences.

    0
    SajjadF
    SajjadF

    6 years ago

    Hey there
    That is a great project, I am gonna add a blutooth HC-05 module to the circuit and send the unlock password with the module's terminal ports so that the alarm would be turned off.
    But I got a problem sending a number through serial ports, I tried some ways But they did not work! Actually my main question is: How To Send The Password By HC-05 module to the system??
    I will be appriciated if anyone can help me.
    Thanks

    0
    MahmoudM116
    MahmoudM116

    6 years ago

    hello

    please tell me how I can make this code that the issuing sound after 5 minutes please and please where I have put the code line

    0
    Kamyk
    Kamyk

    Reply 6 years ago

    Hi. Great project! I have similar question. I wish to activate alarm after 30 sec. When motion will be detected or door will be open I wish to not start alarm or do something in first 30sec. Could you tell me what should I change? Thank you!

    0
    TheKarolukaz
    TheKarolukaz

    6 years ago

    Awesome project!

    I have a question though - how can I add a 5v relay to switch on a powerful buzzer (how to code it)? I tried to change the code but it wasn't successful unfortunately...

    0
    KEITHS123
    KEITHS123

    6 years ago

    AWESOME PROJECT!!! I changed it to a 4X3 keypad, a 20X4 LCD using the I2C library! The most helpful part of the code was your notes on each line of what it is doing in english v.s. code language. You should do more of these!

    0
    DouweK
    DouweK

    6 years ago

    Nice project! But i can't get my LCD working, I've connected all the wires following your instruction ut all i got are questionmarks, degree signs or just white blocks.

    Can you or someone help me?

    Thanks

    0
    Ardumotive_com
    Ardumotive_com

    Reply 6 years ago

    Hi! Do you have a high contrast LCD 16x2 display?

    0
    DouweK
    DouweK

    Reply 6 years ago

    I did some research and it seems that i have a standard LCD while i tought it was a high contrast.
    Do you have a code for the normal LCD?