Design and Implementation of WSN With Real Time Monitoring of LPG Concentration for Home Safety

DOI : 10.17577/IJERTV10IS070351

Download Full-Text PDF Cite this Publication

Text Only Version

Design and Implementation of WSN With Real Time Monitoring of LPG Concentration for Home Safety

Fahad Faez Yassin Al Abdullah Electronic and Communication Engineering Collage of Engineering, Al Naharin University

Baghdad , Iraq

Prof. Dr. Anas Ali Hussein

Electronic and Communication Engineering Collage of Engineering , Al Nahrain University Baghdad , Iraq

Abstract It is common to use Liquefied Petroleum Gas (LPG) cylinders in homes for coking or heating, but this poses a great threat in case of gas leakage, there are several ways to avoid gas leakage by periodic check and maintenance to the gas regulator and hoses , or using cooking devices with auto shut in case no flame is present , but with all the mentioned ways to prevent the leakage , a great chance of leakage is still exist .

The proposed system is used to monitor in real time the concentration of LPG gas ( propane ) in ppm in home kitchen via MQ-6 gas sensor and to wirelessly send the sensed information to a raspberry pi server via Zigbee protocol , alerting the user via a graphical illustration the level of concentration and if a leak is detected , the system also can take a smart decision to turn on an exhaust fan to exhaust the LPG and to keep the home safe from explosion .

Keywords LPG; MQ6; Gas Concentration; Zigbee; XBee;



    Liquefied Petroleum Gas (LPG) is a blend of light hydrocarbon compounds. It mainly consists of butane (C4H10) or propane (C3H8) or a mixture of both. At room temperature, both gases are colorless and odorless., Liquefied Gas is heavier than air and can therefore accumulate above the ground. This may lead to LPG-leaks. It is common practice to add a foul-smelling odorant to the gas to detect leaks and reduce the risk of explosions [1].

    As the use of LPG in homes and cars increases, the number of accidents that may occurs as a result also increases. If the cylinder is not maintained or properly monitored, gas leakage from its body or valve may occur in the whole area (kitchen, gas tank area in cars) Thus a little spark will ignite and cause explosion.[2]

    In this paper, a proposed smart system can help the households owners to detect if there is a gas leakage and a smart action can be applied to eliminate that leakage or to set an alarm to indicate a leakage exists.

    1. General Objective

      To detect LPG leakage and send the results to base station.

    2. Specific Objective

      To monitor the LPG leakage levels in ppm in real time and send the obtained data wirelessly via Zigbee Protocol using XBee devices.

      To decide if the leakage is more than the set threshold and to take an appropriate action by sending a signal to the action device which can be any suggested mechanism for safety measure (shut off electronic valve, set the alarm, etc…)


    The purpose of this system is to detect and monitor gas leakage as part of a smart home safety system. The LPG concertation is always monitored and when it reaches a certain threshold level, the user will be alerted, and a smart action will be taken to eliminate the danger of this leak. The proposed system is consisting of two nodes, the senser node and the base station node, wirelessly connected via Zigbee 3 protocol.

    The responsibility of the sensor node is to monitor the concertation of LPG gas in home kitchen, and to send the data in real time to a local server (base station node) to illustrate the level of concentration and to alert the user in case of high level of gas concertation is detected, and to send a proper order to the action device.

    Fig. 1. Proposed system diagram

  3. SYSTEM REQUIRMENTS (Hardware & Software)

    The proposed system consists of the following parts:

    Hardware Requirments

      • Sensor Node

        • Microcontruller (Arduino Uno 3).

        • XBee Shield.

        • Gas Sensor (MQ-6).

        • Zigbee Transceiver (Digi XBee 3).

        • Action Device (Alaram buzzer or exhaust fans, electronic valve, etc)

      • Base Node

        • Raspberry Pi 3B+.

        • Zigbee Transceiver (Digi XBee 3).

    Software Requiremtns

    • Sensor Node:

      • Arduino IDE.

    • Base Node:

      • Node-Red

    1. Gas Sensor (MQ-6)

      Fig. 3. XBee Shield

      • Zigbee Transvers (Digi Xbe):

        o XCTU


        1. – Microcontroller (Arduino Uno 3)

          The Arduino Uno is a microcontroller board based on a removable, dual-inline-package (DIP) ATmega328 AVR microcontroller. It has 20 digital input/output pins (of which 6 can be used as PWM outputs and 6 can be used as analog inputs). Programs can be loaded on to it from the easy-to-use Arduino computer program.

          The MQ-6 module is used in gas leakage detecting equipment in home and industry, this module has high sensitivity to LPG, iso-butane, propane and LNG.

          The module gives out the concentration of the gases as a analog voltage equivalent to the concentration of the gases. The module also has an onboard comparator for comparing against an adjustable preset value and giving out a digital high or low.

          Gas Sensor

          Gas Detected


          flammable gases such as LPG and propane




          methane (CH4) and natural gas


          LPG and methane


          LPG and methane


          carbonic monoxide (CO) and hydrogen (H2)


          hydrogen (H2)


          gaseous ammonia (NH3), benzene, ethyl alcohol and carbonic dioxide (CO2).

          Table 1 . MQ Sensors type and their gas detection type

        2. Xbee Shiled

        Fig. 2. Arduino Uno 3

        The Xbee shield allows an Arduino board to communicate wirelessly using Zigbee. It is based on the Xbee module from MaxStream. The module can communicate up to 100 feet indoors or 300 feet outdoors (with line-of-sight). It can be used as a serial / usb replacement, or you can put it into a command mode and configure it for a variety of broadcast and mesh networking options. The shields break out each of the XBee's pins to a through-hole solder pad. It also provides

    2. Xbee 3

      Fig. 4. MQ-6 Gas Sensor

      female pin headers for use of digital pins 2 to 7 and the analog inputs, which are covered by the shield (digital pins 8 to 13 are not obstructed by the shield, so you can use the headers on the board itself).

      XBee is a module produced by Digi International mainly use as a radio communication transceiver and receiver. It is mesh communication protocols that sits on top of IEEE

      802.15.4 ZigBee standard. XBee supports peer-to-peer as well as point to multi-point network communications wirelessly with the speed of 250 kbits/s .

      7 Node – Red

      Node-RED is a programming tool for wiring together hardware devices, APIs and online services in new and interesting ways.

      It provides a browser-based editor that makes it easy to wire together flows using the wide range of nodes in the palette that can be deployed to its runtime in a single-click [4].

    3. Raspberry Pi 3B+

    Fig. 5. DIGI XBee 3

    The Raspberry Pi 3 Model B+ isthe latest product in the Raspberry Pi 3 range, boasting a 64-bit quad core processor running at 1.4GHz, dual-band 2.4GHz and 5GHz wireless LAN, Bluetooth 4.2/BLE, faster Ethernet, and PoE capability via a separate PoE HAT The dual-band wireless LAN comes with modular compliance certification, allowing the board to be designed into end products with significantly reduced wireless LAN compliance testing, improving both cost and

    8 XCTU

    Fig. 6. Node-Red home page

    time to market.

    The Raspberry Pi 3 Model B+ maintains the same mechanical footprint as both the Raspberry Pi 2 Model B and the Raspberry Pi 3 Model B.

    XCTU is a free multi-platform application designed to

    enable developers to interact with Digi RF modules through a simple-to-use graphical interface. It includes new tools that make it easy to set-up, configure and test XBee® RF modules.

    XCTU includes all of the tools a developer needs to quickly get up and running with XBee. Unique features like graphical network view, which graphically represents the XBee network along with the signal strength of each connection, and the XBee API frame builder, which intuitively helps to build and interpret API frames for XBees being used in API mode, combine to make development on the XBee platform easier than ever.

    6 Arduino IDE

    Fig. 6. Raspberry Pi 3B+

    The Arduino IDE is a cross-program application created in Java and is originate from IDE for the deal with a programming language and the wiring project. It is proposed to establish programming to a performer and other new users unfamiliar with software enhancement. It includes code editor

    with features such us syntax importance, automatic indentation, brace matching, and is also qualified of compiling and uploading a package to the board with a specific click [3].

    Fig. 7. XCTU application interface


    1. Proposed System Flow Chart

      In the below flow chats, both show the steps that the propose system takes to fulfill the required goal

      Fig. 8. Sensor node flow chart

      Fig. 9. Base node flow chart

    2. LPG Concentration Measurements

      When the MCU is powered up, it continually ask for the status of the sensor , the code is designed to get the output voltage of MQ-6 sensor and calculate the concertation in ppm , send it wirelessly to base node via ZigBee 3 protocol .

    3. Gas Sensor

      MQ-6 [5] gas sensor is highly sensitive to LPG, iso- butane, propane. Unlike MQ-2 Sensor, it has a small sensitivity to smoke, thats why it has better LPG detection since avoid the noise of alcohol and cooking fumes and cigarette smoke.

      The sensor-based module version has a digital pin and analog pin which is TTL driven and works on 5V. For the measurement of a particular gas or multiple

      gases, read the analog values with the analog pin of the module (0-5V). The analog output voltage provided by the sensor changes in proportional to the concentration of smoke/gas. The greater the gas concentration, higher the output voltage, while lesser gas concentration results in low output voltage.

      Arduino reads analog voltage from the sensor, Arduino has 10-bit converter means there are 1024 distinct values. i.e., 210=1024

      Output value= (Input value/1023) *Max Output value.

      Here we are mapping output voltage (0-5V) into integer value between 0 and 1023. Ex (511.5/1023) *5=2.5V.

      1. Sensing Material

    MQ-6 sensor is enclosed in two layers of fine stainless steel mesh called Anti-Explosion network. it ensures the heating element inside the sensor will not cause an explosion as it is sensing a flammable gas. [6].

    The tubular sensing element is made up of Aluminum Oxide (AL2O3) based ceramic and has a coating of Tin Dioxide (SnO2). The Tin Dioxide is the most important material being sensitive towards combustible gases. However, the ceramic substrate merely increases heating efficiency and ensures the sensor area is heated to a working temperature constantly. So, the Nickel- Chromium coil and Aluminum Oxide based ceramic forms a Heating System, while Platinum wires and coating of Tin Dioxide forms a Sensing System.

    a. Work Principle

    When tin dioxide (semiconductor particles) is heated in air at high temperature, oxygen is adsorbed on the surface. In clean air, donor electrons in tin dioxide are attracted toward oxygen which is adsorbed on the surface of the sensing material. This prevents electric current flow.

    In the presence of reducing gases, the surface density of adsorbed oxygen decreases as it reacts with the reducing gases. Electrons are then released into the tin dioxide, allowing current to flow freely through the sensor.


    1. Sensing Node Design

      Measuring a particular gas requires so complicated approaches, so in order to measure a gas concentration in ppm , the following steps had been followed .

      Fig. 10. Sensitivity Characteristics of MQ6 Gas sensor

      1. Analysis of MQ-6 gas sensor graph [5]

        The fig above show the sensitivity characteristics to different gases, we notice two parameters that are used to form these curves . The concertation of mentioned gases is expressed in ppm with respect to Rs/Ro value .X axis represents gas concentration in ppm while Y axis represents Rs/Ro Ratio, where Rs is the resistance of the sensor and Ro is the resistance of the clear air .

      2. Calculations

        To calculate the concentration in ppm for a particular gas , we need to determine the value of Rs/Ro Ratio of that gas and to compare it with the curve from the datasheet .

        This can be done by two steps, first we need to calculate the Ro ( resistance of the surrounding air ) , Ro is determined by dividing Rs ( resistance of clear air ) over Ro of clear air which is 10 for MQ-6 gas sensor from the datasheet)

        Ro = Rs of surrounding air / Ro of clear air (1) RS is determined using the following equation:

        RS = (Vc / VRL -1) X RL (from data sheet) . (2)

        Finally, the ratio Rs/Ro is obtained, which describes the behavior of the sensor at different gas concentration.[5]

        to calculate the concentration of a gas in ppm (parts per million) we need to derive an equation from the sensitivity characteristic of the LPG gas, we note down Rs/Ro values with the respective ppm in a table.

        the program (Get Data graph digitizer) was used to digitize the sensitivity graph to get the Rs/Ro VS ppm values accurately.

        Fig. 11. GetData Graph digitizer interface

        LPG Gas Concertation in ppm

        Rs/Ro Ratio



















        Table 2 . MQ-6 Sensitivity Characteristics to LPG as obtained from Data sheet using GetData Graph digitizer

        After getting the values on table 2, using Excel software to draw the curve for these values.

        It was observer the trend line shows the closest equation to the described curve, and the power function gets the best fit.

        Fig. 12. MQ-6 Curve as obtained by excel

        Using the power regression, we can find the equation for the two variable Rs/Ro and the ppm

        Y = 18.611x-0.421

        Where Y represents the Rs/Ro, x represents the requires ppm, thus:

        ppm = ((Rs/Ro) / 18.611 )1/-0.421

        same procedure can be done for all gases sensed by the MQ-6 or MQ Sensor, for better results we must preheat the sensor for 48 hours.

        in fig (12) we see that R Squared (R2 = 0.9992) which is an indicator of how well our data fits the modl of regression, it is the square of the correlation efficient r.

        R2 that equals to 1 indicates a perfect fit, so our equation indicates a strong correlation.

      3. Calibration, Ro in Fresh Air

        As Ro may differ from place to place depending on the temperature and humidity of that place , a calibration algorithm was designed to get the appropriate Ro to any place in fresh air , this algorithm is done by Arduino uno 3 and was logged over the period of 24 hours, after a preheat for the MQ6 coils for 48 hours as recommended in data sheets ,to make sure that the Gas sensor is heated up and the all measurement stabilizes .

        The average result was taken for the calculated calibrated Ro. Result was Ro = 0.33

        Fig. 13. Running Code on Arduino to find Ro Value.

    2. Base Node Design

    The base node (receiving node) consists of a server (Raspberry pi) with a coordinator (XBee 3) attached to its usb port.

    Using Node Red software, flow chart was designed and coded to receive the incoming information (LPG ppm Value) and to display it using a graphical illustration as a gauge, also to set an If condition in case the ppm value exceed the threshold value (1,500 ppm) to send an action signal to sensor

    node XBee to pass the command to Arduino and to take the appropriate action.

    Reference to a document from New Jersy Department of Health , ( 2,100 ppm ) is immediately dangerous to life and health [8] thats why the chosen threshold value was set to 1,500 ppm .


    The final code that will be run by Arduino consist of the below steps:

    1- Always calibrate the sensor and take the average of 100 analog reading.

    2 Finding Rs/Ro Ratio, After finding Ro value in the specific area (as was done in section Calibration, Ro in Fresh Air) , we can find RS/Ro Ratio by the following formula:

    RS_gas = (5.0-sensor_volt)/sensor_volt ratio = RS_gas/0.33

    where sensor volt is read by Arduino. 3 – Finding LPG PPM

    Finally, we can calculate the PPM of the LPG by applying following formula which was derived from the Data sheet graph:

    X = (ratio/18.611)

    ppm = pow (X, (1/-0.421)) 4 Sending results:

    By using XBee Shield with XBee 3, we can send the ppm values to the base station which is connected to a raspberry pi hosting Node Red software to show the result in a graphical illustration for real time monitoring.

    Fig. 14. Node Red Flow to extract information and show it .

    Fig. 15. Node Red Graphical illustration LPG Gauge.

    Fig. 16. Different gauge status after applying LPG source to sensor.


    The developed LPG monitoring system accurately measured the concertation of LPG in the experiment area, the system is integrated with IoT to send the data in real time to the home owner, it also can be stored in database to see if a continues leakage exist so the home owner can check for maintenance. it helps normal people to have the needed security for their homes against leakages.

    The system can be installed in home kitchen in a constant way and can be either battery powered or directly powered.


The system is only monitoring one home, future work can be done to monitor several apartments in a living building and each node can send information about the number of the apartment and its LPG statues.

More actions can be made such as installing electronic Gas valves that shut down in case of a leakage and can be restored to work by the main system.

Minimizing the footprint of the system and build it on a PCB board will help to make system a smaller package and portable.


Fig. 17. Base Node



  3. R. N. Naik, P. S. N. Reddy, S. N. Kishore, and K. T. Kumar Reddy. (2016). Arduino Based LPG gas Monitoring & Automatic Cylinder booking with Alert System. IOSR J. Electron. Commune., (vol. 11, no. 4, pp. 06-12).


  5. Technical Data Sheet for MQ-6 [available online]


If the value of LPG ppm is above the threshold value ( which is set to 1500 ppm ) a signal will be sent from the base node to the sensor node to take an action ( in this system a LED will turn ON as an indicator of receiving signal ) .

Leave a Reply