Dr. Kayarvizhy N Dr. Kayarvizhy N

Internet of Things

Smoke sensing using MQ2 Sensor

April 29, 2016All posts

Introduction

The MQ2 is a Gas Sensor and is useful for gas leakage detection. It can detect LPG, alcohol, Hydrogen, Smoke, i-butane and so on

Project

In this experiment we will interface the MQ2 with Arduino. It has a single Analog Pin to provide the values. We will read the current value and print the same in serial console. Also whenever the value exceeds 200 we print “Fire Alarm”. Obviously a better way would be to have a speaker sound or to have at least an LED glow. These could be considered as exercises. Another exercise could be to try out the Digital Out as well and see how that works.

Pin Configuration

Arduino Sensor
5V VCC
GND GND
A0 AOUT

Circuit connections

Code

const int sensorPin= 0;

int smoke_level;

void setup() {
  Serial.begin(9600); //sets the baud rate for data transfer in bits/second
  pinMode(sensorPin, INPUT);//the smoke sensor will be an input to the arduino
}

void loop() {
  smoke_level= analogRead(sensorPin); //arduino reads the value from the smoke sensor
  Serial.println(smoke_level);//prints just for debugging purposes, to see what values the sensor is picking up
  if(smoke_level > 200){
    Serial.println("Fire Alarm");
  }
}
0 0 votes
Article Rating
0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Oldest
Newest Most Voted