sai mukesh
Published

A 3-Level Intruder Alert System using Bolt wifi Module

Turn ON the 3 level Intruder Alert system and stop worrying about intruders any more!

IntermediateFull instructions provided553
A 3-Level Intruder Alert System using Bolt wifi Module

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Breadboard (generic)
Breadboard (generic)
×1
LED (generic)
LED (generic)
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1
Buzzer
Buzzer
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Resistor 330 ohm
Resistor 330 ohm
×2
iron scale
×1
wire
×1

Software apps and online services

Bolt Cloud
Bolt IoT Bolt Cloud
Bolt IoT Android App
Bolt IoT Android App
SMS Messaging API
Twilio SMS Messaging API
mailgun
Snappy Ubuntu Core
Snappy Ubuntu Core

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Tape, Double Sided
Tape, Double Sided

Story

Read more

Schematics

circuit

schematic

Code

intruder_alert.py

Python
This is the main program to operate the 3 level Intruder Alert system
import keysandids, json, time#importing all the ids, json to load the content in json format
from boltiot import Email, Bolt, Sms#impoting bolt class, Email for sending mail and Sms for sending sms
mybolt = Bolt(keysandids.bolt_api_key, keysandids.bolt_device_id)#for bolt cloud to identify your device
isOn = myboly.isOnline()#to check the status of the system
print(isOn)
c = 0#this constant is used to turn off the buzzer
if isOn[-2] == '1':#isOn[-2] gives 1 if the system is online and 0 the other case
	print("Turning ON Intruder Alert System")
	mybolt.digitalWrite('0', 'HIGH')#to turn on the LED
	while True:
		if c >= 2:#to turn off the buzzer after 20 sec
			print("Turning Alarm OFF")
			mybolt.digitalWrite('1', 'LOW')
			c = 0
		elif c == 1:
			c = c + 1
		response = mybolt.analogRead('A0')#getting response from the bolt A0 pin
		data = json.loads(response)
		try:
			light_intensity = int(data['value'])
			if light_intensity < 1024:#if the LED is turned off
				c = c + 1
				print('Intruder Detected')
				print('Turning ON ALARM')
				mybolt.digitalWrite('1', 'HIGH')#turns on the buzzer
				print('Alerting through SMS and Mail')
				sms = Sms(keysandids.twilio_sid, keysandids.twilio_auth_token, keysandids.from_number)#passing the parameters required to send sms
				response = sms.send_sms("Alert!There's an Intruder in the house")#sends the msg as Alert! theres an Intruder in the house
				print('Status of SMS at twilio is '+ str(response.status))
				mailer = Email(keysandids.mailgun_api,keysandids.mailgun_domain_name,keysandids.sender_mail, keysandids.rec_mail)#passing the requiresd info to send mail
				response = mailer.send_email('Alert!',"there's an intruder in the house")#getting the response
				response_text =json.loads(response.text)#loading response json format
				print('Status of Mailgun is '+str(response_text))#printing the status of the mail
		except Exception as e:
			print('An Error Occured')
			print(e)
		time.sleep(10)
else:
	print('The Intruder Alert system is OFFLINE')

keysandids.py

Python
This code has credentials like api ids, device ids etc
	bolt_api_key="XXXXXXXXXXXXX"
	bolt_device_id="BOLTXXXXXX"
	twilio_auth_token="XXXXXXXXXXXXXX"
	twilio_sid="XXXXXXXXXX"
	from_number="XXXXXXXXXX"
	mailgun_api="XXXXXXXX"
	mailgun_domain_name="XXXXXXXXXXX"
	sender_mail="XXXXXXXXXX"
	rec_mail="XXXXXXXXXXX"

Credits

sai mukesh

sai mukesh

1 project • 1 follower

Comments