top of page

GASE SENSOR DETECTION

Arduino gas detecting system. This circuit uses the gas sensor to detect if there is fire, smoke, or gas leakage nearby. Using the LCD, this circuit also can display its “Gas Leakage” message to LCD.

COMPONENTS

  1. 1 Arduino Uno

  2. 1 MQ2 gas sensor

  3. 4 1k ohms resistors

  4. 1 4.7k ohms resistor

  5. 2 different color LEDs (I'll be using the red and green LEDs in this case)

  6. 1 LCD(16x2)

  7. 1 breadboard

  8. Many wires of different colors

CONNECTIONS

  1. Connect Arduino 5V to positive power rail

  2. Connect Arduino GND to negative power rai

  3. Connect Arduino A0 to gas sensor B2

  4. Connect gas sensor A1, H2, A2 to positive power rail

  5. Connect gas sensor H2 to ground

  6. Connect gas sensor B1 to 20K ohms resistor, then to ground

  7. Connect the cathodes of three LEDs to 100 ohms resistor, then to ground

  8. Connect the anode of LED1 to pin 13

  9. Connect the anode of LED1 to pin 13

  10. Connect the anode of LED2 to pin 7

  11. Connect the anode of LED3 to pin 6

  12. Connect LCD DB4,5,6,7 to Arduino pin 5,4,3,2.

  13. Connect LCD Cathode to negative power rain

  14. Connect LED anode to terminal 1 resister 3 of 220 ohms.

  15. Connect LCD resister select and enable to pin 12,12.

  16. Connect LCD read/write to negative power rail

  17. Connect LCD contrast to wiper of potentiometer.

  18. Connect LCD ground to negative power rail

  19. Connect LCD positive to positive rail then connect to 5v Arduino

  20. Connect potentiometer terminal 1 to positive power rail

  21. Connect potentiometer terminal 2 to negative power rail.

RESULTS (ALAM DETECTION)

CODE

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

​

void setup() {

  Serial.begin(9600);

  lcd.begin(16, 2);

  pinMode(13,OUTPUT);

  pinMode(7,OUTPUT);

  pinMode(6,OUTPUT);

}

​

void loop() {

​

  int gas_data;

  gas_data = analogRead(A0);

  lcd.setCursor(00,00);

  lcd.print("Gas :");

  lcd.setCursor(6,00);

  lcd.print(gas_data);

  if(gas_data > 800){

   digitalWrite(13,HIGH);

    delay(100);

    digitalWrite(13,LOW);

    lcd.setCursor(00,1);

    lcd.print("Danger getout");

​

  }

    else if (gas_data > 700)

  {

    digitalWrite(6,HIGH);

   delay(100);

    digitalWrite(6,LOW);

    lcd.setCursor(00,1);

    lcd.print("WARNING");

  }

   else

   {

    digitalWrite(7,HIGH);

    lcd.setCursor(00,1);

    lcd.print("SAFE");

  }

  Serial.println(gas_data);

  delay(100);

  lcd.clear();

}

bottom of page