How To DevCreate a Gas Leakage Detection System Using Arduino UNO R3

Introduction 
 
The internet of things is a technology; it can connect many physical devices with other devices through the Internet. These connected physical devices are controlled and monitored anywhere & anytime throughout the world.
 
In this article, we are solving a home LPG Cylinder fire prevention system using IoT technology. By reading this, you will learn how to develop an LPG gas detection system using Arduino UNO R3

Prerequisites 

Hardware requirements:
 
Hardware  Nos
Arduino UNO R3  1
 Data cable for (Arduino)   1
 MQ-2 Gas Sensor   1
 LCD crystal [16x2] Display   1
 Breadboard   1
 220-ohm Resistor  1
10-ohm Potentiometer 
 1
 Jumper wires  -
 Gas Lighter [For checking Gas Leakage]  1
 
Software requirements:
 
Arduino IDE (Click the link to Download Arduino IDE)
 
In this experiment, we can do three stages of work to develop a gas detection system
  1. Connect all the hardware
  2. Write & upload code to Arduino board
  3. Test our developed system
Stage 1 (Connect all hardware)
 
First, we can connect an LCD crystal display with an Arduino UNO board using jumper wires. I am using a breadboard to extend power terminals for making this system.
 
Refer to the below LCD crystal Pin diagram for making an easy connection with Arduino
 
 
Place a 10K ohm potentiometer near the LCD crystal display. It can adjust the contrast of the LCD screen and create a power connection from Arduino +5V and GND right and left end of the potentiometer. Make a connection from the center terminal of the potentiometer to VEE (contrast control) LCD crystal display. (Refer to the connection diagram)
 
Pin Configuration
 
 
Arduino Breadboard LCD Crystal Display
 
Pin 2 ---------------------------------------------------------------------------------------------------> Data pin 4
Pin 3 ---------------------------------------------------------------------------------------------------> Data pin 5
Pin 4 ---------------------------------------------------------------------------------------------------->Data pin 6
Pin 5 -----------------------------------------------------------------------------------------------------> Data pin 7
Pin 7 ----------------------------------------------------------------------------------------------------> Register select
Pin 6 ---------------------------------------------------------------------------------------------------> Enable
+ 5V ----------> Potentiometer Right Terminal------>Potentiometer Centre terminal ----> VEE (Contrast Control) LCD crystal
+5V ---------------------------> 220-ohm Resistor ----------------------------------------------> LED +5V pin [LCD Crystal]
GND ---------------------------------------------------------------------------------------------------->Potentiometer Left terminal, Ground pin & LED - Ground pin [Connect to both pin]
 
Step 2
 
Next, we can connect an MQ-2 Gas sensor to Arduino, it’s very simple to connect this with the Arduino board.
 
Arduino MQ-2 Gas sensor 
 
 A3 ------------------------------------------> A0 [Analog output pin]
+ 3.3 v or 5 V ---------------------------------> Vcc
GND --------------------------------------------> GND
 
All hardware connections are perfectly done :) 
 
Stage 2 [Write & upload code to the Arduino board]
 
In this step, write code for Arduino using the Arduino IDE.
  1. Download Arduino software using this link here.
  2. Install and open an Arduino IDE on your PC/Laptop
  3. Connect your Arduino board to your computer using a USB data cable
  4. Copy and paste below the code into the Arduino IDE
  1. #include<LiquidCrystal.h>  
  2. #define LCD_PIN_RS  7  
  3. #define LCD_PIN_E 6  
  4. #define LCD_PIN_DB4 2  
  5. #define LCD_PIN_DB5 3  
  6. #define LCD_PIN_DB6 4  
  7. #define LCD_PIN_DB7 5  
  8.   
  9. #define gassensor A3  
  10. LiquidCrystal lcd(LCD_PIN_RS,LCD_PIN_E,LCD_PIN_DB4,LCD_PIN_DB5,LCD_PIN_DB6,LCD_PIN_DB7);  
  11.   
  12. void setup() {  
  13.   Serial.begin(9600);  
  14.   lcd.begin(16, 2);  
  15.   
  16. }  
  17.   
  18. void loop() {  
  19. lcd.setCursor(0, 0);  
  20. lcd.print("C-ShCor Gas detection  System");  
  21. delay(500);  
  22. gasread();  
  23. }  
  24. void gasread()  
  25. {  
  26.   int d =analogRead(gassensor);  
  27.   if(d<80)  
  28.  {  
  29.   lcd.setCursor(0,1);  
  30.   lcd.print("No Gas Flow ");  
  31.   Serial.println("No Gas flow ");  
  32.   }  
  33. else if (d>90&&d<110)  
  34.  {  
  35. lcd.setCursor(0,1);  
  36. lcd.print("Mild Gas Leak ");  
  37.   Serial.println("Mild Gas Leak ");  
  38. }  
  39. else if(d>110 && d< 150)  
  40. {  
  41. lcd.setCursor(0,1);  
  42. lcd.print("Gas Leak detect ");  
  43.   Serial.println("Gas Leak Detect ");  
  44. }  
  45. else if (d>150&&d<300)  
  46. {  
  47. lcd.setCursor(0,1);  
  48. lcd.print("Danger in home ");  
  49.   Serial.println("Danger in home ");  
  50. }}  
Save and upload this code to the Arduino UNO board, After Code upload is completed that device can start to detect Gas Leakage.
 
Stage 3 [Test our developed System]
 
Our device is ready… Let's create a manual gas leak using a gaslighter.
 
 
The gas detection system can detect a gas leakage successfully. It's working perfectly!