hitanshu shah
Published © GPL3+

Bolt IoT Two-Way Locking System

Insecure about your valuables stored inside your vault? Using this Two way security locking system keep your insecurities away.

BeginnerFull instructions provided3 hours499
Bolt IoT Two-Way Locking System

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Infrared (IR) Sensor
You can find this IR sensor also at any local store or from amazon It is used to detect human presence using a transmitter and receiver when it detects an obstacle
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1
LED (generic)
LED (generic)
×1
Buzzer
Buzzer
×1
Resistor 330 ohm
Resistor 330 ohm
×1
Jumper wires (generic)
Jumper wires (generic)
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

mailgun
Windows 10
Microsoft Windows 10
Bolt Cloud
Bolt IoT Bolt Cloud
Bolt IoT Android App
Bolt IoT Android App

Story

Read more

Schematics

Schematic Circuit Diagram

Given below are the circuit connections of IR, LED, Buzzer and LDR with the bolt module for security mechanism

Schematic Circuit Diagram

Circuit Connections

Code

conf.py

Python
This is the configuration code to connect the Bolt WiFi module with the mailgun to send automatic mail when anamoly is detected.
#API_KEY = "your bolt api key"
#DEVICE_ID = "your bolt device id"
#MAILGUN_API_KEY = "your mailgun api key"
#SANDBOX_URL = "your mailgun sandbox url"
#SENDER_EMAIL = "your mailgun sender email"
#RECIPIENT_EMAIL = "your own email"

API_KEY = "8d4cb24f-0b73-4da7-a2d3-11bfe2c66cf7"
DEVICE_ID = "BOLT1115621"
MAILGUN_API_KEY = "df1cceb2d47d439c57637fe8b17ed8de-2b0eef4c-7c37a4f0"
SANDBOX_URL = "sandboxa6e907065efe487b8ddd0afb2e4cb973.mailgun.org"
SENDER_EMAIL = "test@sandboxa6e907065efe487b8ddd0afb2e4cb973.mailgun.org"
RECIPIENT_EMAIL = "hitanshushah10.8@gmail.com"

locker.py

Python
This is the full code to perform the project. This code imports the conf.py file and bolt iot packages along with necessary modules. This code detects the two conditions and detects anamoly accordingly.
import conf
import time, json
from boltiot import Bolt,Email

api_key="8d4cb24f-0b73-4da7-a2d3-11bfe2c66cf7" #your bolt device api key
device_id="BOLT1115621" #your bolt device id

mybolt= Bolt(api_key, device_id)
mailer = Email(conf.MAILGUN_API_KEY, conf.SANDBOX_URL, conf.SENDER_EMAIL, conf.RECIPIENT_EMAIL)

HIGH = 1
LOW = 0

while True:
    value = mybolt.analogRead('A0') #ldr read pin
    parsed_value = json.loads(value)
    response = mybolt.digitalRead(2) #ir read pin
    parsed_response = json.loads(response) 
    print ("Parsed response is")
    print (parsed_response)
    print (parsed_value)
    # {"success": "1", "value": "1"} 
    detection = int(parsed_response["value"])
    light = int(parsed_value["value"])

    if light > 300:
        print ("light detected")
        print ("Sending mail")
        mybolt.digitalWrite('0','HIGH') #led output pin
        mybolt.digitalWrite('4','HIGH') #buzzer output pin
        response = mailer.send_email("Alert","Someone opened the Locker") #automatic email
    elif detection == 1:
        print ("Nothing detected")
        mybolt.digitalWrite('0','LOW')
        mybolt.digitalWrite('4','LOW')
    else:
        print ("Something detected")
        print ("Sending mail")
        mybolt.digitalWrite('0','HIGH')
        mybolt.digitalWrite('4','HIGH')
        response = mailer.send_email("Alert","Someone opened the Locker")
	
        	
    time.sleep(10)

Credits

hitanshu shah

hitanshu shah

1 project • 1 follower

Comments