MQ-5 Combustible Gas Sensor Interfacing with Arduino

Published  May 12, 2022   0
Arduino MQ5 Gas Sensor

Nowadays, natural gasses are everywhere. They are easy to transport and provide energy for various tasks in both household and industrial use. It also possesses a significant risk of fire if not handled carefully. This is where MQ-5 Combustible Gas Sensor comes into play. The MQ-5 Combustible Gas Sensor can detect LPG, H2, LPG, CH4, and CO. So in this article, we are going to discuss the MQ-5 sensor, and attach that to an Arduino to see what happens when gases are moved closer to it. Let's dive into it.

MQ-5 Sensor Pinout

MQ5 Gas Sensor Pinout

VCC To +ve of power supply

GND To -ve of power supply

DOUT Sensor data output in digital form

AOUT Sensor data output in analog form

MQ-5 Sensor Module – Parts

The MQ-5 Sensor is popular among beginners since it detects combustible gases in most Arduino projects. Likewise, these are low-cost, easy-to-use sensors with a wide detection range that may be reduced to modify sensitivity. The component markings for the MQ-5 Sensor are given below.

MQ5 Gas Sensor Module Parts

There are four pins on the MQ-5 Sensor Module, two of which are for VCC and GND. Like the other basic sensor modules, the other two can produce analog and digital data simultaneously. Because the module's operating voltage range is 5V with a 0.1 percent precision, we're using the Arduino's 5V pin to power the circuit. As seen in the illustration, the module has two built-in LEDs. The power LED turns on when the board is powered up, and the Dout LED turns on when the potentiometer's trigger value is reached. The entering analog signal from the gas sensor is converted to a digital signal by an OP-Amp comparator on this board.

How Does the MQ-5 Sensor Module Work?

To effectively detect combustible Gas, the MQ-5 Sensor requires a heating element. Putting a heating source close to combustible Gas, on the other hand, may be harmful. As a result, the Sensor has an anti-explosion network made up of two thin layers of stainless steel mesh, as seen in the illustration below. A heating element is included in this stainless steel mesh.

MQ5 Gas Sensor

Only gaseous components from the environment travel through this mesh structure, which protects against dust and other suspended particles. We can see that the Sensor comprises two main components when we disassemble it. The heating element is composed of nichrome wire, while the detecting element is platinum wire with a tin dioxide covering. The mesh decapped from the real Sensor is shown below.

MQ5 Gas Sensor Module Parts

This is what the Sensor looks like when the mesh is removed. As you can see in the above image, we cut the stainless steel mesh and positioned it on the side of the Sensor. The previously mentioned sensing feature is now evident as well. The star-shaped pins on the Sensor are made by attaching the actual detecting and heating element to the Sensor's six legs. The black Bakelite base of the Sensor, which promotes heat conductivity, can also be observed.

Preheat Time for MQ-5 Sensor:

Working with a combustible gas sensor like this necessitates a warmup or stabilization phase before the instrument can work properly. The datasheet for the module indicates that it requires a 24-hour warmup time. Is this implying that it must be switched on for 24 hours before being used?

The answer to this question is NO. To obtain the standard performance values listed in the datasheet, you must run it constantly for 24 hours. After 24 hours, it was evaluated in their lab. If you want to keep inside the limitations, you'll have to stick to the 24-hour preheating time. Given the Sensor's small size, thermal equilibrium will almost certainly be achieved within 30 minutes. And reaching within a few percent of the datasheet's values would likely take a few minutes.

If you want a precise gas concentration measurement, a 24-hour warm-up time is required. You'll also need a reliable sensor calibration and a mechanism to account for other factors such as temperature, humidity, and so on.

The MQ-5 Sensor can detect and quantify gas concentrations in PPM. It's important to remember that sensing the vapor and measuring its concentration in PPM are not the same thing. The main focus of this article is on observing increases in gas levels and concentration. If you want to calculate the gas level in PPM accurately, the method is slightly different; still, we'll go through it briefly.

How to use MQ-5 Sensor to Detect Combustible Gas?

MQ5 Gas Sensor Working

In the above animation, we have a bottle holding LPG, and as it is sprayed, the gas concentration in the surroundings increases. The gas content grows as we pour it a second and third time. As the gas content grows, the Sensor's output voltage rises, as visible on the multimeter. When the module's green LED reaches a certain threshold, it glows (which may be controlled using the potentiometer). The backside shot of the module that we've supplied for demonstrative reasons demonstrates this.

How to Measure Gas Concentration in PPM using the MQ-5 Sensor?

This is a very accurate sensor that is calibrated to detect the PPM of combustible gas present in the environment; but, in order to do so, you must first understand the MQ-5 Sensor's sensitivity characteristics, which can be found in the MQ-5 Sensor datasheet and look like the image below.

MQ-5 Sensor's Sensitivity Characteristics

RS is the sensing resistance in the presence of Gas on the logarithmic graph. The sensory resistance to pure air is R0. Because this Sensor is intended to detect combustible Gas and has a low sensitivity to alcohol and smoke, its resistance will alter depending on the amount of Gas in the air.

Commonly Asked Questions about MQ-5 Gas Sensor Module

Q-1: What is the range of the MQ-5 Sensor?

The MQ-5 Sensor can detect LPG and CH4 between 300 to approximately 10000ppm.

Q-2: What does the MQ5 sensor detect?

The Gas Sensor(MQ5) module is excellent for detecting gas leaks (in home and industry). It may be used to detect H2, LPG, CH4, CO, and alcohol. Measurements can be conducted as quickly as feasible because of its high sensitivity and quick reaction time.

Q-3: What is MQ in MQ sensor?

It is a Metal Oxide Semiconductor (MOS) type Gas Sensor, also known as Chemiresistors since the detection is dependent on a change in the sensing material's resistance when the Gas comes into contact with it.

Q-4: What is ppm for Gas?

Parts-per-million, or "ppm," is a popular fractional unit of concentration measurement.

Internal Schematic of MQ-5 Sensor Module

The circuit schematic for the MQ-5 Gas Sensor Module is shown below. The design of this module is simple and only takes a few components to put together. If you're in a hurry to build this circuit, the schematic shown below will come in handy.

MQ5 Gas Sensor Circuit Diagram

In the schematic, we have an LM393 op-amp, which is a low-power, low-offset voltage op-amp that can be driven by a +5V supply. The circuit cannot be powered using 3.3V since the MQ-5 Sensor's minimum working voltage is 5V. The function of this op-primary amp is to convert an input analog signal to a digital signal. Aside from that, the MQ-5 Gas Sensor module has an integrated 10K potentiometer for adjusting the sensitivity of the triggering voltage. Aside from that, two LEDs are present. The first is the power LED, and the second is the trigger LED. The power LED lights when the board is powered up. The trigger LED lights when a predefined threshold is reached. Finally, the board has two decoupling capacitors that aid to reduce noise.

MQ-5 Gas Sensor with Arduino UNO – Connection Diagram

Now that we understand how the MQ-5 gas sensor operates, we can connect all of the necessary wires to an Arduino Uno and test it out. We'll start with the analog component and then move on to the relatively basic digital component.

To use the Sensor, we must first turn it on. The 5V and GND pins on the Arduino UNO Board are used, and the Sensor's output pin is linked to the A0 pin on the Arduino.

Interfacing MQ5 Gas Sensor with Arduino

We have connected an LED and a buzzer to digital PIN 7 of the Arduino, the analog pin to the A0 pin of the Arduino, and the ground pin is shared between the led, Sensor, and the buzzer, as shown in the above diagram. We'll configure the Arduino such that the LED and buzzer both turn on when Gas is detected.

Arduino MQ5 Sensor Project

Simply connect the Sensor's output to any digital pin on the Arduino and check for a high pulse; if the Arduino reads a high pulse, Gas has been detected; if the Arduino reads a low pulse, no Gas is present in the environment.

Arduino Code for Interfacing MQ-5 Gas Sensor Module

The Arduino MQ-5 gas sensor module's coding is straightforward. We're simply reading the Sensor's analog data and turning the LED and Buzzer ON or OFF. Please bear in mind that we are just processing analog data from the Sensor; the module's inbuilt LED will light up to indicate digital data.

We define two macros: the first one is for the output pin 7 and the second one is sensors analog input pin A0.

#define ledPin 7
#define Sensor A0

We set the pins to take input from the Sensor and the output from the Arduino to drive the LED and Buzzer via Arduino's pin 7.

  pinMode(sensor, INPUT);
  pinMode(ledPin, OUTPUT);

As mentioned before, the MQ-5 needs to heat up for a while before giving a precise measurement of the Gas. This section of the code halts everything and for 20 seconds heats up the Sensor.

 Serial.println("MQ5 Heating Up!");
  delay(20000); // allow the MQ5 to warm up

This section of the code reads the data from the analog pin from the sensor module and prints the value on the serial monitor.

gas_value = analogRead(sensor);
   Serial.print("Sensor Value:");

If the sensor value goes above 250, the Led and Buzzer will turn on and notify both audibly and visibly that Gas is present in the environment.

if (gas_value > 250) {
    digitalWrite(ledPin, HIGH);
    digitalWrite(ledPin, LOW);

Working of the MQ-5 Sensor Module

In the animation below, the MQ-5 Sensor is displayed in action. The LED is off while there is no butane in the environment, but it turns on when we supply a little bit of butane from a lighter since we wrote the code to do so.

Supporting Files