Sunday, November 01, 2015

Gas Leakage Detector Project using Microcontroller and (MQ-9) Gas Sensor

LPG Gas Leakage Detector using (MQ-9)  Gas Sensor and pic18f2550 Microcontroller

Gas Sensor (MQ-9) :

  MQ-9 Gas Sensor is one kind of semiconductor which has very lower conductivity in open air. But in Carbon Monoxide, Methane and LPG gas it has good conductivity. By using ADC of pic microcontroller we can measure it. Let's take a look on MQ-9 sensor .
Gas Sensor (MQ-9)

Gas Sensor (MQ-9) pin out

Datasheet of  MQ-9


Basic Concepts :

The MQ-9 sensor will be connected with a pic microcntroller and a buzzer will also be connected with microcontroller. When LPG gas will be detected in sensor, it will provide voltage into microcontroller's RA1 pin(ADC). It will provide reading more than 590. At this situation microcontroller will turn on the buzzer and LED. That's the basic concept. 

ADC(Analog to Digital Converter ) :

We need a basic knowledge about ADC. Let's  take a look at here :
LPG Gas Leakage Detector using (MQ-9)  Gas Sensor and pic18f2550 Microcontroller
Thief Detector using PIC Microcontroller & PIR Motion Sensor
ADCON1 Register
LPG Gas Leakage Detector using (MQ-9) Gas Sensor and pic Microcontroller

Basically ADC works like as a voltage divider. According to voltage It produce output.

bit 5 : VCFG0: Voltage Reference Configuration bit (VREF- source)
1 = VREF- (AN2)
0 = VSS or 0 volt

bit 4 :VCFG0: Voltage Reference Configuration bit (VREF+ source)
1 = VREF+ (AN3)
0 = VDD or 5volt

We will set  VCFG0[bit 5]=0and VCFG0[bit4]=0. So we will get highest value 5volt[1023] and lowest value 0volt[0].The ADCON1 is a 10 bit register that means  2 to the power 10  is it's highest counting capacity and result is 1024. So this register can count from 0 to 1023. When 0 volt, we get reading at RA1 pin  0. When 5 volt, we get reading at RA1 pin 1023. It means 5volt equivalent to 1023 .

 If  5 volt    equal    reading 1023 .

So 1  volt   equal    reading 1023/5  
[When LPG Gas detect MQ-9 Sensor provide more than 2.93 volt at AO Pin]
So 3 volt equal  reading  (1023/5)*2.93 =599 When we get reading 599 at ADC channel, we understand  that sensor detects LPG. So it makes PORTB.F6 pin high and Buzzer turns on .

 MikroC Source Code :


double source=0;   
char txt[15];  
 void main() {  
 ADCON1=0x0D;         // Configure RA1 pin as input  


Proteus Circuit :


LPG Gas Leakage Detector using (MQ-9)  Gas Sensor and pic18f2550 Microcontroller

LPG Gas Leakage Detector using (MQ-9) Gas Sensor and pic Microcontroller



LPG Gas Leakage Detector using (MQ-9) Gas Sensor and pic Microcontroller


Download This Project(google drive)

Thank You!



  1. Replies
    1. Thank you sir. My comment option hasn't been working for a long time. Suddenly I've found it working and I'm making reply, sir.

  2. Can you plz mail me the programme used in this programme?
    My mail id is

  3. Sir i use pic16f877a and it has a lot unusual errors...Do pic18 family has same issue ?

    1. Although It's a late reply. But you know I have to response. If your aim is to make project for university exam then use same MCU same circuit as I had done. Thank you.

  4. I tried to simulate the circuit with the given program in software with mq-9 sensor(I added the sensor in the library) but its not working... I made the hex file burned it in the chip but its not simulating. Any idea where i go wrong?

    1. it was supposed to work. While I tried It took some times to work as far as I remember.

  5. This comment has been removed by a blog administrator.

  6. Replies
    1. I think I have given download link now. Thank you.


  7. The link is broken. Please upload your new one?


Share and Bookmark this Blog

Introduction to Embedded Systems Software and Development Environments

An Introduction to Programming the Internet of Things (IOT) (Online Course)

Industrial IoT Markets and Security (Online Course)


: (1) 18F2550 (1) 36KHz (3) and (1) Based (1) battery (1) Bipolar (1) Blinking (1) blinks (1) Bluetooth (1) bluetooth device interfacing (1) bluetooth module (1) button (1) circuit (1) clock (1) control (1) crystal oscillator (3) Db9 (1) DC Motor (2) digital (2) Digital Voting Machine (1) digital voting machine using pic (1) display (2) DS1307 (1) electronic (1) embedded c programming tutorial (11) embedded c tutorial (11) experiment kit (4) external interrupt (4) flash (1) flashing (1) Gas Leakage detector (1) HC-06 (1) home (1) how (1) How to (10) i2c tutorial (1) in (1) indicator (1) infrared Connection (3) interface (8) interfacing (3) Interrupt (3) Introduction (1) IR Connection (3) IR Receiver (4) IR Transmitter (4) key pad (1) keypad (1) lavel (1) Lcd 16x2 (2) lcd 2x16 (2) led (1) lm35 (2) LPG (1) machine (1) make (1) Make bootloader (1) making (1) matrix (1) max232 (1) membrane keyboard (1) meter (2) Micocontroller (1) microchip (4) microchip pic (2) microchips (3) microcontroller (9) microcontroller based (3) microcontroller programming (3) Microcontroller Project (4) Microcontroller Projects (1) microcontroller_project (2) microcontrollers (4) Microprocessor (2) mikroC (5) mikroc code to start and stopstart and stop dc motor (1) mikroc pro for pic (2) Motion detector (1) MQ-9 Gas Sensor (1) musical (1) NEC Protocol (4) pcb (5) PIC (3) pic controller (11) pic microcontroller (11) pic microcontroller tutorial (11) pic programming (1) pic programming in c (12) pic proteus (1) Pic Tutorial (12) pic18 (2) pic18f2550 (11) picmicrocontroller (4) picRFモジュール (1) PIR Motion Sensor (1) printed circuit board (1) proteus (6) pulse width modulation (1) push (1) push button (1) PWM (1) real (1) rf transmitter (3) Rs 232 (1) Rs232 (1) scroll (1) scrolling (1) Serial communication (1) Serial Connection (1) Serial Port (1) serial port rs232 (1) Servo Motembedded c programming tutorial (1) simulation (2) Soil Moisture Meter (1) speed control (1) step by step (7) step bystep (1) Stepper Motor (2) text (2) Thief Detector (1) time (1) timer (4) timer0 (4) tone (1) TSOP38236 Receiver (4) tutorial (2) Unipolar (1) USART Connection (1) USB (1) usb 1.0 (1) USB bootloadere (1) USB HID (1) using (9) voltmeter (1) voting (1) water level indicator (3) with (2) work (1)

Live Traffic Feed

Live Traffic Feed
Visitor Tracking

Comment Option isn't working properly

Comment option isn't working properly. If you have anything to say, you are requested to use the "Contact Form" below here.

Leave Your Message Here


Email *

Message *

Like on Facebook