Over a million developers have joined DZone.

Gas Leakage Detection in Home With IoT

DZone 's Guide to

Gas Leakage Detection in Home With IoT

Want to learn how to create a gas leakage detection device in your home using IoT? Check out this post to learn how using the Intel Edison board and Grove Base Shield.

· IoT Zone ·
Free Resource

Gas leakage can become a disaster for any family. In India, where cooking gas is made available in steel canisters, this type of mishap can happen frequently. To solve this problem, we can make a gas leakage detection monitor with Intel Edison.

This project is easy, and we will only use a simple MQ5 sensor. So, let’s see how we can make a gas leakage detection monitor with the IoT.


  • Intel Edison board
  • Power supply
  • Grove Base Shield
  • Grove MQ5 Gas Sensor
  • USB cables
  • Jumper Cables

MQ5 Gas Sensor

Image title

The Grove – Gas Sensor(MQ5) module is useful for gas leakage detecting (in home and industry). It can detect LPG, natural gas, town gas, and so on. Due to its high sensitivity and fast response time, measurements can be taken as soon as possible. The sensitivity of the sensor can be adjusted by using the potentiometer provided.

Image title

Features of MQ5 Sensor

  • Wide detecting scope
  • Stable and long life
  • Fast response and high sensitivity


  • Connect the Edison to Power supply. Wait for 15-20 seconds.
  • Now, connect it to your computer with USB cables.
  • Connect MQ5 Sensor to A0 Pin.

MQ5 is an analog output sensor. This needs to be connected to any one analog socket in Base Shield. I have connected it to the A0 pin of the Base Shield. It is also possible to connect the Grove module to Edison directly by using jumper wires. The output voltage from the gas sensor increases when the concentration of gas increases. Sensitivity can be adjusted by varying the potentiometer. Please note that the best preheat time for the sensor is above 24 hours.


void setup() {
void loop() {
    float sensor_volt;
    float sensorValue;
    sensorValue = analogRead(A0);
    sensor_volt = sensorValue / 1024 * 5.0;
    Serial.print(“sensor_volt = “);

Image title

The voltage read from the sensor is displayed. This value can be used as a threshold to detect any increase/decrease in gas concentration.

Image title

Note: Best preheat time for the sensor is above 24 hours.

iot ,tutorial ,mq5 ,gas sensor ,sensor ,home ,smart home ,gas leak ,intel edison

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}