Ishan Binu Sainudeen
Published © GPL3+

Laser Trip Alarm

Wanted to keep your house safe even if you're not at home? Here's your chance.

IntermediateFull instructions provided34
Laser Trip Alarm

Things used in this project

Hardware components

LDR, 5 Mohm
LDR, 5 Mohm
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Buzzer
Buzzer
×1
Through Hole Resistor, 150 ohm
Through Hole Resistor, 150 ohm
×1
Jumper wires (generic)
Jumper wires (generic)
×1
laser pointer
×1

Software apps and online services

Bolt IoT Android App
Bolt IoT Android App
Bolt Cloud
Bolt IoT Bolt Cloud

Hand tools and fabrication machines

Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Wire Stripper & Cutter, 18-10 AWG / 0.75-4mm² Capacity Wires
Tape, Double Sided
Tape, Double Sided

Story

Read more

Schematics

Breadboard connections

They're the breadboard connections.

Bolt module connections

Code

Trip.py

Python
This is the main code
import conf, json, time
from boltiot import Sms, Bolt

minimum_limit = 80
maximum_limit = 136
flag = 0

mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)


while True:
    print ("Reading sensor value")
    response = mybolt.analogRead('A0')
    data = json.loads(response)
    print("Sensor value is: " + str(data['value']))
    try:
        sensor_value = int(data['value'])
        if sensor_value > maximum_limit or sensor_value < minimum_limit:
            print("Making request to Twilio to send a SMS")
            response = sms.send_sms("Someone has entered... Call 100 for police$
            print("Response received from Twilio is: " + str(response))
            print("Status of SMS at Twilio is :" + str(response.status))
            flag = 1
    except Exception as e:
        print ("Error occured: Below are the details")
        print (e)
    time.sleep(4)

conf.py

Python
These are the configurations you will need
SID = 'You can find SID in your Twilio Dashboard' 
AUTH_TOKEN = 'You can find  on your Twilio Dashboard' 
FROM_NUMBER = 'This is the no. generated by Twilio. You can find this on your Twilio Dashboard'
TO_NUMBER = 'This is your number. Make sure you are adding +91 in beginning'
API_KEY = 'This is your Bolt Cloud accout API key'
DEVICE_ID = 'This is the ID of your Bolt device' 

Bolt cloud code

HTML
This is the code that is used in the Bolt cloud. Remember not to change the variable name of apikey and name as it will automatically be taken by the cloud.
<!DOCTYPE html>
<html>
    <head>
        <title>Laser Trip</title>
        <script type="text/javascript" src="https://cloud.boltiot.com/static/js/boltCommands.js"></script>
        <script>
        setKey('{{ApiKey}}','{{Name}}');
        </script>
    </head>
    <body>
        <center>
        <button onclick="digitalWrite(1, 'HIGH');">Spook The Tresspasser</button>
        <button onclick="digitalWrite(1, 'LOW');">OFF</button>
        </center>
    </body>
</html>

Credits

Ishan Binu Sainudeen

Ishan Binu Sainudeen

1 project • 0 followers

Comments