Timely gas detection is often necessary due to a number of reasons. If a hazardous gas accidentally leaks out into a work environment. Timely implementation of a gas monitoring system can help to prevent an explosion or can prevent worker injury or exposure to toxic gases. Gas monitoring systems are generally intended for worker and plant safety, but in some cases, they are also used for process control in industries such as semiconductor manufacturing plants. In today’s tutorial, we are going to understand How to interface the MQ2 Gas sensor With Arduino Uno.
MQ2 Gas Sensor Module
MQ2 gas sensor is basically an electronic chemiresistor, a sensing material whose resistance changes when it comes in contact with a gas. It is a sensor used for sensing the concentration of gases in the air such as LPG, propane, methane, hydrogen, alcohol, smoke, and carbon monoxide.
An MQ2 gas sensor is housed within the two enclosed layers of fine steel mesh referred to as an Anti – explosion network. This steel mesh housing ensures that while sensing flammable gases such as LPG or propane, the heating element inside the MQ2 sensor will not cause an explosion
Key Features & Specifications
- Operating voltage: 5V
- Load resistance: 20 KΩ
- Heater resistance: 33Ω ± 5%
- Heating consumption: <800mw
- Sensing Resistance: 10 KΩ – 60 KΩ
- Concentration Scope: 200 – 10000ppm
- Preheat Time: <24 hour
Hardware Components
You will need the following parts to build this project:
S.No | Component | Value | Qty |
---|---|---|---|
1) | Arduino Uno | Rev 3, 8 KB | 1 |
2) | Arduino Uno USB Cable | – | 1 |
3) | Gas Sensor Module | MQ2 | 1 |
4) | Resistor | 220 Ohms | 3 |
4) | Buzzer | 5V | 1 |
5) | LED | 5mm, 3.5V | 2 |
6) | Breadboard | – | 1 |
7) | Laptop/PC | – | 1 |
8) | Jumper Wires | Male/female | As per need |
MQ2 Gas Sensor Pinout
Useful Steps
Following are the steps on How To Interface MQ2 Gas Sensor With Arduino Uno
1) Connect the analog input pin 5 of the Arduino with the analog out terminal of the MQ2 sensor. After that connect the GND terminal of the MQ2 sensor with the GND pin of the Arduino.
2) Vcc pin of the sensor with the Vin terminal of the Arduino. After that, connect the 5V buzzer on the breadboard, connect the +ve pin of the buzzer with the digital input pin 10 of the Arduino and -ve pin with the GND of the arduino.
3) After that, connect the green and red LEDs on the breadboard. Connect the +ve pin of the LEDs with digital input pin 11 & 12 of the arduino unio, and the -ve pins with the GND of the arduino UNO respectively.
4) Boot up the Arduino Uno by connecting it to a laptop or PC. After that compile the source code provided below
5) Upload the code to Arduino UNO. Power up & test the sensor.
Circuit Diagram
Source Code
int redLed = 12;
int greenLed = 11;
int buzzer = 10;
int smokeA0 = A5;
int sensorThres = 500;
void setup() {
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(buzzer, OUTPUT);
pinMode(smokeA0, INPUT);
Serial.begin(9600);
}
void loop() {
int analogSensor = analogRead(smokeA0);
Serial.print("Pin A0: ");
Serial.println(analogSensor);
if (analogSensor > sensorThres)
{
digitalWrite(redLed, HIGH);
digitalWrite(greenLed, LOW);
digitalWrite(buzzer,HIGH);
}
else
{
digitalWrite(redLed, LOW);
digitalWrite(greenLed, HIGH);
digitalWrite(buzzer,LOW);
}
delay(100);
}
Working Explanation
The working of this sensor is as follows: When sensors semiconductor particles are 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 the current to flow freely through the sensor, subsequently sending input to the analog pin of the Arduino board.
Applications
- Used in industries to test for leakages of any hazardous gases.
- Also used in modern smoke detectors to detect the presence of a burning fire in the house.
See Also: Ding Dong Sound Generator Circuit | How to setup WiFi on Raspberry Pi 3? | LC Meter Circuit using 555 Timer
could u add some block diagram ckt for this project