Sabekin
Published

Gas Leakage Detector Using Arduino Uno and MQ-2

This device can detect flammable gases, smoke, and carbon monoxide, and send SMS alerts to a mobile number.

IntermediateFull instructions provided5 hours13
Gas Leakage Detector Using Arduino Uno and MQ-2

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Grove - Gas Sensor(MQ2)
Seeed Studio Grove - Gas Sensor(MQ2)
×1
GSM Module SIM800L with MIC & Headphone Jack
M5Stack GSM Module SIM800L with MIC & Headphone Jack
×1
Buzzer
Buzzer
×1
Capacitor 1000 µF
Capacitor 1000 µF
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Solderless Breadboard Full Size
Solderless Breadboard Full Size
×1
1N4007 – High Voltage, High Current Rated Diode
1N4007 – High Voltage, High Current Rated Diode
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Gas_Leakage_Detector_Circuit_Diagram

Code

Gas_Leakage_Detector

C/C++
#include <SoftwareSerial.h>
SoftwareSerial mySerial(9, 10);// SIM800L TXD and RXD pin to arduino pin 9 and 10

int buzzer = 13;// Buzzer positive pin to arduino pin 13
int GASA0 = A0;// Gas module pin A0  to arduino pin A0
int gasvalue;

void setup() {
   
 mySerial.begin(9600);
 Serial.begin(9600);
 pinMode(buzzer, OUTPUT); 
 delay(5000);    
}

void loop() {
  int analogSensor = analogRead(GASA0);
  int gasvalue=(analogSensor-50)/10;
  
  // Checks if it has reached the threshold value
  if (gasvalue >= 10)
  {
    SendTextMessage();
    tone(buzzer,HIGH);
  }
  else
  {

    noTone(buzzer);
  }
  delay(500);
 
}

void SendTextMessage()
{
  mySerial.println("AT+CMGF=1");    //To send SMS in Text Mode
  delay(1000);
  mySerial.println("AT+CMGS=\"+88XXXXXXXXX\"\r");  // the phone number you are using
  delay(1000);
  mySerial.println("Gas is Leaking!");//the content of the message
  delay(200);
  mySerial.println((char)26);//the stopping character
  delay(1000);
  
}

Credits

Sabekin
3 projects • 0 followers

Comments