What if there was a system that could detect fire and immediately signal us through an alarm or a glowing Led or a notification on our mobile phone?
And if the system also notifies us whenever there is a sudden rise in the temperature, wouldn't that be amazing?
We could keep an eye and warn others on time in case there is a possibility of fire. We would be able to save millions of lives as well as expensive infrastructure if we can build and install such a system in schools, offices, colleges, student accommodations, hospitals, nursing care, hotels, supermarkets, data centres, parking lots…in short almost everywhere!!!
Be sure to make all connections (as given in image) before powering ON the Bolt Wi-Fi module.Zoom in for a clear view.
Short Note on each hardware component:
Temperature Sensor, LM35, has the following three pins...
- VCC - connected to 5V of Bolt Wi-Fi module (purple wire)
- Output - connected to A0 (analog input pin) of Bolt Wi-Fi module (blue wire)
- Ground - connected with negative leg of LED on breadboard; indirectly connected to Gnd of Bolt Wi-Fi module (green wire)
Ledhas two pins...
- Positive(longerpin) - connected to GPIO pin 1 of Bolt Wi-Fi module (brown wire)
- Negative(shorterpin) - connected with shorter leg of Buzzer on breadboard; indirectly connected to Gnd of Bolt Wi-Fi module (purple wire)
Buzzerhas two pins as well...
- Positive(longerpin) - connected to GPIO pin 0 of Bolt Wi-Fi module (red wire)
- Negative(shorterpin) - connected to Gnd of Bolt Wi-Fi module (white wire)
The led and the buzzer are connected to the breadboard. All circuit connections are made with the help of jumper wires.
Values recorded by the temperature sensor are read at an interval of 10 seconds. These are analog equivalents of the temperature values of the environment. This analog voltage produced by the LM35 is then given as input to the Bolt A0 pin. The Bolt then converts the analog value into a 10 bit digital value that varies from 0-1023. This digital data is sent to the cloud via Bolt device.
The raw sensor values can be converted into the actual temperature values using the given formula:
temp = (analog_value100)/1023*
In case there is an outbreak of fire, the sensor immediately senses that and turns on the buzzer and the Led. They remain ON until the temperature goes back to normal after which they turn OFF. Along with sound alarm and light signal, a notification indicating the sensor value is received on our mobile phone with the help of Bolt Cloud and Twilio.
The system is designed in such a way that we are instantly informed even in case of a sudden rise in temperature. It uses Z-score analysis to compute bounds for sensor values. If the sensor value extends beyond these bounds, it is detected as anomaly and we receive a message regarding this anomalous behaviour within a few seconds.
Now, let's talk about Z-score a bit more.
- Mn is the mean of 'r' sensor values taken from end.
- Zn is the Z-score calculated as 'C' multiplied with the square root of the mean of the variation of the last 'r' values.
- Tn are the threshold values calculated by adding to and subtracting from the sensor values
We need at least 'r' values to calculate the threshold values. We have to keep changing these parameters 'r' and 'c' till the standard points are within the threshold region and the anomalies are outside this region.
For better understanding, refer to the comments mentioned in the code section.
After making all connections, it's time to power on the BOLT. If you are already familiar with the bolt, feel free to skip this part.
Step 1: First, download the Bolt Iot app. It's available for both Android and iOS. The instructions given below are for Android. iOS can also be used but that will require minor changes.
Step 2: Create a new account on the Bolt Cloud through the Bolt Iot app. Follow the steps given in the mail to activate the Cloud account. Finally, we get this image that tells about the devices that have been configured.
Step 3: Now, setup your bolt device with your Wi-Fi network by clicking on 'ADD DEVICE'. The Bolt device is then powered ON by inserting the Micro USB cable into the USB port provided on the Bolt and connecting the other (bigger) end of the cable to the Android charger or to the laptop.
Step4: Switch OFF the mobile data and switch ON the location service in the mobile if not already and click on the "READY" button. This is required only in the Android App due to APIs by Google. Finally, we get this.
Now, we connect Bolt to our Wi-Fi network.
NOTE: The Wi-Fi network to which Bolt gets connected is 2.4 GHz. Bolt does NOT support 5 GHz Networks at the moment.
The following colour changes are seen on the bolt module:
- Blue light blinking slowly: The bolt's Wi-Fi network has been powered ON. It is ready to be linked via the Bolt app.
- Blue light blinking fast: The bolt is trying to connect to the Wi-Fi network.
- Blue light ON: Finally, the bolt is connected to the Wi-Fi network.
- Green light ON: The bolt is connected with the bolt Cloud.
If there is still any confusion, refer to How to Power ON your Bolt device.
Ssh(login) to the Ubuntu server and follow the below steps to use Bolt Python library in your code.
Step 1: Update the packages on Ubuntu
Execute the command below so that the packages on Ubuntu are updated to the latest version. Do not skip this step or else there can be an error while installing the Boltiot package.
sudo apt-get -y update
Step 2: Install python3 pip3
pip3 is a package manager for python3 used to install and manage packages and python libraries. It is system independent.
Install pip3 using the following command,
sudo apt install python3-pip
Step 3: Installing boltiot library using pip3
sudo pip3 install boltiot
Now we are done with boltiot python library installation.
Twilio is a cloud communications platform as a service (CPaaS) company based in San Francisco, California. It allows software developers programmatically to make and receive phone calls, send and receive text messages, and perform other communication functions using its web service APIs.
Step 1. To create an account on Twilio, go to https://www.twilio.com/
Step 2. Sign up for free on Twilio.
Step 3. Click on Products.
Step 4. Select Programmable SMS and Phone Numbers and click continue.
Step 5. Give a cool name to the project. Project Info is where all the credentials can be found. The image below shows the dashboard of the Twilio account that we just created. Save the account SID (hidden in picture) and authorization token (click on 'view') as these will be used later.
Next, we need to generate a phone number that will be used to send messages to our phone.
Step 6. From the drop-down menu, click Programmable number -> Get Started -> Get Number -> Choose this number
A popup similar to this will appear on screen. Save this number on notepad or somewhere as this will be required later. Click on 'Done'.