LPG Sensor Using Arduino Uno

In this article you will learn how to find LPG gas leakages detected using the LPG Gas Sensor.

Introduction:
 
In this article I'll show you that how can we find out the LPG gas using the MQ2 Gas sensor and print the value in LCD (Liquid Crystal Display).
 
Requirements:
  • Arduino Mega
  • Bread Board
  • MQ2 Gas Sensor
  • LCD 16*2
  • Led
  • Buzzer 
Connection:
 
 
Led:
  • Anode to Digital Pin 12
  • Cathode to Gnd  
Buzzer:
  • Anode pin to Digital Pin10
  • Cathode pin to the gnd  
Programming: 
  1. #include < LiquidCrystal.h >  
  2.     int mq = A0;  
  3. int led = 12;  
  4. int buz = 10;  
  5. int m;  
  6. float p;  
  7.   
  8. LiquidCrystal lcd(2, 3, 4, 5, 6, 7);  
  9.   
  10. void setup()  
  11. {  
  12.     pinMode(led, OUTPUT);  
  13.     pinMode(buz, OUTPUT);  
  14.     digitalWrite(led, LOW);  
  15.     digitalWrite(buz, LOW);  
  16.     lcd.begin(16, 2);  
  17. }  
  18. void loop()   
  19. {  
  20.     d = analogRead(mq);  
  21.     lcd.setCursor(0, 0);  
  22.     lcd.print("LPG GAS SENSOR");  
  23.   
  24.     if (m > 60)   
  25.     {  
  26.         p = 0;  
  27.     } else   
  28.     {  
  29.         p = (m - 60) / 9.64;  
  30.     }  
  31.     lcd.setCursor(0, 1);  
  32.     lcd.print(p);  
  33.     lcd.setCursor(5, 1);  
  34.     lcd.print("%");  
  35.     if (p >= 30)   
  36.     {  
  37.         digitalWrite(led, LOW);  
  38.         digitalWrite(buz, HIGH);  
  39.         lcd.setCursor(9, 1);  
  40.         lcd.print("Little Leakage");  
  41.     } else   
  42.     {  
  43.         digitalWrite(led, HIGH);  
  44.         digitalWrite(buz, LOW);  
  45.     }  
  46.     delay(500);  
  47.     lcd.clear();  
  48. }  
Explanation:
  • The Gas Sensor is connected to the analog input pin A0.
  • The Digital pin 10 is used to control the buzzer.
  • The Digital Pin 12 is connected to the led.
  • If the Gas sensor value is less than 60.
  • The Buzzer and led is ON.
  • Displays the result in liquid crystal display. 
Output:
 
 

Read more articles on Arduino: