Introduction
If you think that the internet has changed your life, think again. The Internet of Things is about to change it all over again! - Brendan O’Brien
Learning IoT was an amazing and exciting experience. I had enrolled myself to Bolt IoT's training on IoT and Machine Learning. I learned a lot from it. But the next part was to build an actual project.
So I made this fire alarm, which can be a very important device at home, office or even commercial places, as well as a great application of IoT in Day-To-Day life.
The objectives of this device are:
- To detect fire by sensing the temperature exceed the threshold set.
- To alert the people present in the room or in the vicinity of it by an alarm.
- To alert the concerned person with an automated SMS.
Assumptions
- You are familiar with Bolt cloud and it's features and operation with the module.
- You are well-versed with electronic components and their connections.
- You are familiar with basic Python 3.
- You are familiar with commands in the Bolt library.
- You have downloaded PuTTY.
- You have made a droplet in DigitalOcean website.
- You have a Twilio account and number generated on it.
- You are familiar with Linux commands.
Circuit Diagram
All the components are listed in the components section.
- Take the breadboard, connect the buzzer and temperature sensor on it.
- Make connections such that they match the circuit diagram mentioned above by jumper wires or normal wires.
- Connect the Bolt IoT Module to a power source using the USB cable.
- Make sure the Bolt Module is connected to the cloud.
Login to your Ubuntu server and create a file for configurations. I have named it as conf_project.py.
Now refer the code given below:
SID = 'Given on your Twilio dashboard'
AUTH_TOKEN = 'Given on your Twilio Dashboard'
FROM_NUMBER = 'Number generated by Twilio'
TO_NUMBER = 'The number on which you want the SMS to be sent'
API_KEY = 'Given on your Bolt Cloud'
DEVICE_ID = 'BOLTXXXXXXXX'
Now replace all the credentials with the mentioned information.
Now create another file for the main program. I have named it as fire_alert.py
Refer the code given below.
Main Program
import conf_project
from boltiot import Sms, Bolt
import json, time
maximum_limit = 290
mybolt = Bolt(conf_project.API_KEY, conf_project.DEVICE_ID)
sms = Sms(conf_project.SID, conf_project.AUTH_TOKEN, conf_project.TO_NUMBER, conf_project.FROM_NUMBER)
while True:
print ("Reading Sensor Value.....")
response = mybolt.analogRead('A0')
data = json.loads(response)
print("Sensor Value: " + str(data['value']))
response2 = boltiot.digitalWrite('0', 'LOW')
try:
sensor_value = int(data['value'])
if sensor_value > maximum_limit:
response1 = mybolt.digitalWrite('0', 'HIGH')
print(response1)
print("Making SMS request to Twilio.....")
realTemp = (100*sensor_value)/1024
response = sms.send_sms("Fire alamr has gone off, Temperature: " +str(realTemp))
print("Response recieved from Twilio: " +str(response.status))
except Exception as e:
print("ERROR OCCURRED - DETAILS: ")
print(e)
time.sleep(10)
- Two files are made, one which has all of the details related to Twilio and Bolt like SID, numbers etc.
- The second is the main program which has the code to fetch and process data over the cloud.
- The second program imports all the necessary information needed for the operation.
- You can replace the minimum_limit value with any value you want.
Note: I have not shared the configuration file as it contains some sensitive information like API keys.
STEP- 3 Run The Programtype sudo python3 and the name of your file with the main program on it.
sudo python3 [FileName]
The program will take data every 10 seconds from the temperature sensor and check if it's exceeding the limit set.
The fire alarm is ready.
Future Work
This project works as a demonstration of how IoT can be used for safety systems. This can be modified to an industrial level appliance by:
- Proper circuit assembly with device assembly (Plastic shell to accommodate the circuit and opening for the sensors)
- Smoke sensors and Odour sensors combined with a temperature sensor for better working.
- Dedicated mobile app for setup and convenient operation.
NOTE: Due to COVID-19 lockdown at the time of making this project, some components like smoke sensor were not available. This project works on temperature detection which can be inaccurate sometimes.
Comment below if you have any suggestions or views on this project.
Thank You :)
Comments
Please log in or sign up to comment.