Arduino Projects

Arduino Gas leakage detection and SMS alert MQ-2 sensor



This project is based on Gas leakage detection or smoke detection using the MQ-2 gas/smoke sensor, Arduino Uno, and GSM sim900A module. This project is used for the Gas/Smoke detection, once the Gas/Smoke is detected a message is sent to the owner. This Project can be installed in kitchens, Rooms, etc.

In my previous project, I used the same sensor with the Solenoid valve. So whenever there was a gas leakage the solenoid valve would close automatically. If you want to control the gas flow using a solenoid valve then you should definitely watch my tutorial. Which provides the best protection.

The Gsm sim900A and MQ-2 sensor interfacing with Arduino Uno or Mega is really simple which i will explain in a minute.

In this tutorial, I will show you have to make your own Smoke/ gas leakage detection and SMS alert system. This is an automatic system, a message will be sent automatically whenever the gas or smoke is detected.

Amazon Links:

Arduino Nano USB-C Type (Recommended)

12v Adaptor:

Sim900A GSM Module:

DC 5V 2A Adaptor

solenoid valve:

MQ135 Gas Sensor:

Smoke sensor MQ-2:

12V SPDT Relay:

One-Channel Relay Module:

Other Tools and Components:

ESP32 WiFi + Bluetooth Module (Recommended)

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines


Please Note: these are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!


GSM SIM900A Module:

The GSM SIM900A module is already explained in my previous tutorials. You can check out these two projects.

Arduino GSM Alarm system:

RFID and GSM based students attendance system with SMS alert:

MQ-2 Sensor:

gas leakage

The MQ-2 sensor is capable of detecting a wide range of gases including carbon monoxide, alcohol, methane, hydrogen, isobutene, liquefied petroleum gas, propane, and smoke. For the easy interfacing, the MQ-2 sensor Module is provided with 4 male headers so that it can be easily interfaced with the Arduino Uno or Mega using male to female type jumper wires.

gas leakage

MQ-2 Sensor Pinouts:

As you can see The 4 male header pins are labeled with




and Vcc…

A0 pin is the Analog output of the MQ-2 sensor module, and this pin should be connected with the analog pin of the Arduino Uno or Mega.

D0 is the digital output in the form of 5v or GND. This sensor module also has a variable resistor which can be used to change the detection level.

The MQ-2 Sensor Module GND pin should be connected with the Arduino Uno or Mega ground.

While Vcc of the MQ-2 sensor module will be connected with the 5v pin of the Arduino Uno or Mega.

MQ-2 Sensor Applications:

They are used in gas leakage detecting equipment in family and industry, are suitable for detecting of LPG, i-butane, propane, methane, alcohol, Hydrogen and smoke.

Arduino GAS Leakage Detection Circuit Diagram:

gas leakage

This schematic is designed in cadesoft eagle, if you want to learn how to make schematics and PCB, then you can watch my tutorial “Click Here link 3”. The MQ-2 Sensor  Module and gsm sim900A or Sim900D modules interfacing with Arduino /Mega is very simple.

As you know my friends GSM sim900A module communicates with Arduino using Serial communication so that’s why we have to define pins for the tx and Rx pins of the GSM module. Well, you also know that Arduino has a serial port which is on pin number0 and pin number1.

If you have watched my previous tutorials on YouTube, you will know, I always say never use the Arduino’s default serial port for the communication with other devices, you can define another serial port on any digital pins. Now the question is if we will not use the Arduino’s default serial port then how we will connect the gsm module? well no worries at all, we can define multiple serial ports using the SoftwareSerial library which I will explain in the programming.

As you can see in the circuit diagram above the tx pin of the sim900A is connected with pin7 of the Arduino, the rx Pin of the sim900A is connected with pin8 of Arduino and GND is connected with the GND of Arduino.  a power supply is connected with sim900A ideal voltage is 4.7v to 5v.

The MQ-2 sensor module VCC pin will be connected with the Arduino’s 5v, its Ground pin will be connected with the Arduino’s Ground and its A0 pin will be connected with the Arduino’s A1.

Gas leakage detection Arduino Programming:

Watch Video Tutorial:

Related Project:

IoT Smoke Detection

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Related Articles


Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button