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.

  • 533 views
  • 0 comments
  • 3 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

  • 213,130 views
  • 36 comments
  • 133 respects

Create a People Counter Controlled by an Android App

Project tutorial by Kutluhan Aktar

  • 3,064 views
  • 2 comments
  • 7 respects

Android App-Based Home Automation System Using IOT

Project tutorial by Team Autoshack

  • 24,853 views
  • 17 comments
  • 75 respects

Complete Digital Clock Including Alarm and Motion Sensor

Project tutorial by LAGSILVA

  • 12,677 views
  • 11 comments
  • 50 respects

Security System And Access Control With Arduino And RFID

Project tutorial by Sarath P

  • 7,988 views
  • 1 comment
  • 19 respects

Simple Obstacle Sensor with Arduino

Project tutorial by muhammed shameel k.v

  • 5,566 views
  • 2 comments
  • 8 respects
Add projectSign up / Login