Design of IoT Based Gas Leakage Detection Andsafety System
Design of IoT Based Gas Leakage Detection Andsafety System
College of Engineering
Prepared by:
Supervised by:
March 2022
استهالل
I
DEDICATION
II
ACKNOWLEDGEMENT
Thanking Allah before and after... First and foremost; the greatest
thanking to our teachers for their continuous support... and for their great
efforts, they were the best guide and monitor... Finally; thanking our
colleagues and workers at the College of Engineering for their
cooperation...
III
ABSTRACT
IV
المستخلص
إٌ ألَظًة اكتشبف انحشائك و انغبصات انًتسشبة دوس يهى فً انحفبظ عهى األسواح
وانًًتهكبت و انحفبظ عهى بٍئة آيُة و يشالبتهب .هزا انًششوع ٌُبلش أنٍة تحكى األسدوٌُى
ببعط انعُبصش الكتشبف انحشائك و انغبصات انًتسشبة ,هزا انُظبو رو استجببة سشٌعة نحبالت
انحشائك و انغبصات انًتسشبة عٍ طشٌك استخذاو حسبسبت حشائك و غبصات ,عُذيب تستشعش
هزِ انحسبسبت ٌمىو انُظبو بئغالق يفتبح تأيٍٍ انغبص ,و تشغٍم يشاوح شفط انهىاء نتمهٍم
تشكٍض انغبص انًتسشة أو دخبٌ انحشائك ,و يٍ ثى تشغٍم َظبو اإلَزاس انزي ٌتضًٍ شبشة
تعشض انحبالت انطبسئة .فً حبنة تسشة انغبص ٌتهمى انًسؤول سسبنة َصٍة تُبٍهٍة ,أيب فً
حبنة انحشائك ٌتهمى يكبنًة هبتفٍة.
V
CONTENTS
Title Page
استهالل I
Dedication II
Acknowledgement III
Abstract IV
انًستخهص V
Contents VI
Chapter One 1
Introduction 1
Preface 1
Critical Systems 2
Safety Critical 2
Business Critical 2
Mission Critical 2
Security Critical 3
Problem Statement 3
Proposed Solution 3
The Objectives 3
Methodology 4
Thesis layout: 4
VI
Chapter Two 5
2.1 Background 5
2.3.2 Detectors 9
2.4.8 Relay 19
2.4.11 Buzzer 22
Chapter Three 33
Methodology 33
3.1 Overview 33
3.2 Simulation 34
Chapter Four 41
System result 41
4.1.4 No Detection 43
4.2 Results 44
Chapeter Five 48
5.1 Conclusion 48
5.2 Recommendation 48
References 49
Appendix A
LIST OF TABLES
Title Page
VII
LIST OF FIGURES
Title Page
VIII
Figure 2-22: The Cloud 25
INTRODUCTION
Preface
1
leakage[1]. And another instance, the HPCL refinery disaster destroyed
the lives of many families.
Critical Systems
Safety Critical
Business Critical
Mission Critical
2
Security Critical
Safety critical systems (SCS) are systems designed with the intent
of curbing the effects of an accident from a hazardous event. This can be
implemented in the aviation industry, the medical profession.
Problem Statement
The gas and fire safety system in Saria batteries factory which
uses different toxic gases that can result in a hazardous work
environment if a gas leakage due to creaks in pipelines or old valves in
gas cylinders occurred, it can also lead to explosions when exposed to
heat or sparks, which could result in great losses both material and
human lives.
Proposed Solution
The Objectives
1- activate the safety system to reduce the leakage gas and fire
accident by implementing gas concentration detection and fire
detection
3
Methodology
Thesis layout:
Chapter one gives a general overview for the system, this chapter
also includes the problem statement, objectives and the methodology
which was followed to solve the research problem. Chapter Two gives a
summary of the background and the related literature up to the state-of-
the-art regarding the problem and its possible solutions. Chapter Three
shows the methodology and simulation setting up. Chapter Four involves
the results which are analyzed and interpreted to evaluate the proposed
algorithms and the system performance. Finally, Chapter Five the thesis
is concluded in the conclusion along with suggestions for further future
research.
4
CHAPTER TWO
2.1 Background
5
2.2 Safety Critical System
6
Typical Action from PSD Systems:
The safety shutdown system (SSS) shall shut down the facilities to
a safe state in case of an emergency situation, thus protecting personnel,
the environment and the asset. The safety shutdown system shall manage
all inputs and outputs relative to emergency shutdown (ESD) functions
(environment and personnel protection). This system might also be fed
by signals from the main fire and gas system. it has two types:
7
Typical Actions from an Emergency Shutdown System:
Alarm systems used in factories are part of the safety systems, the
alarm System consist of:
8
the necessary warning sirens and carrying out the tasks assigned to it.
Shown figure (2-1):
2.3.2 Detectors
9
Table 2-1: Gas Sensors
Alternating 5V
MQ-7 Carbon Monoxide
and 1.4V
Alternating 5V
MQ-9 Carbon Monoxide, flammable gasses.
and 1.4V
MQ131 Ozone 6V
MQ137 Ammonia 5V
10
Sensor Detects Heater Voltage
Alternating 0.2V
MQ307A Carbon Monoxide
and 0.9V.
Alternating 0.2V
MQ309A Carbon Monoxide, flammable gasses
and 0.9V
11
Figure 2-1: Gas Sensor (MQ-2)
12
2.3.2.2 Beam Detectors
They are used in the high places or the opening places such as:
places without roofs and the opening places for marketing. It consists of
a sender and receiver, the sender sends rays to the receiver, when there is
a fire the smoke cut this rays and the sensor will work. Shown figure (2-
4):
13
Figure 2-5: Alarm Unit
14
2.4.2 Temperature Sensor
This sensor uses the infrared flame flash method, which allows the
sensor to work through a coating of oil, dust, water vapor, otherwise ice.
The flame detection response can depend on its fitting. It is used in alarm
systems, natural gas lines and propane & a fire suppression system. The
response of these sensors is faster as well as more accurate compare with
a heat or smoke detector because of its mechanism while detecting the
flame. Shown figure (2-8):
15
Figure 2-8: Flame Sensor
16
2.4.5 Wireless Module (SIM900)
18
2.4.8 Relay
20
Figure 2-16: Solenoid Valve
21
Figure 2-17: Ventilation Fan
2.4.11 Buzzer
22
2.4.12 Three Phase AC Contactor
23
Figure 2-20: Three Phase AC Contactor
2.5 Internet of Things (IoT)
24
Figure 2-21: Internet of Things (IoT) System
2.6 The Cloud
25
The cloud enables users to access the same files and applications
from almost any device, because the computing and storage takes place
on servers in a data center, instead of locally on the user device.
26
Figure 2-23: Models of Cloud
27
2.7 Related Work
Many similar projects already exist and they have their own
characteristics and functionality. They all have so many advantages as
well as disadvantages. We can see various descriptions of them below
here.[12]Manish Verma used Raspberry pi 3 model attached with
embedded system with required input and output gas level with the help
of gas sensors. This resulted in a more efficient in operation because it is
connected to a common web page specially built to notify or email the
responsible authority automatically so reduces the stress of constant
monitoring. The choice of using a real time gas leakage monitoring and
sensing the output levels of gas has been clearly observed by the help of
this system.
28
auto-ignition. This type of system can be directly applied to the engine
chamber/ fuel chamber of the modern marine vessels using dual fuel
power cycle with LPG/LNG as secondary fuel-flamer. The results from
the experiments clearly indicate satisfactory actuation speed and
accuracy. The trials performed by the authors showed about 99%
efficiency of signal transmission and actuation.
This gas detection and alert system[15] will not only alert us of the
leakage but will also mechanically turn off the knob of the gas cylinder
to seize any leakage of gas. Moreover, this system informs the concerned
person by emailing and dropping a message on their mobile. This gives a
larger degree of safety to any gas setup in any circumstances. The
project is determined by using a lighter to collect leaked gas around the
gas sensor after sensing procedure if sensor value is greater than the
threshold value then microcontroller will perform its programmed tasks:
29
1.Immediately turn off the regulator knob to stop further leakage
2.Within 2-4sec the relay will cut off the main power supply.
4.Wi-Fi module will send SMS/e-mail using the cloud to the users.
5.The exhaust fan will fan out all enclosed gas from the
environment. When reset button of MCU pressed the system will get
refreshed
30
In this paper[17], we built an IoT (Internet of Things) based
framework that helps to prevent accident-related to LPG leakage. The
device is an intelligent piece of home computerization framework, as at
the point whenever gas spillage is detected it alarms the customer
through GSM signal phone call and SMS. All the while, it sounds the
buzzers to alert nearby people and it turns on the exhaust fan to transfer
the gas in an open space which will eventually dissolve into normal air
pressure very quickly. The device is capable of identifying the gas and
fire separately so that it can send accurate information directly to the
user via GSM module as quickly as possible. The algorithm is designed
to detect and produce results as quickly as accurately possible to prevent
any accident/blast from happening.
31
acoustic equipment used in the oil production, and passive sonar
systems have lower power consumption and longer lifespan.
32
CHAPTER THREE
METHODOLOGY
3.1 Overview
33
the cloud or database and used to monitor the system through the
application that act like human machine interface (HMI),we can save this
data in the cloud by connecting Arduino to the internet by using
ESP8266. And we use SIM900 to send SMS or make a call to inform the
manager the emergency situation. The system block diagram is shown
in figure (3-1):
The following figure (3-2) illustrates the system circuit for IoT gas
and fire detection which has been designed using the Proteus program ,
We Considering that the factory is divided into two part each part has
LPG gas sensor (MQ-2), CO gas sensor (MQ-7), flame sensor and
34
temperature sensor ,so when the system detect any gas or fire in any part
in the factory it will decide the right action using the actuators.
35
3.3.3 Interfacing the First Relay Circuit with Arduino
This circuit controls the gas valve, the circuit construction from
relay RL1, it has five pins. Two are connected to the Arduino pin (6) and
ground (control pins), the third pin is connected to the gas valve negative
point and the fourth pin is connected to the power supply which feed the
gas valve positive point by 5 DC voltage and the fifth pin configuring the
mode relay if it is close or open.
The second relay is used to control the LED which is used in the
simulation to represent the electricity panel, the circuit construction from
relay RL2, it has five pins. Two are connected to the Arduino pin (8) and
ground (control pins), the third pin is connected to the LED negative
point and the fourth pin is connected to the power supply which feed the
LED positive point by 5 DC voltage and the fifth pin configuring the
mode relay if It is close or open.
The VSS pin of the LCD is connected to the ground, while the
VDD pin is fed by 5 DC voltage, the VEE pin is connected to the
monitor with variable screen-lighting control resistance, the RW pin is
36
connected to the ground, the RS pin is connected to the seventh digital
pin of Arduino, the E (enable) is connected to sixth digital pin of
Arduino, the data legs (D4-D7) are connected with pins (25 -22) of
Arduino.
37
RX and TX are connected to the TX and RX pins of the GSM900
respectively to display the messages from the GSM.
First of all, all the hardware unit of the system was tested and it
was ensured that they were in a good working condition. Then all units,
gas valve, electrical panel, fire-fighting system, buzzer, ventilation fan,
gas sensors, flame sensors, temperature sensors, LCD and LEDs, were
connected to each other on the board with the Arduino Mega using
wires, the sensors were connected to 5v from the Arduino, the actuators
were connected to a 12v external power supply and the AC contractor is
connected to a 24v external power supply, the system response is divided
into two parts: normal mode “no gas or fire detected” and emergency
mode “gas or fire detected”. In the normal situation the green LED light
up, and the LCD screen displays the phrase „safe‟ the gas valve relay and
electricity panel relay are normal close, the fire-fighting system relay is
normal open and the ventilation fan is close. In the emergency mode if
one of the gas sensors is sensing (LPG or CO) gas the sensor sends the
signal by analog signal pin to the Arduino, then the Arduino receives and
read the signal and compare it with the threshold value, if it is higher
than threshold value the Arduino send a high digital signal that will
change the gas valve relay from normal close to open to turn off the
valve, and send a high digital signal to the ventilation fan, buzzer and red
LED to be active. and if one of the flame sensors is active then the
sensor sends the signal by digital signal pin to the Arduino, then the
Arduino receive and read the signal if it is equal to zero the Arduino
send a high digital signal that will change the fire-fighting system relay
from normal open to close, and change the gas valve relay from normal
close to open to turn off the valve, and send a high digital signal to the
38
ventilation fan, buzzer and red LED to be active then send a high digital
signal that will change the solid state relay from normal close to open to
turn off the AC contactor to shut-down the factory power. Second part is
the software, the code used to program the system, after importing the
required libraries and declaring the variables, the values from the sensors
are read using specific functions like DigitalRead and AnalogRead, and
then stored in the variables, next the sensor value is tested using an IF
statement and if value is above the predefined value then the Arduino
will send controlling signal to the actuators accordingly, if a gas leakage
is detected a SMS is sent using sendSMS function, and in the case of fire
a call is made using callfunction function.
39
3.5 System Work Flow
40
CHAPTER FOUR
SYSTEM RESULT
41
4.1.2 Gas is Detected
We have 4 gas sensors two of them are MQ-2 and the other two
are MQ7- when these sensors detect gas then it will send signal to the
Arduino and therefore the Arduino sends a signal to: the second relay to
close the gas valve, to the fire-fighting system to reduce the
concentration of the gas, to the alarming part (buzzer and LED), to the
LCD to display the case, and to the GSM to send a warning message to
the manager. The Gas Detection is shown in figure (4-2):
Any one of the flame senor with any one of the gas sensor are
active then the sensor will send signal to the Arduino then the Arduino
sends a signal to: the first relay to operate the fire-fighting system, to the
second relay to close the gas valve, to the ventilation fan to reduce the
concentration of the gas, to the alarming part (buzzer and LED), to the
42
LCD to display the case, and to the GSM to send a warning message and
call the manager. The Fire andGas Detection is shown in figure (4-3):
4.1.4 No Detection
The system is in the normal mode the sensor voltage is less than
the threshold so the electricity panel and gas valve are active and the fan,
water pump and alarming unit are off. The Normal Mode is shown in
figure (4-4):
43
Figure 4-4: No Detection
4.2 Results
In this case any one of gas sensor is higher than the threshold the
sim900 will send a message to the manager phone and the LCD will
display which gas sensor is detect the gas. Shown figures (4-5/4-6):
44
Figure 4-5: SMS Gas Alarm
In this case one or both of flame sensors are higher than the
threshold the sim900 will make a call to the manager number and the
LCD will display which flame sensor is detect the fire. Shown figures (4-
7/4-8):
45
Figure 4-7: GSM Call Alarm
In this case any one or two or three or all of gas sensor with the
flame sensor is higher than the threshold the sim900 will send a message
and make a call to manager phone and the LCD will display which flame
and gas sensor is detect the fire and the gas. Shown figure (4-9):
In case the factory temperature is high than the normal the sensor
will send signal to Arduino to activate the cooling fan. Shown figure (4-
10):
46
Figure 4-10: Cool Temperature
47
CHAPETER FIVE
5.1 Conclusion
In this thesis, the aim is to design a gas and fire alarm and control
system with a Low cost with effective usage and make it more users
friendly and easy to operate. So gas, temperature and flame sensors and
Arduino are used to save lives and reduce percentage of any accident.
The program embedded in the Arduino Mega works according to the
need A step by step approach in designing Arduino based system for gas
and temperature measurement has been followed. According to the study
and analysis of various parts of the system a design has been carried out
the results obtained from the measurement has shown that the system
performs well under all conditions and the attempt has been done
5.2 Recommendation
48
REFERENCES
[1] E. History, “search menu keyb keyb Bhopal disaster zoom _ in,” pp. 3–5, 1984.
[3] P. Ideas, “MQ2 Gas Sensor Working and Its Applica,” pp. 1–7, 2021.
[4] H. H. Electronics, “Mq-7 carbon monoxide datasheet,” pp. 2–4, 2018, [Online].
Available: https://www.pololu.com/file/0J313/mq7.pdf%0A%0A.
[5] “Insight Into ESP8266 NodeMCU Features & Using It With Arduino IDE Voltera V-
One PCB Printer - Concept to creation in minutes ESP-12E,” p. 8266.
[7] Tameson, “Solenoid Valve - How They Work,” pp. 1–9, 2021, [Online]. Available:
https://tameson.com/solenoid-valve-types.html.
[8] P. M. How and T. Contactor, “How to Wire a Three-Phase Contactor,” pp. 4–8.
[10] M. M. Alani, “What is the cloud?,” SpringerBriefs Comput. Sci., vol. 0, no.
9783319414102, pp. 1–14, 2016, doi: 10.1007/978-3-319-41411-9_1.
[11] The ThingsBoard Authors, “What is ThingsBoard?,” pp. 6–7, 2021, [Online].
Available: https://thingsboard.io/docs/getting-started-guides/what-is-thingsboard/.
[12] R. C. Pandey, M. Verma, and L. K. Sahu, “Internet of Things (IOT) Based Gas
Leakage Monitoring and Alerting System with MQ-2 Sensor,” Int. J. Eng. Dev. Res.,
vol. 5, no. 2, pp. 2321–9939, 2017.
49
monitoring system with feedback and feedforward control by utilizing IoT,” Facta
Univ. - Ser. Electron. Energ., vol. 32, no. 4, pp. 615–631, 2019, doi:
10.2298/fuee1904615s.
[15] M. Sharma, D. Tripathi, N. P. Yadav, and P. Rastogi, “Gas Leakage Detection and
Prevention Kit Provision with IoT,” Int. Res. J. Eng. Technol., vol. 5, no. 2, pp.
2227–2230, 2018, [Online]. Available: www.irjet.net.
[16] P. M. P. Gajre, N. Muley, D. Borse, and V. Naraje, “Unmanned Vehicle for Gas
Leakage Detection Using Raspberry PI,” Int. J. Adv. Res. Sci. Commun. Technol.,
vol. 5, no. 2, pp. 135–142, 2021, doi: 10.48175/ijarsct-1187.
[18] J. Na, L. Yue, R. Zhuang, and C. Yang, “Experimental Study on a Target Direction
Finding Algorithm for Gas Leakage Detection in Underwater Structures,” IOP Conf.
Ser. Earth Environ. Sci., vol. 651, no. 4, 2021, doi: 10.1088/1755-
1315/651/4/042015.
[19] H. H. Yan and Y. Rahayu, “Design and development of gas leakage monitoring
system,” Int. Conf. Electr. Eng. Comput. Sci. Informatics, vol. 1, no. August, pp.
207–212, 2014, doi: 10.11591/eecsi.1.404.
50
APPENDIX
#include <Wire.h>
char msg;
char call;
#include "dht.h"
dht DHT;
#include <MQ2.h>
void setup() {
SIM900.begin(19200);
Serial.begin(9600);
delay(1000);
lcd.begin(16, 2);
lcd.print("Safe");
void loop() {
DHT.read11(dht_apin);
A
DHT.read11(dht_apin2);
Serial.print(TEMP1);
Serial.println("C ");
Serial.println(GAS_Value1);
Serial.println(GAS7_Value1);
Serial.println(digitalRead(40));
Serial.print(TEMP2);
Serial.println("C ");
Serial.println(GAS_Value2);
Serial.println(GAS7_Value2);
Serial.println(digitalRead(41));
B
if(GAS_Value1 >= 400){ // if the gas value exceeds the threshold value perform the
following actions
lcd.setCursor(0,0);
lcd.print("GAS1 DETECTED");
lcd.setCursor(0,1);
Serial.println(" ");
Serial.println(GAS_Value1);
Serial.println(" ");
digitalWrite(ALARM,HIGH);
digitalWrite(relay,LOW);
digitalWrite(motor1pin1, HIGH);
digitalWrite(motor1pin2, LOW);
sendSMS();
delay(1000);
lcd.setCursor(0,0);
lcd.print("GAS7 DETECTED");
lcd.setCursor(0,1);
Serial.println(" ");
C
Serial.println(GAS_Value1);
Serial.println(" ");
digitalWrite(ALARM,HIGH);
digitalWrite(relay,LOW);
digitalWrite(motor1pin1, HIGH);
digitalWrite(motor1pin2, LOW);
sendSMS();
delay(1000);
if(FLAME_LAB_1 == LOW){
lcd.setCursor(0,0);
lcd.print("FIRE DETECTED");
lcd.setCursor(0,1);
Serial.println(" ");
Serial.println(GAS_Value1);
Serial.println(" ");
digitalWrite(ALARM,HIGH);
digitalWrite(relay,LOW);
digitalWrite(motor1pin1, HIGH);
digitalWrite(motor1pin2, LOW);
digitalWrite(motor2pin1, HIGH);
digitalWrite(motor2pin2, LOW);
D
callfunction();
delay(1000);
else{
digitalWrite(ALARM,LOW);
digitalWrite(motor1pin1,LOW);
digitalWrite(motor1pin2, LOW);
digitalWrite(motor2pin1,LOW);
digitalWrite(motor2pin2, LOW);
digitalWrite(relay,HIGH);
delay(5000);
delay(3000);
// SMS function
void sendSMS() {
SIM900.print("AT+CMGF=1\r");
delay(100);
SIM900.println("AT+CMGS=\"+249117763141\"");
delay(100);
SIM900.println("GAS DETECTED.");
delay(100);
SIM900.println((char)26);
delay(100);
E
SIM900.println();
delay(5000);
// Calling function
void callfunction() {
SIM900.println("ATD + +249909598273;");
delay(100);
SIM900.println();
delay(20000);