Omm Prasad Sahu
Published © GPL3+

SMS Safety Alert system using Bolt IoT and Twillio

The main purpose of this project is to send an SMS when someone feels that he/she is in danger.

BeginnerFull instructions provided1 hour811
SMS Safety Alert system using Bolt IoT and Twillio

Things used in this project

Story

Read more

Schematics

Cirrcuit Diagram

Circuit diagram of the project representing the hardware connections.

Code

conf

Python
The code containing the software details, such as api keys and device id etc.
SID = 'ACf8f66f55299142473a1bf300f0c3505a'      #You can find SID in your Twilio Dashboard
AUTH_TOKEN = '7f3ab64b0b1e869cc598c5252d39f6ed' #You can find  on your Twilio Dashboard
FROM_NUMBER = '+12058517537'  #The number from which SMS will be sent
TO_NUMBER = '+917684074560'   #The number to which SMS will be sent.It should be verified before in the twillio site
API_KEY = '400c2ad2-fdff-4e2b-a656-d34fce76826a' #API key of your bolt device
DEVICE_ID = 'BOLT3848039'   #The device id of the bolt device

SMS_Alert

Python
The main code which will be used to turn ON the Buzzer and send SMS.
import conf           #imports the conf.py file
from boltiot import Sms, Bolt    # imports the sms and Bolt module from the boltiot library
import json, time         #imports the json and time module

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.digitalRead('0')      #reads the sensor value 
    data = json.loads(response)
    print(data)  
    print("Sensor value is: " + str(data["value"]) )
    try:
        sensor_value = int(data["value"])    #Converts the data type from str to int
        if sensor_value > 0 :          #checks the condition,if user touches the sensor, it becomes 1 from 0
            mybolt.digitalWrite('1', 'HIGH')    #Enables the buzzer
            print("Making request to Twilio to send a SMS")
            response = sms.send_sms("Alert!!! Someone is in danger. Track this number: XXXXXXXXXX " )   #send sms,number should be provided instead of xxxxxxxxxx
            print("Response received from Twilio is: " + str(sensor_value))
            print("Status of SMS at Twilio is :" + str(response.status))
            time.sleep(10)       #wait for 10 seconds
            mybolt.digitalWrite('1','LOW')     #turns off the buzzer
        else:
            mybolt.digitalWrite('1','LOW')

    except Exception as e:
        print ("Error occured: Below are the details")
        print (e)
    time.sleep(1)

Credits

Omm Prasad Sahu
1 project • 0 followers
Thanks to Mr Pranay Pai Vernekar.

Comments