Gas leakage is a serious problem in households nowadays where LPG gas is used, therefore the gas leakage detection system is introduced. There are many methods available for booking a Gas Refill, methods include online booking, telephonic booking etc. It will be a difficult situation for the one who uses LPG gas for cooking regularly. The aim of this paper is to present a new system automatically books a cylinder when the gas is about to empty is by sending a notification to the gas agency using wifi using the Internet of Things approach. In addition that sensor is used to detect gas leakage at home. If the gas leakage is sensed automatically it will send an SMS to the user. wifi is one of the most used networks across the world. Hence, a load cell has been used to monitor the weight of the LPG gas regularly. The values are next fed to the microcontroller.
If the gas in the cylinder indicates a value where the remaining percentage level is crossed below the threshold level set for gas to be indicated as getting emptied, then a notification will be delivered to the gas enterprise automatically to book the new cylinder. Subsequently, a reply notification will be sent to the customer about the booking status. At the same time, application software is developed in the gas enterprise to inform and record the booking. This, work helps society to specifically indicate gas leakage and also helps both customers and the agency to get the gas booking made automatically using the IoT technique.
A wide range of MQ sensors available in the market that has the ability to measure Methane, Butane, LPG, smoke, Alcohol, Ethanol, Carbon Monoxide, Hydrogen Gas, Ammonia, etc. These sensors are widely used in Smoke Detection, Gas Detection, and Air Quality Monitoring systems. Among these, we previously used the MQ4 gas sensor in the Food monitoring system and MQ135 in the Air Quality monitoring system.
Today we will use the MQ-5 sensor to build an LPG Leakage Detector using ESP8266-01. The ESP8266 will be programmed using the Arduino Uno, and after uploading the program, ESP8266 will be interfaced with the MQ-5 sensor. Here it will use IFTTT Webhooks to send Email warnings whenever the Gas sensor detects LPG Gas.
Circuit Diagram

Components Required
- ESP8266-01 (ESP-01)
- MQ-5 LPG Gas Sensor
- 3.3 Volt Voltage Regulator (AMS1117)
- 0.1uF Ceramic Capacitor
- 47uF/16V Electrolyte Capacitor
- Push Button
- Prototype Board
- +5V Power Supply
Programming ESP-01 Using Serial Converter
Instead of using the FTDI board, here I am using Arduino Nano to program the ESP8266-01. To Program ESP8266-01 using Arduino Nano make a circuit as per the given diagram.
Connect the VCC and GND of ESP8266 to 3.3V and the GND of the Arduino. Then connect CH_PD to 3.3V and GPIO_0 to the GND of Arduino. Also, connect the RX and TX of ESP8266 to the RX and TX of Arduino Nano respectively. GPIO_0 is directly connected to the ground to enable the programming mode of ESP8266. After making the circuit as per the diagram, connect the reset pin of the Arduino Nano to the ground to bypass the Arduino. It will disable Arduino and upload the code directly to the ESP8266 board.
Now power up the Arduino Nano and open the Arduino IDE. Select the “Generic ESP8266 Module” inboard type and upload the code.
LPG Leakage Detector Circuit Diagram
After uploading the code, remove the Arduino Nano and connect the MQ-5 gas sensor with ESP8266 as per the diagram. This system will be ready to work as an LPG leakage detector.
VCC and CH_PD pins of ESP8266 are connected to the output pin of AMS1117 while the GND pin is connected to the ground of the power supply. The reset pin of ESP8266 is connected to GND through a push button. MQ-5 sensor is connected to the GPIO2 pin of ESP8266. The positive rail of the buzzer is connected to GPIO 0 of ESP8266 through a switch. The AMS117-3.3V is used to regulate 3.3V for the ESP8266-01 board.
Here we have built a small module using ESP8266-01 on the prototype board which is similar to Veroboard.
PCB Design
After designing the schematic diagram of the IoT MQ-5 gas detector system, the assembled components and wiring are too clumsy and look unprofessional. In fact, the wiring also has a chance of loose connection. Then I realised that we need to design the whole system small so that it will fit in any area of the house. To give it a clean and professional look I decided to build its PCB prototype using EasyEDA software as it is so simple to use. Now come to the main part, where we need to order our PCB prototype. I always prefer PCBWay for their quality assurance, fastest delivery and also for 24/7 customer support.


I’ve done several runs with PCBWay and am happy with the results, it’s good quality. The etching, solder mask, and hole sizes are all done well and that is what matters to me. It takes a few hours for a design to get approved and then a couple of days to finish and ship.
With more than a decade in the field of PCB prototypes and fabrication, PCBWay has proved its assurance from time to time. They always look at the needs of the customer from different regions in terms of quality, on-time delivery, cost-effectiveness and any other demanding requests. PCBWay is a place that brings manufacturers and customers together. As one of the largest and most experienced PCB manufacturers in China, PCBWay is proud to be the best business partner in any aspect of PCB needs.
Guide for Ordering PCB from PCBWay
IFTTT Setup LPG Gas Leakage Detector
Here we are using IFTTT to send Email warnings when the MQ-5 gas sensor detects the LPG gas. IFTTT is a web-based service by which we can create chains of conditional statements, called applets. Using these applets, we can send Emails, Twitter, and Facebook notifications.
- To use the IFTTT sign in to your IFTTT account if you already have one or create an account.
- Now search for “Webhooks” and click on the Webhooks in the Services section.
- Now, in the Webhooks window, click on “Documentation” in the upper right corner to get the private key.
- Copy this key. It will be used in the program.
- After getting the private key, now create an applet using Webhooks and Email services. To create an applet, click on your profile and then click on Create.
- Now, in the next window, click on the ‘This’ icon.
- Now search for Webhooks in the search section and click on Webhooks.
- Now choose the ‘Receive a Web Request’ trigger and in the next window, enter the event name as LPG_event and then click on create a trigger.
- After this, click on ‘Then That’ and then click on Email.
- Now in Email, click on send me an email enter the email subject and body and then click on create action.
ESP-01 Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | #include <ESP8266WiFi.h> const char *ssid = "Galaxy-M20"; // WiFi Name const char *pass = "ac312124"; // WiFi Password const int sensorPin= 2; const int buzzer= 0; int lpg; void send_event(const char *event); const char *host = "maker.ifttt.com"; const char *privateKey = "hUAAAz0AVvc6fsrfefe6VQWmpiGFxx3sV5rnaM9"; WiFiClient client; void setup() { Serial.begin(115200); delay(10); pinMode(buzzer, OUTPUT); Serial.println("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, pass); while (WiFi.status() != WL_CONNECTED) { delay(550); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); } void loop() { lpg = !digitalRead(sensorPin); Serial.print("Air:"); Serial.println(lpg); if (lpg == 1) { digitalWrite(buzzer, HIGH); delay(1000); digitalWrite(buzzer, LOW); send_event("LPG_event"); } } void send_event(const char *event) { Serial.print("Connecting to "); Serial.println(host); // Use WiFiClient class to create TCP connections WiFiClient client; const int httpPort = 80; if (!client.connect(host, httpPort)) { Serial.println("Connection failed"); return; } // We now create a URI for the request String url = "/trigger/"; url += event; url += "/with/key/"; url += privateKey; Serial.print("Requesting URL: "); Serial.println(url); // This will send the request to the server client.print(String("GET ") + url + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n"); while(client.connected()) { if(client.available()) { String line = client.readStringUntil('\r'); Serial.print(line); } else { // No data yet, wait a bit delay(50); }; } Serial.println(); Serial.println("closing connection"); client.stop(); } |