Rohit Kumar
Published

Intrusion Alert System using Arduino and Bolt IoT

Get an Email and Sms on your mobile and sound alert whenever someone enters in your room.

IntermediateFull instructions provided1 hour5,412
Intrusion Alert System using Arduino and Bolt IoT

Things used in this project

Story

Read more

Schematics

Final Circuit Diagram

Code

Python Code for SMS and Email.

Python
import  json, time, requests
from boltiot import Sms, Bolt
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

email = ''
password = ''
send_to_email = ' '
subject = 'intrusion'
message = 'Someone Entered !!'

msg = MIMEMultipart()
msg['From'] = email
msg['To'] = send_to_email
msg['Subject'] = subject

msg.attach(MIMEText(message, 'plain'))

SID=" "
AUTH_TOKEN=" "
FROM_NUMBER=" "
TO_NUMBER=" "

sms = Sms(SID, AUTH_TOKEN, TO_NUMBER, FROM_NUMBER)

while True:
    response = requests.get('http://cloud.boltiot.com/remote/e0f2449f-c1b0-483c-8bd8-f4ba5fc32a89/digitalRead?pin=0&deviceName=BOLT6094123')
    data=json.loads(response.text)
    print(data)
    sensor_value = int(data['value'])
    if sensor_value == 1:
        print("MOTION DETECTED")
        print("sending SMS")
        server = smtplib.SMTP('smtp.gmail.com', 587)
        server.starttls()
        server.login(email, password)
        text = msg.as_string()
        server.sendmail(email, send_to_email, text)
        sms.send_sms("SOMEONE ENTERED")
        server.quit()
    elif sensor_value ==0:
        print("SENSOR IS READY")
    time.sleep(5)

Arduino Code

C/C++
void setup() {

  pinMode(2, INPUT); //Pin 2 as INPUT

  pinMode(3, OUTPUT); //PIN 3 as OUTPUT

}


void loop() {

  if (digitalRead(2) == HIGH) // check if PIR is triggered.

  {

  digitalWrite(3, HIGH);   // turn the LED/Buzz ON

  delay(100);                       // wait for 100 msecond

  digitalWrite(3, LOW);   // turn the LED/Buzz OFF

  delay(100);                       // wait for 100 msecond

  }

}

Credits

Rohit Kumar

Rohit Kumar

1 project • 5 followers
Thanks to Rohit9924.

Comments