Gas Detector Using Arduino

Introduction:

In this article I will explain how to detect gas using Arduino Mega. The gas sensor can easily find gas leaking at a place. When the gas is detected it can measure the range of the gas sensor.

Parts
  • Arduino Mega 2560
  • Gas Sensor
  • Buzzer
  • Bread Board
  • Led
  • Hookup wires.
Connection:

Step 1:
Connection from the Gas Sensor to the Arduino Mega 2560,


Figure 1:
Gas Sensor
  • Take the Output pin to the Analog pin of the A0 in the Arduino Mega board.
  • Take the Vcc pin to the +5v of the ArduinoMega board.
  • Take the Gnd pin to the Gnd of the ArduinoMega board.
Step 2: Connection from the LED to the Arduino Mega2560
  • Postive pin = 10;
  • Negative pin = Gnd;
Step 3: Connection from the Buzzer to the Arduino Mega2560
  • Take the positive pin and connect to the Digital pin of 05 to the Arduino Mega board.
  • Take the negative pin and connect to the Gnd of the ArduinoMega board.
Programming:
  1. const int sensorpin = A0; // sensor output pin to Arduino analog A0 pin  
  2. int led = 10;  
  3. int buzzer = 5;  
  4. int sensorValue = 0;  
  5. void setup()  
  6. {  
  7.     pinMode(led, OUTPUT);  
  8.     pinMode(buzzer, OUTPUT);  
  9.     Serial.begin(9600); //Initialize serial port - 9600 bps  
  10. }  
  11. void loop()  
  12. {  
  13.     Serial.println("Welcome to c#corner");  
  14.     sensorValue = analogRead(sensorpin);  
  15.     Serial.println(sensorValue);  
  16.     if (sensorValue < 100)  
  17.     {  
  18.         Serial.println("LPG Value");  
  19.         Serial.println("LED on");  
  20.         digitalWrite(led, HIGH);  
  21.         digitalWrite(buzzer, HIGH);  
  22.         delay(1000);  
  23.     }  
  24.     digitalWrite(led, LOW);  
  25.     digitalWrite(buzzer, LOW);  
  26.     delay(sensorValue);  
  27. }  
Explanation:
  • When the gas is detected the LED will be ON and the Buzzer also produced the sound.
  • Then we can see the reading in the serial monitor.
  • When the Gas is detected the LED can be HIGH.
Output:

Serial Monitor:

                                             Figure 2: serial Monitor Display
Output:

                                                      Figure 3: Output
 
Read more articles on Arduino:

Up Next
    Ebook Download
    View all
    Learn
    View all