Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino Nano-Based LPG Gas Detector with Alert System

Image of Arduino Nano-Based LPG Gas Detector with Alert System

Circuit Documentation

Summary of the Circuit

This circuit is designed to function as an LPG Gas Detector using an Arduino Nano as the central processing unit. It incorporates an MQ6 gas sensor to detect the presence of LPG gas, a red LED to provide a visual indication, and a buzzer for an audible alarm. The system operates by continuously monitoring the gas concentration in the air. If the detected gas level exceeds a predefined threshold, the circuit activates both the LED and the buzzer to alert the user.

Component List

Arduino Nano

  • Description: A compact microcontroller board based on the ATmega328P.
  • Purpose: Acts as the central processing unit for the circuit, reading sensor data, and controlling the LED and buzzer based on the gas concentration.
  • Pins: D1/TX, D0/RX, RESET, GND, D2, D3, D4, D5, D6, D7, D8, D9, D10, D11/MOSI, D12/MISO, VIN, 5V, A7, A6, A5, A4, A3, A2, A1, A0, AREF, 3V3, D13/SCK.

MQ6 Gas Sensor

  • Description: A gas sensor designed for the detection of LPG, butane, propane, methane, alcohol, hydrogen, and smoke.
  • Purpose: To detect the presence and concentration of LPG gas in the environment.
  • Pins: VCC, GND, A0, DO.

LED: Two Pin (red)

  • Description: A basic red light-emitting diode.
  • Purpose: To provide a visual indication when the gas concentration exceeds the threshold.
  • Pins: cathode, anode.

Buzzer

  • Description: An electronic buzzer capable of producing an audible alert.
  • Purpose: To emit an audible alarm when the gas concentration is above the threshold.
  • Pins: PIN, GND.

Wiring Details

Arduino Nano

  • GND connected to:
    • LED (cathode)
    • Buzzer (GND)
    • MQ6 Gas Sensor (GND)
  • D2 connected to Buzzer (PIN)
  • D3 connected to LED (anode)
  • 5V connected to MQ6 Gas Sensor (VCC)
  • A0 connected to MQ6 Gas Sensor (A0)

MQ6 Gas Sensor

  • VCC connected to Arduino Nano (5V)
  • GND connected to Arduino Nano (GND)
  • A0 connected to Arduino Nano (A0)

LED: Two Pin (red)

  • Anode connected to Arduino Nano (D3)
  • Cathode connected to Arduino Nano (GND)

Buzzer

  • PIN connected to Arduino Nano (D2)
  • GND connected to Arduino Nano (GND)

Documented Code

/*
 * LPG Gas Detector using Arduino Nano
 * This code reads the analog value from the MQ6 gas sensor and turns on an LED
 * and a buzzer if the gas concentration exceeds a certain threshold.
 */

const int gasSensorPin = A0; // MQ6 sensor analog output connected to A0
const int buzzerPin = 2;     // Buzzer connected to digital pin 2
const int ledPin = 3;        // LED connected to digital pin 3
const int threshold = 300;   // Threshold value for gas concentration

void setup() {
  pinMode(buzzerPin, OUTPUT); // Set buzzer pin as output
  pinMode(ledPin, OUTPUT);    // Set LED pin as output
  pinMode(gasSensorPin, INPUT); // Set gas sensor pin as input
  Serial.begin(9600);         // Initialize serial communication
}

void loop() {
  int gasLevel = analogRead(gasSensorPin); // Read gas sensor value
  Serial.print("Gas Level: ");
  Serial.println(gasLevel); // Print gas level to serial monitor

  if (gasLevel > threshold) { // If gas level exceeds threshold
    digitalWrite(buzzerPin, HIGH); // Turn on buzzer
    digitalWrite(ledPin, HIGH);    // Turn on LED
  } else {
    digitalWrite(buzzerPin, LOW);  // Turn off buzzer
    digitalWrite(ledPin, LOW);     // Turn off LED
  }
  delay(1000); // Wait for 1 second before next reading
}

This code is designed to be uploaded to the Arduino Nano. It initializes the pins connected to the buzzer, LED, and MQ6 gas sensor. The loop function reads the analog value from the gas sensor and compares it to the threshold. If the gas level is above the threshold, it activates the buzzer and LED to warn of high gas concentration. The gas level is also printed to the serial monitor for debugging purposes.