Minor Project On: Gas Detection and Alert System
Minor Project On: Gas Detection and Alert System
Minor Project On: Gas Detection and Alert System
On
BY-
CERTIFICATE
This is to certify that the report entitled “Gas Detection And Alert System” is a
bonafide record of Minor Project (I) Report submitted by
Arpit Bhateley(2K12/EC/036)
Anngad Singh (2K12/EC/030)
Apaar Singhal(2K12/EC/034)
Angad Singh (2K12/EC/026)
Mentor
ACKNOWLEDGEMENT
INDEX
S. No. Title Page No.
1 Introduction 6
2 Microcontroller-Arduino 7
3 Gas Sensor Module 15
4 SIM 900 GSM Module 21
5 Servo Motor 27
6 Buzzer 28
7 Circuit Diagram 29
8 Code 30
9 Working 33
10 Applications 39
11 Cost Comparison 41
5
FIGURE INDEX
S. No. Title Page No.
1 Block Diagram 6
2 Microcontroller-Arduino 7
3 Schematic & Reference Design-Arduino 8
4 Arduino Mega 2560 PIN diagram 9
5 Gas Sensor 15
6 Wiring-Gas Sensor 16
7 SIM 900 GSM Module 21
8 SIM 900 GSM Module-Pin Diagram 23
9 Interfacing the Modem to microcontroller 24
(Basic connection)
10 Interfacing the Modem to ARDUINO 24
11 Servomotor 27
12 Circuit Diagram 29
13 Application of Gas Detection System 39
14 Practical System 40
6
Introduction
The presence of dangerous LPG leakage in the cars, service station or in the
storage tank environment can be detected using the Ideal Gas Sensor.
The objective of this project is to detect any leakage of LPG/CNG in gas based
cars, small scale factories or in home appliances also. It will detect the leakage and
will close the knob of the system to stop the supply of the gas. Stepper motor is
there that could be attached with the knob and will close the supply by rotating it.
An alarm is also there to alert the user as soon as leakage is found. There shall be
an automatic call/sms from the system if any gas is detected. Hence the user gets
automatic information as soon as some problem occurs at the station.
Servo
Motor
LED ALARM
7
It is the heart of the project. It is used to control the Servo Motor, LED and Buzzer
when LPG leakage occurs. The input/ output ports of the microcontroller are used
for this purpose.
8
Overview
The Arduino MEGA ADK is a microcontroller board based on the ATmega2560.
It has a USB host interface to connect with Android based phones, based on
the MAX3421e IC. It has 54 digital input/output pins (of which 15 can be used as
PWM outputs), 16 analog inputs, 4 UARTs (hardware serial ports), a
16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a
reset button.
The MEGA ADK is based on the Mega 2560.
Similar to the Mega 2560 and Uno, it features an ATmega8U2 programmed as a
USB-to-serial converter.
Summary
Microcontroller ATmega2560
Operating Voltage 5V
SRAM 8 KB
EEPROM 4 KB
Power
The Arduino MEGA ADK can be powered via the USB connection or with an
external power supply. The power source is selected automatically.
External (non-USB) power can come either from an AC-to-DC adapter (wall-wart)
or battery. The adapter can be connected by plugging a 2.1mm center-positive plug
into the board's power jack. Leads from a battery can be inserted in the Gnd and
Vin pin headers of the POWER connector.
The board can operate on an external supply of 5.5 to 16 volts. If supplied with less
than 7V, however, the 5V pin may supply less than five volts and the board may be
unstable. If using more than 12V, the voltage regulator may overheat and damage
the board. The recommended range is 7 to 12 volts.
The power pins are as follows:
VIN. The input voltage to the Arduino board when it's using an external power
source (as opposed to 5 volts from the USB connection or other regulated power
source). You can supply voltage through this pin, or, if supplying voltage via the
power jack, access it through this pin.
5V. This pin outputs a regulated 5V from the regulator on the board. The board can
be supplied with power either from the DC power jack (7 - 12V), the USB
connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the 5V
or 3.3V pins bypasses the regulator, and can damage your board. We don't advise
it.
3V3. A 3.3 volt supply generated by the on-board regulator. Maximum current
draw is 50 mA.
GND. Ground pins.
IOREF. This pin on the Arduino board provides the voltage reference with which
the microcontroller operates. A properly configured shield can read the IOREF pin
voltage and select the appropriate power source or enable voltage translators on the
outputs for working with the 5V or 3.3V.
12
Memory
The MEGA ADK has 256 KB of flash memory for storing code (of which 8 KB is
used for the bootloader), 8 KB of SRAM and 4 KB of EEPROM (which can be
read and written with the EEPROM library).
Serial: 0 (RX) and 1 (TX); Serial 1: 19 (RX) and 18 (TX); Serial 2: 17 (RX)
and 16 (TX); Serial 3: 15 (RX) and 14 (TX). Used to receive (RX) and transmit
(TX) TTL serial data. Pins 0 and 1 are also connected to the corresponding pins of
the ATmega8U2 USB-to-TTL Serial chip.
External Interrupts: 2 (interrupt 0), 3 (interrupt 1), 18 (interrupt 5), 19
(interrupt 4), 20 (interrupt 3), and 21 (interrupt 2). These pins can be
configured to trigger an interrupt on a low value, a rising or falling edge, or a
change in value.
PWM: 2 to 13 and 44 to 46. Provide 8-bit PWM output with
the analogWrite() function.
SPI: 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS). These pins support SPI
communication using the SPI library. The SPI pins are also broken out on the ICSP
header, which is physically compatible with the Uno, Duemilanove and Diecimila.
USB Host: MAX3421E. The MAX3421E comunicate with Arduino with the SPI
bus. So it uses the following pins:
o Digital: 7 (RST), 50 (MISO), 51 (MOSI), 52 (SCK).
NB:Please do not use Digital pin 7 as input or output because is used in the
comunication with MAX3421E
o Non broken out on headers: PJ3 (GP_MAX), PJ6 (INT_MAX), PH7 (SS).
13
LED: 13. There is a built-in LED connected to digital pin 13. When the pin is
HIGH value, the LED is on, when the pin is LOW, it's off.
TWI: 20 (SDA) and 21 (SCL). Support TWI communication using the Wire
library. Note that these pins are not in the same location as the TWI pins on the
Duemilanove or Diecimila.
The MEGA ADK has 16 analog inputs, each of which provide 10 bits of resolution
(i.e. 1024 different values). By default they measure from ground to 5 volts, though
is it possible to change the upper end of their range using the AREF pin and
analogReference() function.
There are a couple of other pins on the board:
AREF. Reference voltage for the analog inputs. Used with analogReference().
Reset. Bring this line LOW to reset the microcontroller. Typically used to add a
reset button to shields which block the one on the board.
Communication
The Arduino MEGA ADK has a number of facilities for communicating with a
computer, another Arduino, or other microcontrollers. The ATmega2560 provides
four hardware UARTs for TTL (5V) serial communication. An ATmega8U2 on
the board channels one of these over USB and provides a virtual com port to
software on the computer (Windows machines will need a .inf file, but OSX and
Linux machines will recognize the board as a COM port automatically. The
Arduino software includes a serial monitor which allows simple textual data to be
sent to and from the board. The RX and TX LEDs on the board will flash when
data is being transmitted via the ATmega8U2/16U2 chip and USB connection to
the computer (but not for serial communication on pins 0 and 1).
A SoftwareSerial library allows for serial communication on any of the MEGA
ADK's digital pins.
14
The ATmega2560 also supports TWI and SPI communication. The Arduino
software includes a Wire library to simplify use of the TWI bus; see the Wire
library for details. For SPI communication, use the SPI library.
The USB host interface given by MAX3421E IC allows the Arduino MEGA ADK
to connect and interact to any type of device that have a USB port. For example,
allows you to interact with many types of phones, controlling Canon cameras,
interfacing with keyboard, mouse and games controllers as Wiimote and PS3.
This sensor is used to sense the leakage of LPG. In normal conditions the output of
this sensor is ‘high’ and it goes ‘low’, when the LPG is sensed.
Introduction
The MQ series of gas sensors use a small heater inside with an electro-chemical
sensor. They are sensitive for a range of gasses and are used indoors at room
temperature.
They can be calibrated more or less (see the section about "Load-resistor" and
"Burn-in") but a know concentration of the measured gas or gasses is needed for
that.
The output is an analog signal and can be read with an analog input of the Arduino.
16
Wiring
The preferred wiring is to connect both 'A' pins together and both 'B' pins together.
It is safer and it is assumed that is has more reliable output results. Although many
schematics and datasheets show otherwise, you are advised to connect both 'A' pins
together and connect both 'B' pins together.
In the picture, the heater is for +5V and is connected to both 'A' pins. This is only
possible if the heater needs a fixed +5V voltage.
The variable resistor in the picture is the load-resistor and it can be used to
determine a good value. A fixed resistor for the load-resistor is used in most cases.
The Heater
The voltage for the internal heater is very important.
Some sensors use 5V for the heater, others need 2V. The 2V can be created with a
PWM signal, using analogWrite() and a transistor or logic-level mosfet.
The heater may not be connected directly to an output-pin of the Arduino, since it
uses too much current for that.
Some sensors need a few steps for the heater. This can be programmed with an
analogWrite() function and delays. A transistor or logic-level mosfet should also in
this situation be used for the heater.
The sensors that use 5V or 6V for the internal heater do get warm. They can easily
get 50 or 60 degrees Celcius.
After the "burn-in time", the heater needs to be on for about 3 minutes (tested with
MQ-2) before the readings become stable.
18
Load-resistor
The sensor needs a load-resistor at the output to ground. It's value could be from
2kOhm to 47kOhm. The lower the value, the less sensitive. The higher the value,
the less accurate for higher concentrations of gas.
If only one specific gas is measured, the load-resistor can be calibrated by applying
a know concentration of that gas. If the sensor is used to measure any gas (like in a
air quality detector) the load-resistor could be set for a value of about 1V output
with clean air.
Burn-in
Some datasheets use the term "preheat", but it is the time to burn-in the sensor.
This is meant to make the sensor readings more consistent. A time of 12 or 24
hours is usually used for the burn-in time.
The Burn-in is achieved by applying normal power to the sensor (to the heater and
with the 'A' and 'B' pins connected, and with a load-resistor). In some special cases
a specific burn-in is needed. See the datasheet if the sensor needs such a specific
burn-in.
19
List of sensors
MQ-2
MQ-3
MQ-4
MQ-5
MQ-6
MQ-7
MQ-8
MQ-9
General features
Point-to-point MO and MT
SMS cell broadcast
Text and PDU mode
Drivers
MUX Driver
Interfaces
GPIO
PWM
ADC
Compatibility
AT cellular command interface
Approvals in planning
CE
FCC
ROHS
PTCRB
GCF
AT&T
IC
TA
Pin Assignment
24
GETTING STARTED
1) Insert SIM card. Open the SIM cardholder by sliding it as per the arrow mark
and lift up. Insert the SIM card , so as to align the chamfered corner suits in card
holder .After inserting the SIM card, lock the holder by sliding it to theopposite
direction of arrow mark.
3) Connect the pins connect the GSM modem as per the circuit diagram provided
4) Power the modem power the modem from suitable power supply, which is
having enough current capacity (>1A).
6) Network LED
The Network LED indicates the various status of GSM module eg. Power on,
Network registration & GPRS connectivity. When the modem is powered up, the
status LED will blink every second. After the modem registers in the network
(takes between 10-60 seconds), LED will blink in step of 3 seconds. At
this stage you can start using Modem for your application.
7) Baud rate
The Baud rate supported by the modem is between 9600 and 115200. Make sure
the host system is set to the supported baud rate. The modem automatically sets to
the baud rate of the first command sent by the host system after it is powered up.
User must first send “A” to synchronize the baud rate. It is recommended to wait 2
to 3 seconds before sending “AT” character. After receiving the “OK” response,
Your Device and GSM Modemare correctly synchronized. So there is no need for
setting the baud rate using commands. Before You Start using the modem, please
make sure that the SIM card you inserted support the needed features and there is
enough balance in SIM.
26
Note that the starting "AT" is the prefix that informs the modem about the start of a command
line. It is not part of the AT command name. For example, D is the actual AT command name in
ATD and +CMGS is the actual AT command name in AT+CMGS. However, some books and
web sites use them interchangeably as the name of an AT command.
There are two types of AT commands: basic commands and extended commands.
Basic commands are AT commands that do not start with "+". For example, D (Dial), A
(Answer), H (Hook control) and O (Return to online data state) are basic commands.
Extended commands are AT commands that start with "+". All GSM AT commands are
extended commands. For example, +CMGS (Send SMS message), +CMSS (Send SMS message
from storage), +CMGL (List SMS messages) and +CMGR (Read SMS messages) are extended
commands.
27
4.) Servomotor
A servomotor is a rotary actuator that allows for
precise control of angular position, velocity and
acceleration. It consists of a suitable motor
coupled to a sensor for position feedback. It also
requires a relatively sophisticated controller,
often a dedicated module designed specifically
for use with servomotors.
Servomotors are used in applications such
as robotics, CNC machinery or automated
manufacturing.
Here we are using the servomotor to close the
knob of the gas cylinder in case of any leakage.
Mechanism
Servo motors have three wires: power, ground, and signal. The power wire is
typically red, and should be connected to the 5V pin on the Arduino board. The
ground wire is typically black or brown and should be connected to a ground pin
on the Arduino board. The signal pin is typically yellow, orange or white and
should be connected to a digital pin on the Arduino board. Note that servos draw
considerable power, so if you need to drive more than one or two, you'll probably
need to power them from a separate supply (i.e. not the +5V pin on your Arduino).
Be sure to connect the grounds of the Arduino and external power supply together.
28
5.) BUZZER
Circuit Diagram
30
Code
/*--------------Variables-------------------------------*/
int gas=0;
int pos = 0;
const int analogInPin = A0; // Analog input pin that the gas sensor is attached to
int timestosend=1;
int count=0;
/*--------------------------------------------------------*/
void setup()
Serial.println("AT+CMGF=1");
delay(200);
31
void loop()
Serial.print("sensor = " );
Serial.println(sensorValue);
{ gas=1;
pos=90;
else
{ gas=0;
pos=0;
}
32
if(gas==1)
while(count<timestosend)
delay(1500);
Serial.print("AT+CMGS=\"");
Serial.print(phone);
Serial.println("\"");
while(Serial.read()!='>');
delay(500);
Serial.write(0x1A);
Serial.write(0x0D);
Serial.write(0X0A);
delay(3000);
33
count++;
else
count=0;
delay(10);
WORKING
Input Section:
Sensor Output=900*5/1024=4.39V
Processing Section:
It reads the Sensor Output Value and compares them to the threshold
level.
If the reading exceeds the threshold level ie 4.39V in this case it
generates the required PWM signal (through the PWM pin) for the
working of the Servo motor which shuts out the supply of gas.
It then sends a digital high signal to both the LED and the Buzzer to
sound off an alarm and glow the LED.
It finally sends commands and the text message to the GSM Module(
through Tx and Rx pins) via AT Commands to send the emergency
message to the concerned person/ authority.
Output Section:
1. Servo Motor: It accepts the PWM signal from the microcontroller and
input voltage from the external battery for its working. It subsequently
turns off the knob to shut down the supply of gas.
35
2. Buzzer: It accepts the digital high signal from the microcontroller to sound
off the alarm.
3. LED: It accepts the digital high signal from the microcontroller to glow the
LED in case of any leakage.
4. GSM Module: It receives the required message ( through Tx and Rx pins)
from the microcontroller. Then it send the emergency message in case of any
leakage.
Code Description:
#include <Servo.h>- Header file of Servo Library which contains all the
functions necessary for the control and operation of the Motor. It has the following
2 functions-
const int analogInPin = A0- Analog input pin that the gas sensor is attached to
void setup()
void loop()
else
The following code segment is used for sending the text message
delay(1500);
Serial.println("\"")-
delay(500);
Serial.write(0x0D)-
Serial.write(0X0A)-
delay(3000);
}
39
}
40
41
APPLICATIONS
Safety plays a major role in today’s world and it is necessary that good safety
systems are to be implemented in places of education and work. The LPG or
propane which is flammable mixture of hydrocarbon gases used as fuel in many
applications like homes, hostels, industries, automobiles, vehicles because of its
desirable properties which include high calorific
value, which produce the less smoke, produces
less soot, and does not cause much harm to the
environment. Natural gas is another widely used
fuel in homes. Both gases burns to produce clean
energy, however there is a serious problem about
their leakage in the air. The gases being heavier
than air do not disperse easily and may lead to
suffocation when inhaled also when gas leakage
into the air may lead to explosion. Due to the
explosion of LPG gas the number of deaths has
been increased in recent years. To avoid this
problem there is a need for a system to detect and also prevent leakage of LPG.
Gas leak detection is the process of identifying potentially hazardous gas leaks by
means of various sensors. The advantage of this automated detection and alerting
system over the manual method is that it offers quick response time and accurate
detection of an emergency and in turn leading faster diffusion of the critical
situation.
The gas detection and alert system that we have designed is a very cost effective
system to detect leakage of any gas. It not only detects leakage of gas, it also
sounds an alarm and has a motor attached to it that can be used to close the knob of
the leaking cylinder. It has its applications in various fields like
It is especially useful in the case when leakage takes place when there is no one
around. In this case the motor installed would close the source of the leakage and
the concerned person would get an alert by SMS.
42
One of the incidents that everyone can closely relate to is the Bhopal Gas tragedy.
With this system in place not only would a timely alert been useful for evacuation,
but the source of gas leakage could also have been stopped and a lot of lives would
have been saved.
ADVANTAGE
It is used in house as LPG leakage detection.
It also detects alcohol so it is used as liquor tester.
The sensor has excellent sensitivity combined with a quick response time.
DISADVANTAGES
It is little sensitive to smoke, then in kitchen it is not perfectly response for
LPG gas leakage.
It works only when at 5V power supply is given.
Its sensitivity depends on Humidity and temperature.
43
COST COMPARISON
Our Gas Detection And Alert System was designed for a cost of 2,485/-. The same
product is available in the market for an approximate cost of about 8,000/- to
9,000/- .
Serving almost the same purpose it can be seen easily that our system is much
more cost effective than any other system that is commercially available and can
be used easily in households, automobiles, schools, colleges, industries etc.