Where do you keep your valuable stuffs ? Obviously the answer to this question is a "Locker". A locker is a place where all your stuffs remains secured and safe and they are protected with the help of key. Nowadays many password protected safe lockers are available but all these lockers have the same purpose to keep your valuables secured. But still many robberies happen where intruders break through the lock and steal everything. So have you ever wondered what more can be done to provide additional security from the intruders? That's what this project is all about - "TwoWayLockingSystem".
1. Introduction:This project is based on the concept of Internet of Things. This project is a system which keeps your locker secured from robbers and your valuables safe. It provides two step security mechanism :-
- Most of the robbers use torches to unlock the door so if someone uses torch to unlock the door, the system will detect the torch and the alert mechanism will start
- If robbers somehow break into the door in dark without using torch or any alert detected then as soon as they enter into the locker for robbery the system will detect it and start the alert mechanism
Alert mechanism:- Led will glow along with the buzzer which you can keep anywhere in your house
What if nobody is at home? You will also get notified via mail message if someone breaks or attempt to break your locker
Also you can control the security mechanism manually using mobile or web page in case some known person opens the locker when the system is running.
2. Demonstration:3. Components required:- Bolt WiFi Module
- Infrared(IR) Sensor
- Light-Dependent Resistor (LDR)
- LED bulb
- Buzzer
- Resistor (330 ohm)
- Breadboard
- Connecting Wires
(use breadboard whenever required) In these we use Bolt WiFi module for connections.
- LDR : Insert one end of LDR to A0 (analog pin) and other end to 3v3 pin.
- IR Sensor: Connect VCC pin to 5V pin, GND pin to ground pin, OUT pin to any of the digital pin (0, 1, 2, 3, 4)
- Resistor: Insert one end to A0 (analog pin) where one end of LDR is connected and other pin to ground pin. Note: The resistance across LDR changes with change in light intensity falling on it. Since the Bolt Module cannot read resistance values, but it can read voltage values, hence a voltage divider circuit is made.
- LED bulb: Connect negative pin (short end) to ground pin and positive pin (long end) to any of the digital pin (0, 1, 2, 3, 4) Note: Don't connect it where you have already connected any other pin.
- Buzzer: Connect negative pin (short end) to ground pin and positive pin (long end) to any of the digital pin (0, 1, 2, 3, 4) Note: Don't connect it where you have already connected any other pin.
This system works on two main concepts and protects your locker in two-ways.
1. if someone uses torch to unlock the door: For this we use LDR, LDR is light dependent resistor which detects the intensity of light and send it to cloud. We set fixed intensity of light which is less than the intensity of the torch light. So when the intensity increases that is if someone uses torch to open the door locker, the increase in intensity of light is detected by the LDR and if it is more than the set limit then the security mechanism is activated.
2. if someone opens the locker door in dark without using the torch: For this we use IR sensor, Infrared Sensor is a sensor that detects if any obstacle is present in front of it, it sends the infrared rays with the transmitter and receiver receives the rays if there is human presence. This ir sensor is kept just inside the door and the valuable items can be kept behind it, so when someone enters into the locker, it is detected by the ir sensor which the activates the alert mechanism.
Alert Mechanism:- When the anomaly is detected by any of the above two conditions then it sends it signals to led and buzzer and then led starts glowing along with the buzzer and automatic mail is sent to the owner.
- Complete you circuit connections as given in Point 4. and keep it ready for implementation.
- Connect your Bolt Device to the Bolt Cloud as per instructions given at https://trainings.boltiot.com/. and check if the status of your device is online. (if device show's offline try troubleshooting the problems as given by https://trainings.boltiot.com/.
- Create new product on bolt cloud and link it with your bolt device and make sure if is online.
- Write code for your device to create a manually controlled web page.
<!DOCTYPE html>
<html>
<head>
<title>Bolt IoT Platform</title>
<script type="text/javascript" src="https://cloud.boltiot.com/static/js/boltCommands.js"></script>
<script>
setKey('{{ApiKey}}','{{Name}}');
</script>
</head>
<body bgcolor="lightcyan">
<h1 align="center"> Two Way Locking System</h1>
<br>
<center><h2 font size=40px>Led Controller</h2>
<button onclick="digitalWrite(0, 'HIGH');">ON</button>
<button onclick="digitalWrite(0, 'LOW');">OFF</button>
</center>
<br>
<br>
<center><h2 font size=40px>Buzzer Controller</h2>
<button onclick="digitalWrite(4, 'HIGH');">ON</button>
<button onclick="digitalWrite(4, 'LOW');">OFF</button>
</center>
</body>
</html>
- Create an account on mailgun (https://www.mailgun.com/) and get necessary credentials. You can follow steps given on https://trainings.boltiot.com/.Note: Use (test@your sandbox url) for senders email.
- Write Configuration Code to connect your bolt device to mailgun and save it as conf.py.
#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"
- Write complete code for your working of the system based on your required conditions and save it as locker.py
import conf
import time, json
from boltiot import Bolt,Email
api_key="8d4cb24f-0b73-4da7-a2d3-11bfe2c66cf7"
device_id="BOLT1115621"
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')
parsed_value = json.loads(value)
response = mybolt.digitalRead(2)
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')
mybolt.digitalWrite('4','HIGH')
response = mailer.send_email("Alert","Someone opened the Locker")
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)
- Finally check all the connects and device status, if everything seems proper the try and implement your code.
MailOutput:
Comments