Surilli
Published © LGPL

Smoke and Gas Detection Using MQ-2 sensor and Piezo Buzzer

This sensor is used to monitor gas leakage in your home or work place, and it beeps the buzzer whenever leakage is detected.

BeginnerFull instructions provided30 minutes2,777
Smoke and Gas Detection Using MQ-2 sensor and Piezo Buzzer

Things used in this project

Hardware components

Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Surilli WiFi
Surilli WiFi
×1
Buzzer
Buzzer
×1
MQ-2 (smoke sensor)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

smoke_sensor_xyKELD2azW.fzz

Code

Untitled file

C/C++
int smoke_sensor_pin =16;//D0 pin of sensor is connected to pin 16 of surilli.
int buzzer =2;//positive pin of buzzer is connected to pin 2 of surilli
void setup() {
  pinMode(smoke_sensor_pin, INPUT);//pin 16 is declared as input
  pinMode(buzzer, OUTPUT);//pin 2 is declared as output
  Serial.begin(9600);
}
void loop() {
  delay(500);
  int SmokeSensor = digitalRead(smoke_sensor_pin);//it will read D0 pin of sensor which is connected to pin 16
  Serial.println(SmokeSensor);//to display value (1 or 0) of pin 16 on serial monitor.
  if(SmokeSensor == 0){
    digitalWrite(buzzer, HIGH);//when gas is detected buzzer will be on.
    Serial.println("Gas detected");
    }
    if(SmokeSensor == 1){
      digitalWrite(buzzer, LOW);//when no gas is detected buzzer is turned off.
    Serial.println("Gas not detected");
    }
}

Credits

Surilli

Surilli

196 projects • 62 followers
Surilli is a premiere Internet of Things centric Technology Company aimed at providing cutting edge innovative solutions.

Comments