Hackster is hosting Impact Spotlights: Smart Home. Watch the stream live on Thursday!Hackster is hosting Impact Spotlights: Smart Home. Stream on Thursday!
Ameya Achrekar
Published

Fire Alert With Buzzer

This Project Is Made To Avoid The Fire Accidents. This Project Will Help Us When There Is Fire In Any Place, Sms Is Sended When There Is Fire

BeginnerFull instructions provided2 hours260
Fire Alert With Buzzer

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Breadboard (generic)
Breadboard (generic)
×1
LED (generic)
LED (generic)
×1
Buzzer
Buzzer
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Flame Sensor
×1

Software apps and online services

Vmware Workstation Pro
Ubuntu Server
SMS Messaging API
Twilio SMS Messaging API
Bolt Cloud
Bolt IoT Bolt Cloud

Story

Read more

Code

Fire Alarm Code In Python

Python
It Is A Python Coding Language I Have Used It In Ubuntu Server OS By Installing VMware Workstation Pro In My Pc
from boltiot import Sms, Bolt
import json, time

SSID = 'YOUR SSID' 
AUTH_TOKEN = 'YOUR TWILIO AUTH TOKEN' 
FROM_NUMBER = 'YOUR TWILIO NUMBER'
TO_NUMBER = 'YOUR PHONE NUMBER'
API_KEY = 'YOUR BOLT IOT API KEY'
DEVICE_ID = 'YOUR BOLT DEVICE ID'


mybolt = Bolt(API_KEY,DEVICE_ID)
sms = Sms(SSID,AUTH_TOKEN,TO_NUMBER,FROM_NUMBER)

while True: 
    print ("Reading sensor value")
    response = mybolt.digitalRead('0') 
    data = json.loads(response) 
    print("Sensor value is: " + str(data['value']))
    try: 
        sensor_value =  int(data['value'])
        if sensor_value==0:
            mybolt.digitalWrite("1","HIGH")
            mybolt.digitalWrite("2","HIGH")
            time.sleep(5)
            mybolt.digitalWrite("1","LOW")
            mybolt.digitalWrite("2","LOW")
            print("Making request to Twilio to send a SMS")
            response = sms.send_sms("Emergency! Flame detected in the room")
            print("Response received from Twilio is: " + str(response))
            print("Status of SMS at Twilio is :" + str(response.status))
    except Exception as e: 
        print ("Error occured: Below are the details")
        print (e)
    time.sleep(10)

Credits

Ameya Achrekar
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.