You are on page 1of 22

MICROCONTROLLER BASED LPG GAS DETECTOR USING

GSM MODULE

ABSTRACT
Ideal gas sensor is used to detect the presence of a dangerous LPG leak in your car
or in a service station, storage tank environment. This unit can be easily
incorporated into an alarm unit, to sound an alarm or give a visual indication of the
LPG concentration. The sensor has excellent sensitivity combined with a quick
response time. The sensor can also sense iso-butane, propane,
LNG and cigarette smoke.
If the LPG sensor senses any gas leakage from storage the output of this sensor
goes low. This low signal is monitored by the microcontroller and it will identify
the gas leakage. Now the microcontroller is turn on LED and Buzzer. After few
milliseconds delay, it also turn on exhaust fan for throwing gas out and continue
send messages as GAS LEAKAGE to a mobile no. , written in c-code.

INTRODUCTION
MQ-5 Semiconductor Sensor for Combustible Gas Sensitive material of MQ-5 gas
sensor is SnO2, which with lower conductivity in clean air. When the target
combustible gas exist, the
sensors conductivity is higher along with the gas concentration rising. We use
simple electrocircuit, convert change of conductivity to correspond output signal of gas
concentration. MQ-5
gas sensor has high sensitivity to Methane, Propane and Butane and could be used
to detect both
Methane and Propane. The sensor could be used to detect different combustible gas
especially Methane, it is with low cost and suitable for different application.

Component used

Sr. no.

Quantity (nos)

1.

89c51 microcontroller (base + IC)

2.

Diode (4007, .7v)

3.

10k resistance

4.

4.7k resistance

5.

470 ohms resistance

12

6.

Crystal oscillator (12Mhz frequency)

7.

buzzer

8.

LCD (2 line LCD display)

9.

Transformer (220v-909)

10.

L.E.D.

11.

16 Pin connector

12.

Ceramic Capacitor (30pf-33pf)

13.

Electrolytic capacitor (100 microfarad)

14.

Capacitor(10nf)

15.

Electrolytic capacitor (470 microfarad)

16.

Capacitor(1 pf)

17.

MQ5 Sensor

18.

MQ6 Sensor

19.

MQ7 Sensor

20.

MQ135 Sensor

21.

Pot (10k) (contrast controller)

22.

Stepper motor

23.

2-Pin connector

24.

2- pin switches

25.

Cello tape (for electrical use)

26.

Supply wire

2 mts

BLOCK DIAGRAM

BLOCK DIAGRAM DESCRIPTION


MQ-5 LPG SENSOR
It senses the leakage of LPG. The out put of this sensor is high at normal condition. The output
goes low, when it senses the LPG.
MICROCONTROLLER
It is the whole control of the project. It controls the Exhaust fan, LED, Buzzer and when LPG
leak occurs. The input/ output ports of the microcontroller is used for this.
EXHAUST FAN
This is used to send out the LPG to space and then the concentration of LPG is reduced.
Buzzer
When buzzer is blowing, this indicates the leakage of LPG gas. It is 12 V DC operated buzzer.
LED
When LED is glowing, this indicates the leakage of LPG gas. It is 1.2 V DC operated LED.
2

MQ-5 LPG GAS DETECTOR MODULE

Output Indicator
LED

OP-AMP Ic

MQ-5 LPG GAS


Sensor

Power Indicator
LED
PRESET

Output

Vcc
GND

SPECIFICATIONS OF MQ-5 LPG GAS SENSOR

WORKING PRINCIPLE
The sensing material in TGS gas sensors is metal oxide, most typically SnO2. When a metal
oxide crystal such as SnO2 is heated at a certain high temperature in air, oxygen is adsorbed on
the crystal surface with a negative charge. Then donor electrons in the crystal surface are
transferred to the adsorbed oxygen, resulting in leaving positive charges in a space charge layer.
Thus, surface potential is formed to serve as a potential barrier against electron flow.
Inside the sensor, electric current flows through the conjunction parts (grain boundary) of SnO2
micro crystals. At grain boundaries, adsorbed oxygen forms a potential barrier which prevents
carriers from moving freely. The electrical resistance of the sensor is attributed to this potential
barrier. In the presence of a deoxidizing gas, the surface density of the negatively charged
oxygen decreases, so the barrier height in the grain boundary is reduced. The reduced barrier
height decreases sensor resistance.
8051 Microcontroller

The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes of


Flash programmable and erasable read only memory (PEROM). The device
is manufactured using Atmels high-density nonvolatile memory technology and is compatible
with the industry-standard MCS-51 instruction set and pin out. The on-chip Flash allows the
program memory to be reprogrammed in-system or by a conventional non-volatile memory
programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel
AT89C51 is a powerful microcomputer which provides a highly-flexible and cost-effective
solution to many embedded control applications.
The AT89C51 provides the following standard features: 4K bytes of Flash, 128 bytes of RAM, 32
I/O lines, two 16-bit timer/counters, a five vector two-level interrupt architecture, a full duplex
serial port, on-chip oscillator and clock circuitry. In addition, the AT89C51 is designed with static
logic for operation down to zero frequency and supports two software selectable power saving
modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port and
interrupt system to continue functioning. next hardware reset.

Pin Configuration:

Pin Description:

VCC:
Supply voltage.

GND:
Ground.

Port 0:

Port 0 is an 8-bit open-drain bi-directional I/O port. As an output port, each pin can sink eight
TTL inputs. When 1s are written to port 0 pins, the pins can be used as high impedance inputs.
Port 0 may also be configured to be the multiplexed low order
Address /data bus during accesses to external program and data memory. In this mode P0 has
internal pull ups. Port 0 also receives the code bytes during Flash programming,
and outputs the code bytes during program verification. External pull ups are required during
program verification.

Port 1:

Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1 output buffers can
sink/source four TTL inputs. When 1s are written to Port 1 pins they are pulled high by the
internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being
pulled low will source current (IIL) because of the internal pull-ups. Port 1 also receives the loworder address bytes during Flash programming and verification.
Port 2:
Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 2 output buffers can
sink/source four TTL inputs. When 1s are written to Port 2 pins they are pulled high by the
internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being
pulled low will source current (IIL) because of the internal pull-ups.
Port 2 emits the high-order address byte during fetches from external program memory and
during accesses to external data memory that use 16-bit addresses (MOVX @ DPTR). In this
application, it uses strong internal pull-ups when emitting 1s. During accesses to external data
memory that use 8-bit addresses (MOVX @ RI), Port 2 emits the contents of the P2 Special
Function Register. Port 2 also receives the high-order address bits and some control signals
during Flash programming and verification.
Port 3:
Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3 output buffers can
sink/source four TTL inputs. When 1s are written to Port 3 pins they are pulled high by the
internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are externally being
pulled low will source current (IIL) because of the pull-ups. Port 3 also serves the functions of
various special features of the AT89C51 as listed below: Port 3 also receives some control
signals for Flash programming and verification.

ALE/PROG:
Address Latch Enable output pulse for latching the low byte of the address during accesses to
external memory. This pin is also the program pulse input (PROG) during Flash programming. In
normal operation ALE is emitted at a constant rate of 1/6 the oscillator frequency, and may be
used for external timing or clocking purposes. Note, however, that one ALE
Pulse is skipped during each access to external Data Memory. If desired, ALE operation can be
disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX
or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no
effect if the microcontroller is in external execution mode.
RESET:
Reset input. A high on this pin for two machine cycles while the oscillator is running resets the
device.

PSEN:
Program Store Enable is the read strobe to external program memory. When the AT89C51 is
executing code from external program memory, PSEN is activated twice each machine cycle,
except that two PSEN activations are skipped during each access to external data memory.
EA/VPP:
External Access Enable. EA must be strapped to GND in order to enable the device to fetch
code from external program memory locations starting at 0000H up to FFFFH. Note, however,
that if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to
VCC for internal program executions. This pin also receives the 12-volt programming enable
voltage (VPP) during Flash programming, for parts that require 12-volt VPP.
XTAL1:
Input to the inverting oscillator amplifier and input to the internal clock operating circuit.

XTAL2:
Output from the inverting oscillator amplifier.

Oscillator Characters:
XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier which can be
configured for use as an on-chip oscillator, as shown in Figure 1. Either a quartz crystal or
ceramic resonator may be used. To drive the device from an external clock source, XTAL2
should be left unconnected while XTAL1 is driven as shown in Figure 2. There are no
requirements on the duty cycle of the external clock signal, since the input to the internal
clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high
and low time specifications must be observed.
Idle Mode:
In idle mode, the CPU puts itself to sleep while all the on chip peripherals remain active. The
mode is invoked by software. The content of the on-chip RAM and all the special functions
registers remain unchanged during this mode. The idle mode can be terminated by any enabled
interrupt or by a hardware reset. It should be noted that when idle is terminated by a hard ware
reset, the device normally resumes program execution, from where it left off, up to two machine
cycles before the internal reset algorithm takes control. On-chip hardware inhibits access to
internal RAM in this event, but access to the port pins is not inhibited. To eliminate the possibility
of an unexpected write to a port pin when Idle is terminated by reset, the instruction following the
one that invokes Idle should not be one that writes to a port pin or to external memory.
Programming the Flash:
The AT89C51 is normally shipped with the on-chip Flash memory array in the erased state (that
is, contents = FFH) and ready to be programmed. The programming interface accepts either a
high-voltage (12-volt) or a low-voltage (VCC) program enable signal. The low-voltage
programming mode provides a convenient way to program the AT89C51 inside the users
system, while the high-voltage programming mode is compatible with conventional third party
Flash or EPROM programmers. The AT89C51 is shipped with either the high-voltage or lowvoltage programming mode enabled.
The AT89C51 code memory array is programmed byte by byte in either programming mode. To
program any nonblank byte in the on-chip Flash Memory, the entire memory must be erased
using the Chip Erase Mode.

MICROCONTROLLER CIRCUIT WITH PHERIPHERALS

Buzzer
Connector for
Exhaust Fan

L293D
Filter

Programming
Pins

LCD
Connector
8051

RESET
Button

GSM MODULE
For sending message, I am using a GSM Module named SIMCOM_300. GSM Module SIM300
with sim-card holder, RS232 interface, power supply, buzzer and audio interface. You can
connect this to PC using a USB to Serial Adaptor and use terminal programs such as Real term to
send & receive data. We can also interface GSM Module with microcontroller directly through
wires.
GSM Module works with AT COMMANDS. AT commands are used to control MODEMs. AT is
the abbreviation for Attention.
AT commands with a GSM/GPRS MODEM or mobile phone can be used to access following
information and services:
1.
2.
3.
4.
5.

Information and configuration pertaining to mobile device or MODEM and SIM card.
SMS services.
MMS services.
Call services.
Data and Voice link over mobile network.
8

SIM Card
Holder
Buzzer

Audio
Connect
or

Supply Port

Communication
PORT

Antenna

SIMCOM_300
(NOTE: For more details of SIMCOM_300 GSM Module, please refer datasheet.)

EXPLANATION OF COMMONLY USED AT COMMANDS


1)
AT - This command is used to check communication between the module and the
computer.
For example,
AT
OK
The command returns a result code OK if the computer (serial port) and module are connected
properly. If any of module or SIM is not working, it would return a result code ERROR.

2)
+CMGF - This command is used to set the SMS mode. Either text or PDU mode can
be selected by assigning 1 or 0 in the command.
SYNTAX:
AT+CMGF=<mode>
0: for PDU mode
1: for text mode
The text mode of SMS is easier to operate but it allows limited features of SMS. The PDU
(protocol data unit) allows more access to SMS services but the operator requires bit level
knowledge of TPDUs. The headers and body of SMS are accessed in hex format in PDU mode
so it allows availing more features.
For example,
AT+CMGF=1
9

OK

3)
+CMGW - This command is used to store message in the SIM.
SYNTAX:
AT+CMGW=" Phone number"> Message to be stored Ctrl+z
As one types AT+CMGW and phone number, > sign appears on next line where one can type
the message. Multiple line messages can be typed in this case. This is why the message is
terminated by providing a Ctrl+z combination. As Ctrl+z is pressed, the following information
response is displayed on the screen.
+CMGW: Number on which message has been stored

4)
+CMGS - This command is used to send a SMS message to a phone number.
SYNTAX:
AT+CMGS= serial number of message to be send.
As the command AT+CMGS and serial number of message are entered, SMS is sent to the
particular SIM.
For example,
AT+CMGS=1
OK
5)
ATD - This command is used to dial or call a number.
SYNTAX:
ATD<Phone number>(Enter)
For example,
ATD123456789
6)
ATA - This command is used to answer a call. An incoming call is indicated by a
message RING which is repeated for every ring of the call. When the call ends NO
CARRIER is displayed on the screen.
SYNTAX:
ATA(Enter)
As ATA followed by enter key is pressed, incoming call is answered.
For example,
RING
RING
ATA
7)
ATH - This command is used to disconnect remote user link with the GSM module.
SYNTAX:
ATH (Enter)

10

CONNECTION BETWEEN MICROCONTROLLER AND GSM MODULE


For connection, connect Receiver Pin (Rx) of Microcontroller to Transmitter Pin (Tx) of GSM
Module and Transmitter Pin (Tx) of Microcontroller to Receiver Pin (Rx) of GSM Module. Also
connect Ground Pin (GND) of both.

Vcc

Vcc

AVR

Rx

Tx

Tx

Rx
GSM

GND

GND

POWER SUPPLY
Power supply for the complete unit can be derived from the mains using a step-down transformer
of 230V AC primary to 0-12V, 500mA secondary. A full- wave rectifier followed by a capacitor
filter is the output voltage and feeds it to the 5-volt regulator (LM7805) whose output is used to
the power supply requirements of microcontroller circuit, other ICs.
+12
V

+5V
IC1

D
1
L
1
230
V
A
C

1 LM7805 3
D
2

1N4007
1N400
7
D3
230/012V

1N400
7
D4

C
1

C
2
1000uF/25V2

1
N
4
0
0
7
11

F /

16V

Step down
Transformer
Power
Indicator

Filter

Full Wave Rectifier Ic

COMPLETE CONNECTION DIAGRAM

Exhaust Fan

Microcontroller
Circuit

GAS Sensor
Module

GSM
Module

Power
Supply

12

SCHEMATIC DIAGRAM

13

FLOW CHART DIAGRAM


Start

Power On

MCU sends AT to
GSM Module

Is GSM Module
replies OK ?

NO

YES

Is LPG Sensors
O/P value is
greater than
threshold value?

YES
Turn on LED & Buzzer
Start Exhaust Fan by enabling the respective
PORT

Send message to stored Mobile No.

14

NO

APPLICATIONS
This project is applicable in following fields:
1.
2.
3.
4.
5.
6.
7.
8.

Domestic gas leakage detector


Industrial Combustible gas detector
Portable gas detector
Homes
Factories
LPG storage
Gas cars
Hotels etc.

CONCLUSION
I have finally succeeded in making the "MICROCONTROLLER BASED LPG GAS
DETECTOR USING GSM MODULE" Satisfactorily. More knowledge is gained and more
experiences are faced lot of informations are collected ultimately, I have concluded with a great
pleasure for achieving our aim.
I have planned to fulfill my technical requirements. The knowledge I have attained with this
project really would follow till the end of our career.

REFERENCES

1.
2.
3.
4.

www.iskyworld.in
www.seminarprojects.com
www.engineersgarage.com

www.datasheets 4u.com

15

You might also like