Anushka Choudhary
Published

Fire Alert via SMS using Bolt IoT

An IoT fire alarm based on the temperature of the surroundings detects fire and makes a buzzer sound alarm, sending a SMS alert to the user.

IntermediateFull instructions provided245
Fire Alert via SMS using Bolt IoT

Things used in this project

Hardware components

Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×1
Temperature Sensor
Temperature Sensor
×1
Buzzer
Buzzer
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1

Software apps and online services

Ubuntu Core
Ubuntu Core
Bolt Cloud
Bolt IoT Bolt Cloud
Bolt IoT Android App
Bolt IoT Android App

Story

Read more

Code

Fire alarm code(fire_alarm.py)

Python
#Importing necessary files

import conf
from boltiot import Sms, Bolt
import json, time

#Setting maximum limit for temperature

max_limit = 400

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.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)

credential file(conf.py)

Python
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

Anushka Choudhary
1 project • 0 followers

Comments