Gas Leakage Detection System using 8051

In this tutorial, we are going to see a Gas Leakage Detection System using 8051.

Gas Leakage Detection System using 8051

Abstract

Gas leakage tragedies and accidents have led to heavy losses over the years. So it is very important to detect any gas leakage and prevent any accidents. So here we propose a system to detect LPG gas leakage scenarios and provide a security alert to intended users.

SMS-based LPG gas leakage detection system using GSM has application in various areas like home, industries, hotels, hospitals. This project has a gas leakage detector implemented by using an LPG Gas sensor. The user can get remote indication through SMS sent from the project. This SMS is sent from the GSM modem which is connected to the microcontroller. A buzzer is turned on after LPG gas leakage so it acts as a gas leakage alarm.

Components Required

  • 8051 Development board
  • LCD Module
  • GSM Module
  • Gas Sensor
  • Buzzer
  • ADC0804
  • Relay

Software Required

  • Keil IDE

Prerequisites

Before seeing the code, first you can see the basic interfacing tutorials of these components.

Block Diagram

Gas Leakage Detection System using 8051

Explanation

  • A gas sensor is used to detect the Gas, which is connected to 8051 microcontrollers through ADC0804.
  • LCD is used to Display the Gas level and Relay status.
  • GSM is used to send the message when it detects the Gas in-room or home.
  • The buzzer also makes a sound when the controller detects any Gas.
  • Relay also connected to Micro Controller. The house’s electricity power will go through this relay. When it detects gas leakage, the relay goes off. So house electricity will be off. It will prevent the other damages by electricity.

Circuit Diagram

LCD:

  • RS – P3.7
  • RW – GND
  • EN – P3.6
  • Data lines – P1

Gas Sensor:

  • Output – ADC’s Vin (6th Pin)

ADC0804:

  • RD – P0.7
  • WR – P0.6
  • INTR – P0.5
  • CS – GND
  • Data Lines – P2

GSM:

  • GSM RX – P3.1
  • GSM TX – P3.0

Buzzer: P0.1

Relay: P0.0

Code

Here I’ve added only the main code. Header files are not here. You can download the full code Here.

#include<reg52.h>
#include"LCD.h"			   //rs=p3.7, en=p3.6
#include"GSM.h"

#define NUM "1234567890"    //Enter Your Mobile Number

sbit rd=P0^7;
sbit wr=P0^6;
sbit intr=P0^5;

sbit RELAY=P0^0;
sbit buzz=P0^1;


unsigned char h,msgq;
unsigned int s,r;
void adc();

unsigned char adc_data=0;

void main()
{

	init_serial();
	LCD_initialise();
	RELAY=1;			//relay on
	buzz=0;				//buzz on
	comwrt(0x80);
	display("LOADING.");
	for(h=0;h<8;h++) {
		datawrt('.');
		for(s=0;s<30000;s++);
	}
	P2=0xFF;
	comwrt(0x80);
	display("GAS:000PPM R:OFF");
	buzz=0;
	for(r=0;r<=10000;r++);

	while(1) {
		adc();
		for(r=0;r<=20000;r++);			
	}
}


void adc()
{
wr=0;
rd=1;
wr=1;
while(intr==1);
rd=0;
adc_data = P2 ;

msgq = adc_data;

	comwrt(0x84);
	datawrt((msgq/100)+0x30);
	datawrt(((msgq/10)%10)+0x30);
	datawrt((msgq%10)+0x30);
	
	if(msgq > 80) {
		RELAY=0;			   //relay off
		buzz=0;				   //buzz on
		comwrt(0x8D);
		display("OFF");
		
		comwrt(0xC0);
		display("G:HIGH   V:CLOSE");
		for(s=0;s<60000;s++);
		comwrt(0xC0);
		display("SENDING MSG.....");
		
		sendSMS(NUM,"VOLVE CLOSED AND POWER DISCONNECTED DUE TO GAS LEAKAGE!");
		for(s=0;s<30000;s++);
		comwrt(0x80);
		display("GAS:");
		comwrt(0x8b);
		display("R:");
	} else {
		comwrt(0xC0);
		display("G:NORMAL V:OPEN ");
		RELAY=1;		 //relay on
		buzz=1;			 //buzz off
		comwrt(0x8D);
		display("ON ");	
	}
}

Explanation

  • The gas sensor detects gas leakage in the home. This value is analog. So we need to connect ADC to convert Digital.
  • If the Gas level is high, the microcontroller turns OFF the Relay to cut the electricity. The ON the buzzer. Finally, it sends the message to the house owner about gas leakage using GSM.

Please read the other 8051 projects here.

You can also read the below tutorials.

Linux Device Driver TutorialsC Programming Tutorials
FreeRTOS TutorialsNuttX RTOS Tutorials
RTX RTOS TutorialsInterrupts Basics
I2C Protocol – Part 1 (Basics)I2C Protocol – Part 2 (Advanced Topics)
STM32 TutorialsLPC2148 (ARM7) Tutorials
PIC16F877A Tutorials8051 Tutorials
Unit Testing in C TutorialsESP32-IDF Tutorials
Raspberry Pi TutorialsEmbedded Interview Topics
Reset Sequence in ARM Cortex-M4BLE Basics
VIC and NVIC in ARMSPI – Serial Peripheral Interface Protocol
Bootloader Tutorials

5 1 vote
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
2
0
Would love your thoughts, please comment.x