Annalie D'Almeida
Published © GPL3+

Smart Fire Alarm

An IoT fire alarm which based on the temperature of surroundings detects a fire then sounds an alarm and sends a SMS alert.

IntermediateFull instructions provided6 hours468

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
Buzzer
Buzzer
×1
Male/Male Jumper Wires
×1
Temperature Sensor
Temperature Sensor
×1

Software apps and online services

SMS Messaging API
Twilio SMS Messaging API
Snappy Ubuntu Core
Snappy Ubuntu Core

Story

Read more

Schematics

Circuit Connections

Shows proper circuit connections.

Code

fire_alarm

Python
The main code to run your IoT smart fire alarm
#Code by Annalie D'Almeida
import conf
from boltiot import Sms, Bolt
import json, time

max_limit = 400

#Fetch your credentials
mybolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)

#Infinite loop to fetch temperature and check with threshold
while True:
    print ("Reading sensor value")
    response = mybolt.analogRead('A0')
    data = json.loads(response)
    print("Sensor value is: " + str(data['value']))
    try:
        sensor_value = int(data['value'])
        if sensor_value > max_limit:
            response1 = mybolt.digitalWrite('0', 'HIGH')
            print(str(response1))
            print("Making request to Twilio to send a SMS")
            temperature = (100*sensor_value)/1024
            response2 = sms.send_sms("Alert!!! The Fire Alarm has been tripped!! The current temperature of the fire is: " +str(temperature))
            print("Response received from Twilio is: " + str(response2))
            print("Status of SMS at Twilio is :" + str(response2.status))
        else:
            response3 = mybolt.digitalWrite('0', 'LOW')
            print(str(response3))
    except Exception as e:
        print ("Error occured: Below are the details")
        print (e)
    time.sleep(10)

conf

Python
Code for storing your credentials.
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'
API_KEY = 'This is your Bolt Cloud accout API key'
DEVICE_ID = 'This is the ID of your Bolt device'

Credits

Annalie D'Almeida

Annalie D'Almeida

2 projects • 2 followers

Comments