Kumaresh PV
Published

Blind's Companion

To help the visually impaired with Intruder Detector and alert messaging system with the help of Bolt-IoT, Arduino & Ultrasonic sensor

IntermediateFull instructions provided1,856

Things used in this project

Story

Read more

Custom parts and enclosures

Blind's Companion

The whole procedure of the project. Please check this for understanding and completion of project.

Schematics

Circuit Diagram

The circuit connections is given as per the schematic diagram

Code

Configurations file

Python
Save this file as conf.py
"""Configurations"""  
API_KEY = "This is your Bolt Cloud account API key" This is your Bolt Cloud API Key  
DEVICE_ID = "This is the ID of your Bolt device"# This is the device ID  
TELEGRAM_CHAT_ID = "@XXXX" #This is the channel ID of the created Telegram channel.  
TELEGRAM_BOT_ID = "botXXXXX"    # This is the bot ID of the created Telegram Bot.  
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"
MAILGUN_API_KEY = "This is the private API key which you can find on your MailGun Dashboard" 
SANDBOX_URL = "You can find this on your MailGun Dashboard" 
SENDER_EMAIL = "This would be test@your SANDBOX_URL"
RECIPIENT_EMAIL = "Enter your Email ID Here"

Arduino Code

Arduino
Arduino code for Sensor and Bolt-IoT configuration
#include <Ultrasonic.h>  
Ultrasonic ultrasonic(5, 6);  
int LED = 2;  
int threshold = 100;  
void setup() {  
 // put your setup code here, to run once:  
 Serial.begin(9600);  
 pinMode(LED, OUTPUT);  
}  
void loop() {  
 // put your main code here, to run repeatedly:  
 int distance = ultrasonic.distanceRead();  
 if(distance< threshold)  
 {  
 digitalWrite(LED, HIGH);  
 Serial.println("HIGH");  
 delay(10000);  
 }  
 else{  
 digitalWrite(LED,LOW);  
 }  
 delay(1000);  
}  

Sensor file

Python
Save this as Sensor.py
import requests, json, time, conf
from boltiot import Bolt, Sms, Email  
 
mybolt = Bolt(conf.API_KEY, conf. DEVICE_ID) #Create object to fetch data  
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
mailer = Email(conf.MAILGUN_API_KEY, conf.SANDBOX_URL, conf.SENDER_EMAIL, conf.RECIPIENT_EMAIL)
response = mybolt.serialRead('10')  
print (response)  

def send_telegram_message(message):  
   """Sends message via Telegram"""  
   url = "https://api.telegram.org/" + conf.TELEGRAM_BOT_ID + "/sendMessage"  
   data = {  
      	 "chat_id": conf.TELEGRAM_CHAT_ID,  
      	 "text": message  
          }  
def trigger_integromat_webhook():
       URL = "https://www.integromat.com/" # REPLACE WITH CORRECT URL
       response = requests.request("GET", URL)
       print(response.text)

   try:  
       response = requests.request("POST", url, params=data  )  
       print("This is the Telegram response")  
       print(response.text)  
       telegram_data = json.loads(response.text)  
       return telegram_data["ok"]  
    except Exception as e:  
       print("Error occured: Below are the details")
       print(e)  
       return False  
while True:  
   response = mybolt.serialRead('10')  #Fetching the value from Arduino  
   data = json.loads(response)  
   status_value = data['value'].rstrip()  
   if str(status_value) == 'HIGH':  
       trigger_integromat_webhook()
       print ("Status is", status_value)  
       message = "Some intruder has entered the room"  
       telegram_status = send_telegram_message(message)  
       print("Making request to Twilio to send a SMS")
       response = sms.send_sms("Some intruder has entered the room " +str(sensor_value))
       print("Response received from Twilio is: " + str(response))
       print("Status of SMS at Twilio is :" + str(response.status))
       print("Making request to MailGun to send an email")
       response = mailer.send_email("Alert", " Someone intruder has entered the room" +str(sensor_value))
       response_text = json.loads(response.text)
       print("Response received from Mailgun is: " + str(response_text['message']))

   else:  
        print ("Status is LOW!",status_value)  
   time.sleep(10)  

Credits

Kumaresh PV

Kumaresh PV

1 project • 0 followers

Comments