Surilli
Published © LGPL

Smoke and Gas Detection Using Surilli Basic M0 and MQ2

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

BeginnerFull instructions provided30 minutes250
Smoke and Gas Detection Using Surilli Basic M0 and MQ2

Things used in this project

Hardware components

Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Surilli Basic
Surilli Basic
×1
Buzzer
Buzzer
×1
MQ2 Sensor
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Smoke and Gas Detection using Surilli Basic M0

Code

MQ2_sensor_and_Piezo_Buzzer

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

Credits

Surilli

Surilli

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

Comments