LPG gas leak alarm

0 27096 Medium

Are you tired of constantly worrying about potential gas leaks in your home or office? Look no further than our revolutionary LPG gas leak a

 

LPG gas leak alarm

Things used in this project

 

Hardware components

HARDWARE LIST
1 DFRobot Gravity: Analog Propane Gas Sensor (MQ6) For Arduino
1 Bolt IoT Bolt WiFi Module
1 Arduino UNO
1 Buzzer
1 Jumper wires (generic)
1 Breadboard (generic)

Software apps and online services

 

Bolt IoT Bolt Cloud

 

Arduino IDE

 

Python 3.6 IDLE

 

Integromat

 

bubble.io

Story

 

INTRODUCTION

 

Fire detectors are crucial in various settings such as businesses, shops, shopping centers, private complexes, and parking areas as they play a vital role in identifying fire or smoke at an early stage, potentially saving lives. These detectors typically have an alert system that uses a buzzer or siren to signal the presence of fire. I have developed an IoT-based fire warning system that utilizes temperature and smoke sensors to not only detect the presence of fire but also send related data through IoT, providing timely and accurate information to prevent further damage.

 

It’s good to have some information as early as possible rather than afterward. The Fire can burn your house your office or any other place. Here is the solution we are going to build it for now. So it’s a simple thing anywhere if fire caught then that generates so much of smoke right and a very steep rise in temperature. Also, an LPG gas leakage in our home can cause a blast if happen. So whenever any of this going to happen it will notify us to do something to protect our selves. Also, we can initiate a siren to create an alert.

 

This project has some basic functionality as detecting the temperature and smoke rise in a place. Also, using both data in combination we can figure out the leakage of LPG gas. whenever any such condition occurs using Z-score analysis we receive the alert through notification and text message. Those messages have the information on what event had happened that can be a fire detection or only smoke or it’s an LPG gas leakage. We get to know through notification and text message. Besides with those alert, we receive a web app to control the siren to alert people around.

 

 

 

demo:

 


 

HARDWARESETUP

Note: For every code upload on Arduino IDE you should have to disconnect the TX and Rx pin else it will result in an error. Also, we are using the analog pin of MQ-6 sensor don’t use the digital pin leave it blank. And don’t forget to combine the ground of both boards if you use any other connection type.

 

SOFTWARESETUP

 

There is a simple code in the setup we are calling Serial to run on 9600 baud rate. And then taking the input using analogRead() for pin A0 and A1 of Arduino.

 

Note: If you want to use the graphs in your project you can go through these links:https://github.com/Inventrom/boltiot-arduino-helper..

 

Once you can run the Arduino code then we want a python ide to write the code. You can write either in a virtual machine or your raspberry pi or in windows. I’m using it in windows Python 3.6 IDLE. You can download and read documentation to install on your system https://www.python.org/..

 

About libraries we are using external boltiot and requests library only. you can install both of them using pip command on terminal or cmd. For windows you can learn how to do this https://www.liquidweb.com/kb/install-pip-windows/

 

conf2.py 

Apart from main code, we are also going to make one more python file i.e. configuration file where we are mentioning the bolt API key and the device id also we mention the frame rate and multiplication factor for z- analysis.

CODE
API_KEY = "XXXX"        //Bolt Cloud
API KeyDEVICE_ID = "BOLTXXXX"    //Device ID of the Bolt Module
FRAME_SIZE = 10        //Frame Size for Z score analysis
MUL_FACTOR = 1         //Multiplication factor for Z score analysis

You can find both API Key and Device ID on your bolt cloud account.

 

main.py 

Now for the main code, the logic is we have to fetch data from bolt serial so we are using the functioning bolt.serialRead('1') but going through the documentation I found that value is 10 instead of 1. Actually while using the value 10 the fetching data is not instant. While using 1 it’s an instant data fetched but with a drawback i.e. in the first iteration it will fetch a bunch of combined data. After getting the data from serial we have to make it in the correct form in my case I’m getting data as {‘value’:’546\n45\n’, ’ success’:’1’} so I need to extract it. So I first converted it into JSON data then using list(data['value'].split("\n")) I get the list so at index 0 I have sensor value of first and at index 1 it’s for the second one.

 

Detection of alert

 

The assessment of the Z-score is used to detect anomalies. The anomaly here implies that the value of a variable (temperature or gas value) exceeds a certain value variety. The value range is referred to as boundaries (upper and lower bound). We use the upper limit only to detect the fire warning. The input values, frame size, and multiplication factor are used to calculate these boundaries. The frame size is the minimum number of input values needed for the Z-score analysis and the multiplication factor determines the proximity of the bounds to the input values curve.

 

 

Given above is the formula to calculate the bounds. Here the input is represented as 'Vi', 'r' denotes the frame size and 'C' is the multiplication factor. Firstly we calculate the mean (Mn) of the input values (for every new input, the mean is calculated again). But wait we have 2 sensor value that means we have to use if the statement of other sensors. Or for both sensor, we have to analyze it separately. We can do it in a better way we can add up the sensor value and then go for analysis. The variation of input value (from the mean) is given as (Vi - Mn)^2. The Z-score (Zn) is calculated as shown above ( square root of the mean of the variation of each input value multiplied by the multiplication factor). The bounds are represented as 'Tn' and the upper bound is calculated as (Vi + Zn) and the lower bound is calculated as (Vi - Zn).The frame size and multiplication factor are determined using the trial-and-error method.

 

So for combined analysis, we have to match the data rise accordingly it will not work if our one data is a rise in multiple of 10 and other in multiples of 1.

 

You have to make them a little bit closer. Let suppose in this project the temperature rise in multiple of 1 i.e. 34, 35, 36 but gas sensor rise as 100, 120, 150 so we going to multiply the temperature data to a constant according to our project.

 

Alert sending to devices

 

Now when we have calculated the upper bound we are going to compare it with a combined value that is the sum of both sensor value. If it is an anomaly we will call the alert function. And through that, we will make a web request for integromat scenario. Which will send the notification and text message to our device which generates the current situation according to the condition mentioned in the scenario.

 

Integromat Flow

 

 

You can find the link for making web request trigger while clicking on the webhook and copy the address and past it in the main.py code. Also with every node there is a online help hypertext so you can refer from it how to use as shown above.

 

The conditions are if temperature>40 then it’s a fire alert if temperature <40 and the gas value >350 then it’s LPG leakage. And if the temperature <40 and 150<gas value<350 then it’s smoke call and if any condition doesn’t satisfy then it’s an anonymous call. Along with all these message and notification we are sending the web app which can control the siren to initiate and alert people nearby.

 

Controlling Siren/Buzzer

 

The web app is being designed with the bubble.io. It’s a very reliable and easy to make any web with free hosting. I have used the template of the bolt by Yashwant naik and then modified it according to project need. You can go through the detailed documentation from https://docs.boltiot.com/docs/introduction-1

 

 

A web app to control pin

 

 

It will notify if your device is offline.


 

Schematics

 

Code

 

icon Fire-and-LPG-Leakage-Alert-Using-Z-score-Analysis-and-Machine-learning-master.zip 5KB Download(1)

The article was first published in hackster, February 6,  2023

cr: https://www.hackster.io/aravindreddy3239/lpg-gas-leak-alarm-d66d1c

author: Aravind Reddy

License
All Rights
Reserved
licensBg
0