Aoishi Das
Published © GPL3+

Intruder Alarm..!!

Security Is Not A Product But A Process

BeginnerFull instructions provided1 hour250
Intruder Alarm..!!

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Breadboard (generic)
Breadboard (generic)
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1
5 mm LED: Yellow
5 mm LED: Yellow
×1
Resistor 100 ohm
Resistor 100 ohm
×1
Resistor 330 ohm
Resistor 330 ohm
×1
Jumper wires (generic)
Jumper wires (generic)
×3

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud

Story

Read more

Schematics

CIRCUIT DIAGRAM

The Red end of the wire is connected with 3.3V pin of the Bolt Wifi Module
The Green end of the wire is connected with A0 pin of the Bolt Wifi Module
The Black end of the wire is connected with GND pin of the Bolt Wifi Module

Code

INTRUDER ALARM

Python
This is the main code for detecting intruders and sending e-mail
import email_conf #Importing the configurtion file
from boltiot import Bolt, Email #Import Email and Bolt class from boltiot library
import json, time

mybolt = Bolt(email_conf.API_KEY,email_conf.DEVICE_ID) #Create object to fetch data from configuration file
mailer = Email(email_conf.MAILGUN_API_KEY,email_conf.SANDBOX_URL,email_conF.SENDER_EMAIL,email_conf.RECIPIENT_EMAIL) #Create object to send EMAIL

while True:
  print("Checking the status")
  response = mybolt.analogRead('A0')  #Fetching the value from BOLTIOT
  data = json.loads(response)
  
  try:
    v=int(data['value'])
    print(v)
    if v<200:
      print("Intrusion detected. Requesting to send email")
      response=mailer.send_email("ALERT","INTRUSION DETECTED")
      response_text=json.loads(response.text)
      print("MAILGUN response is :"+str(response_text['message']))
      
  except Exception as e:
    print("Error occured. The details are as follows")
    print(e)
    
  time.sleep(200)

CONFIGURATION

Python
email_conf.py
MAILGUN_API_KEY = 'This is the private API key which you can find on your Mailgun Dashboard' 
SANDBOX_URL= 'You can find this on your Mailgun Dashboard' 
SENDER_EMAIL = 'This would be test@your SANDBOX_URL'
RECIPIENT_EMAIL = 'Enter your Email ID Here'
API_KEY = 'This is your Bolt Cloud account API key'
DEVICE_ID = 'This is the ID of your Bolt device' 

Credits

Aoishi Das

Aoishi Das

1 project • 0 followers

Comments