Chetashri Mahajan
Published

Fire_Alert_System

The device which alert us when fire is detected and sends a alert message.

BeginnerFull instructions provided1.5 hours382
Fire_Alert_System

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Temperature Sensor
Temperature Sensor
×1
Buzzer
Buzzer
×1
5 mm LED: Red
5 mm LED: Red
×1
5 mm LED: Green
5 mm LED: Green
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×2
Male/Male Jumper Wires
×7
Breadboard (generic)
Breadboard (generic)
×1
Resistor 10k ohm
Resistor 10k ohm
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1

Software apps and online services

Bolt IoT Android App
Bolt IoT Android App
Bolt Cloud
Bolt IoT Bolt Cloud
SMS Messaging API
Twilio SMS Messaging API
Ubuntu VMware

Story

Read more

Schematics

fire alert system

Code

fire_alert_system.py

Python
import conf                                 #import credential file
from boltiot import Sms, Bolt
import json
import time

mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID) #to connect to bolt device.

sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)  # to send SMS using this info

green_led=mybolt.digitalWrite('0','HIGH')  #To ON green LED, as no fire.

#loop to fetch and detect whether fire or not after every 10 secs 

while True: 
  print ("Reading sensor value")
  response = mybolt.analogRead('A0')   #Get sensor value from bolt device
  data = json.loads(response)
  #loop to compare the temperature if matching with fire's
  try: 
    sensor_value=int(data['value'])
    temperature=(100*sensor_value)/1024             #converting raw temperature      reading to degree Celsius.
    print("Sensor value is: " + str(temperature))
    if temperature>conf.THRESHOLD_VALUE: 
      green_led=mybolt.digitalWrite('0','LOW')   #OFF green LED
      buzzer=mybolt.digitalWrite('2','HIGH')     #ON buzzer
      red_led=mybolt.digitalWrite('1','HIGH')    #ON red LED
      print("FIRE! Making request to send SMS")
      response=sms.send_sms("FIRE!FIRE! GET OUT OF YOUR HOUSE.")       #sending sms
      print("status of sms  is:"str(response.status))
    
    else:
      green_led=mybolt.digitalWrite('0','HIGH')      #ON green LED
      red_led=mybolt.digitalWrite('1','LOW')         #OFF red LED
      buzzer=mybolt.digitalWrite('2','LOW')          #OFF buzzer
  except Expection as e:
    print("error accured:below are the details")
    print(e)
    time.sleep(10)     # time delay of 10 secs
                

conf.py

Python
Replace all credentials with yours.
SID = 'ACecXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'#You can find SID in your Twilio Dashboard 
AUTH_TOKEN ='a528XXXXXXXXXXXXXXXXXXXXXXXXXXXX' #You can find  on your Twilio Dashboard        
FROM_NUMBER ='+120XXXXXXX' #This is the no. generated by Twilio. You can find this on your Twilio Dashboard
TO_NUMBER ='+91810XXXXXXX' #This is your number. Make sure you are adding +91 in beginning
API_KEY ='bf0eaXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' #This is your Bolt Cloud accout API key       
DEVICE_ID ='BOLTXXXXXXX' #This is the ID of your Bolt device 
THRESHOLD_VALUE=40

Credits

Chetashri Mahajan

Chetashri Mahajan

1 project • 0 followers

Comments