Sheekar Banerjee
Published © CC0

MQ-2 Flammable Gas Sensor with Arduino | Sheekar Banerjee

The MQ-2 Flammable Gas and Smoke Sensor is usually used to detect the presence of flammable or smoke element in the air.

IntermediateFull instructions provided561
MQ-2 Flammable Gas Sensor with Arduino | Sheekar Banerjee

Things used in this project

Story

Read more

Schematics

Circuit Diagram of MQ2 Sensor with Arduino UNO R3

Code

Program of MQ2 Sensor with Arduino UNO R3

Arduino
//Coded and tested by :
// Sheekar Banejee, AI-ML-IOT Solution Engineer and Researcher

int smokeA0 = A0;
// Your threshold value
int sensorThres = 700;

void setup() {
  pinMode(smokeA0, INPUT);
  Serial.begin(9600); //Streaming 9600 bits of Sensor Data per Second
}

void loop() {
  int analogSensor = analogRead(smokeA0);

  Serial.println("Sensor Value: ");
  Serial.println(analogSensor);
  // Checks if it has reached the threshold value
  if (analogSensor > sensorThres)
  {
    Serial.println("Alert! Smoke Detected!");
  }
  else
  {
    Serial.println("Normal...");
  }
  delay(3000);
}

Credits

Sheekar Banerjee
0 projects • 6 followers
A motivated Computer Scientist & Engineer with years of experience over IoT, Robotic Systems, Machine Learning Algorithms and Software.
Contact

Comments

Please log in or sign up to comment.