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 Arduino Uno
-
1 MQ2 gas sensor
-
4 1k ohms resistors
-
1 4.7k ohms resistor
-
2 different color LEDs (I'll be using the red and green LEDs in this case)
-
1 LCD(16x2)
-
1 breadboard
-
Many wires of different colors
CONNECTIONS
-
Connect Arduino 5V to positive power rail
-
Connect Arduino GND to negative power rai
-
Connect Arduino A0 to gas sensor B2
-
Connect gas sensor A1, H2, A2 to positive power rail
-
Connect gas sensor H2 to ground
-
Connect gas sensor B1 to 20K ohms resistor, then to ground
-
Connect the cathodes of three LEDs to 100 ohms resistor, then to ground
-
Connect the anode of LED1 to pin 13
-
Connect the anode of LED1 to pin 13
-
Connect the anode of LED2 to pin 7
-
Connect the anode of LED3 to pin 6
-
Connect LCD DB4,5,6,7 to Arduino pin 5,4,3,2.
-
Connect LCD Cathode to negative power rain
-
Connect LED anode to terminal 1 resister 3 of 220 ohms.
-
Connect LCD resister select and enable to pin 12,12.
-
Connect LCD read/write to negative power rail
-
Connect LCD contrast to wiper of potentiometer.
-
Connect LCD ground to negative power rail
-
Connect LCD positive to positive rail then connect to 5v Arduino
-
Connect potentiometer terminal 1 to positive power rail
-
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();
}