Adhyoksh Jyoti
Published

Home security with lasers

Protect your home from intruders and get alert in case.

IntermediateProtip2 hours1,629
Home security with lasers

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1
4x4 matrix keypad
×1
Buzzer
Buzzer
×1
Resistor 10k ohm
Resistor 10k ohm
×1
Jumper wires (generic)
Jumper wires (generic)
×15
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
5V DC power supply
×1
Laser Diode, 655 nm
Laser Diode, 655 nm
×1

Software apps and online services

Arduino IDE
Arduino IDE
Bolt Cloud
Bolt IoT Bolt Cloud
SMS Messaging API
Twilio SMS Messaging API
Snappy Ubuntu Core
Snappy Ubuntu Core

Story

Read more

Schematics

Circuit Schematics

Code

Python code

Python
import conf
from boltiot import Sms, Bolt
import json, time


mybolt = Bolt(conf.api_key, conf.device_id)
sms = Sms(conf.sid, conf.auth_token, conf.to_no, conf.from_no)


while True: 
    print ("Reading value from Arduino")
    resp1 = mybolt.digitalRead('1') 
    d1 = json.loads(resp1)
    resp2 = mybolt.digitalRead('2') 
    d2 = json.loads(resp2) 
    resp3 = mybolt.digitalRead('3') 
    d3 = json.loads(resp3)
    print("D1 value is: " + str(d1['value']))
    print("D2 value is: " + str(d2['value']))
    print("D3 value is: " + str(d3['value']))
    try: 
       sens1 = int(d1['value'])
       sens2 = int(d2['value']) 
       sens3 = int(d3['value'])  
       if sens3 == 1 :
             print("Making request to Twilio to send a SMS")
             response = sms.send_sms("Breach!!!! Someone has entered forcefully.")
             print("Response received from Twilio is: " + str(response))
             print("Status of SMS at Twilio is :" + str(response.status))
       elif sens2 == 1 :
             print("Making request to Twilio to send a SMS")
             response = sms.send_sms("Someone is trying to open the door.")
             print("Response received from Twilio is: " + str(response))
             print("Status of SMS at Twilio is :" + str(response.status))
       elif sens1 == 1 :
             print("Making request to Twilio to send a SMS")
             response = sms.send_sms("The door is opened. You can enter now.")
             print("Response received from Twilio is: " + str(response))
             print("Status of SMS at Twilio is :" + str(response.status))

    except Exception as e: 
       print ("Error occured: Below are the details")
       print (e) 
    time.sleep(10)

Arduino Code

Arduino
#include <Keypad.h>

String ch="",pwd="123ABCD4";
const byte rows=4,cols=4;
char keys[rows][cols]={
                      {'1','2','3','A'},
                      {'4','5','6','B'},
                      {'7','8','9','C'},
                      {'*','0','#','D'},
};
byte rpin[rows]={2,3,4,5};
byte cpin[cols]={6,7,8,9};
Keypad obj=Keypad(makeKeymap(keys),rpin,cpin,rows,cols);

int ldr=A0,buzz=10,d1=11,d2=12,d3=13,light,key=0,i,k;
String cmd="";

void setup() 
{
  Serial.begin(9600);
  pinMode(ldr,INPUT);
  pinMode(buzz,OUTPUT);
  pinMode(d1,OUTPUT);
  pinMode(d2,OUTPUT);
  pinMode(d3,OUTPUT);  
}

void loop() 
{
  digitalWrite(d1,0);
  digitalWrite(d2,0);
  digitalWrite(d3,0);
  
  if(Serial.available()>0)
  {
    cmd=Serial.readString();
    Serial.println(cmd);
  }
  if(cmd == "1")
  {
    char temp=obj.getKey();
    if(temp != NO_KEY)
    {
      if(temp != '*')
      {
        Serial.println(temp);
        ch +=temp; 
      }
      else 
      {
        if(ch == pwd)
        {
          digitalWrite(d1,HIGH);
          Serial.println("Access granted");
          delay(10000);
        }
        else
        {
          digitalWrite(d2,HIGH);
          Serial.println("Access Denied");
          cmd="0";
          delay(10000);
        }
      }
    }
  }
  light=analogRead(ldr);
  if(light<300)
  {
    digitalWrite(d3,HIGH);
    for(i=0;i<10;i++)
    {
      digitalWrite(buzz,HIGH);
      delay(500);
      digitalWrite(buzz,LOW);  
      delay(500);
    }
  }
}

HTML code

HTML
<!DOCTYPE html>
<html>
    <head>
        <title>
            Project
        </title>
        <script type="text/javascript" src="https://cloud.boltiot.com/static/js/boltCommands.js"></script>
        <script>
        setKey('{{ApiKey}}','{{Name}}');
        </script>
    </head>
    <body onload="serialBegin(9600)">
        <div style="background-color:red;height:350px;">
            <center>
                <br><br><br><br><br><br><br><br>
                <button onclick="serialWrite('1')">Door opened</button>
            </center>
        </div>
        <div style="background-color:green;height:350px;">
            <center>
                <br><br><br><br><br><br><br><br>
                <button onclick="serialWrite('0')">Door closed</button>
            </center>
        </div>
    </body>
</html>

Credits

Adhyoksh Jyoti

Adhyoksh Jyoti

11 projects • 9 followers
Electronics and Communication Engineering B.Tech graduate from NIT Srinagar, J&K.

Comments