Introduction:
This is a robust Gas sensor suitable for sensing LPG, Smoke, Alcohol, Propane, Hydrogen, Methane and Carbon Monoxide concentrations in the air. If you are planning on creating an indoor air quality monitoring system; breath checker or early fire detection system, MQ2 Gas Sensor Module is a great choice.
In this project, you will learn the sensor Analog output voltage and when the smoke reaches a certain level, it will make sound a buzzer and a red LED will turn on.
When the output voltage is below that level, a green LED will be on.
How does it Work?
The voltage that the sensor outputs changes accordingly to the smoke/gas level that exists in the atmosphere. The sensor outputs a voltage that is proportional to the concentration of smoke/gas.
In other words, the relationship between voltage and gas concentration is the following:
- The greater the gas concentration, the greater the output voltage
- The lower the gas concentration, the lower the output voltage
Component Required:
Arduino Uno
Uno Cable
MQ-2 Smoke Detection Sensor
Breadboard
Male-Female Jumper Wire
1 x 5mm LED Red
1 x 5mm LED Green
Buzzer
3 x Resistor 221ohm
9v Battery
Battery Snapper Connector
Circuit Diagram:
Connections:
Connect sensor A0 pin to Arduino A5 pin
Connect sensor GND pin to GND
Connect sensor Vcc pin to Vcc
Connect buzzer +ve to Arduino pin 10
Connect buzzer -Ve to GND through 221ohm resistor
Connect +ve pin of Red led to Arduino pin 12
Connect -ve pin of red led to GND through 221ohm resistor
Connect +ve pin of Green led to Arduino pin 11
Connect -ve pin of Green led to GND through 221ohm resistor
Code for Smoke Detection using MQ-2 Gas Sensor
int redLed = 12;
int greenLed = 11;
int buzzer = 10;
int smokeA0 = A5;
// Your threshold value
int sensorThres = 165;
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);
// Checks if it has reached the threshold value
if (analogSensor > sensorThres)
{
digitalWrite(redLed, HIGH);
digitalWrite(greenLed, LOW);
tone(buzzer, 1000, 200);
}
else
{
digitalWrite(redLed, LOW);
digitalWrite(greenLed, HIGH);
noTone(buzzer);
}
delay(100);
}
If you have any query please write us at support@zbotic.in
YOU CAN BUY MQ-2 GAS DETECTION PROJECT KIT ON ZBOTIC
Please click below link
Hope you understand the project well and if you are facing any errors do inform us in the comments section below.
Leave a reply