Project tutorial
MQ-2 Gas Sensor Arduino

MQ-2 Gas Sensor Arduino © GPL3+

I have worked on MQ-2 gas sensor (FC-22) powered and interfaced it with an Arduino Uno.

  • 23,133 views
  • 4 comments
  • 6 respects

Components and supplies

Apps and online services

About this project

Posted on May 30, 2017 by electromaniaweb

As I currently reside in India, most of the houses here have a LPG -Gas stove system for cooking food and various other kitchen activities. There are LPG cylinders which are used as a fuel source for the gas stove.

Many a times, disastrous accidents take place due to leakage of these cylinders, in these situations we must administer proper care and safety.

Keeping this in mind, in today’s post I have worked on MQ-2 gas sensor (FC-22) powered and interfaced with Arduino Uno.

Here is its datasheet :-http://www.allelectronics.com/mas_assets/theme/allelectronics/spec/GS-29.pdf

Now, First of all you will require these components:

  • Arduino UNO
  • Breadboard
  • LED’s
  • Resistors
  • Jumper wires
  • MQ-2 gas sensor.
  • Buzzer

Circuit diagram:

MQ-2 Pin diagram:

That’s it guys.Install this in your kitchen or garage for better safety and protection of your loved ones.

Code

Code snippet #1Plain text
******
 
 All the resources for this project:
 https://www.electromaniaweb.wordpress.com 
https://www.arduino.cc

*******/

int LED1 = 12;
int LED2 = 11;
int buzzer = 10;
int smokeA0 = A5;
int sensorThreshold = 400;

void setup() {
  pinMode(LED1, 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 > sensorThreshold)
  {
    digitalWrite(LED1, HIGH);
    digitalWrite(LED2, LOW);
    tone(buzzer, 1000, 200);
  }
  else
  {
    digitalWrite(LED1, LOW);
    digitalWrite(LED2, HIGH);
    noTone(buzzer);
  }
  delay(100);
}
CODEArduino
All the resources for this project:
 https://www.electromaniaweb.wordpress.com 
https://www.arduino.cc

*******/

int LED1 = 12;
int LED2 = 11;
int buzzer = 10;
int smokeA0 = A5;
int sensorThreshold = 400;

void setup() {
  pinMode(LED1, 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 > sensorThreshold)
  {
    digitalWrite(LED1, HIGH);
    digitalWrite(LED2, LOW);
    tone(buzzer, 1000, 200);
  }
  else
  {
    digitalWrite(LED1, LOW);
    digitalWrite(LED2, HIGH);
    noTone(buzzer);
  }
  delay(100);
}

Schematics

schematic
Capture plf2nxch0s
PIN diagram MQ2
2 bfzmsvieba

Comments

Similar projects you might like

Smoke Detection using MQ-2 Gas Sensor

by Aritro Mukherjee

  • 442,616 views
  • 90 comments
  • 261 respects

How to Use a Gas Sensor (MQ-2)

by MisterBotBreak

  • 4,986 views
  • 1 comment
  • 13 respects

Smart Fire and Flammable Gas Safety Valve

Project in progress by Ashwini kumar sinha

  • 1,772 views
  • 0 comments
  • 3 respects

Simple Obstacle Sensor with Arduino

Project tutorial by muhammed shameel k.v

  • 22,876 views
  • 5 comments
  • 15 respects

MQ-4 Natural Gas Sensor Experiment Based on Arduino

Project tutorial by Andrew85

  • 12,432 views
  • 4 comments
  • 12 respects
Add projectSign up / Login