Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino-Based Fire and Smoke Detection System with Buzzer and LED Indicators

View and Edit Project In Cirkit DesignerImage of Arduino-Based Fire and Smoke Detection System with Buzzer and LED Indicators

Circuit Documentation

Summary

This circuit is designed to detect fire and smoke using a heat flame sensor and an MQ2 gas sensor. It provides visual and auditory alerts through LEDs and a buzzer. The circuit is controlled by an Arduino UNO microcontroller, which processes the sensor inputs and drives the output components accordingly.

Component List

  1. Buzzer

    • Pins: POSITIVE, NEGATIVE
    • Description: Emits sound when activated.
    • Purpose: Provides an auditory alert when fire or smoke is detected.
  2. Heat Flame Sensor

    • Pins: AO, DO, GND, VCC
    • Description: Detects the presence of flame.
    • Purpose: Provides a digital output indicating the presence of flame.
  3. MQ2 Gas Sensor

    • Pins: VCC, GND, AOUT, DOUT
    • Description: Detects smoke and other gases.
    • Purpose: Provides an analog output indicating the level of smoke or gas.
  4. Arduino UNO

    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
    • Description: Microcontroller board.
    • Purpose: Controls the circuit by processing sensor inputs and driving the output components.
  5. LED: Two Pin (green)

    • Pins: cathode, anode
    • Description: Green LED.
    • Purpose: Indicates normal operation when no fire or smoke is detected.
  6. LED: Two Pin (red)

    • Pins: cathode, anode
    • Description: Red LED.
    • Purpose: Indicates the presence of fire or smoke.
  7. Resistor

    • Pins: pin1, pin2
    • Description: 200 Ohms resistor.
    • Purpose: Limits current to the LEDs.

Wiring Details

Buzzer

Heat Flame Sensor

MQ2 Gas Sensor

Arduino UNO

LED: Two Pin (green)

LED: Two Pin (red) (fire)

LED: Two Pin (red) (smoke)

Resistor (green LED)

Resistor (red LED for fire)

Resistor (red LED for smoke)

Code Documentation

// Pin definitions
const int flameSensorPin = 6; // Digital pin connected to flame sensor DO
const int smokeSensorPin = A0; // Analog pin connected to MQ2 AOUT
const int redLEDFirePin = 3; // Digital pin connected to red LED (fire)
const int redLEDSmokePin = 4; // Digital pin connected to red LED (smoke)
const int greenLEDPin = 5; // Digital pin connected to green LED
const int buzzerPin = 13; // Digital pin connected to buzzer

void setup() {
  // Initialize serial communication
  Serial.begin(9600);
  // Initialize pins
  pinMode(flameSensorPin, INPUT);
  pinMode(smokeSensorPin, INPUT);
  pinMode(redLEDFirePin, OUTPUT);
  pinMode(redLEDSmokePin, OUTPUT);
  pinMode(greenLEDPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
  // Turn on green LED initially
  digitalWrite(greenLEDPin, HIGH);
}

void loop() {
  // Read sensor values
  int flameState = digitalRead(flameSensorPin);
  int smokeLevel = analogRead(smokeSensorPin);
  
  // Print sensor values for debugging
  Serial.print("Flame State: ");
  Serial.println(flameState);
  Serial.print("Smoke Level: ");
  Serial.println(smokeLevel);
  
  // Check for fire or smoke
  if (flameState == HIGH || smokeLevel > 300) { // Adjust threshold as needed
    // Fire or smoke detected
    digitalWrite(greenLEDPin, LOW); // Turn off green LED
    
    if (flameState == HIGH && smokeLevel > 300) {
      // Both fire and smoke detected
      digitalWrite(redLEDFirePin, HIGH); // Turn on red LED (fire)
      digitalWrite(redLEDSmokePin, HIGH); // Turn on red LED (smoke)
      tone(buzzerPin, 1000); // Set buzzer to high tone
    } else if (flameState == HIGH) {
      // Only fire detected
      digitalWrite(redLEDFirePin, HIGH); // Turn on red LED (fire)
      digitalWrite(redLEDSmokePin, LOW); // Turn off red LED (smoke)
      tone(buzzerPin, 500); // Set buzzer to medium tone
    } else if (smokeLevel > 300) {
      // Only smoke detected
      digitalWrite(redLEDFirePin, LOW); // Turn off red LED (fire)
      digitalWrite(redLEDSmokePin, HIGH); // Turn on red LED (smoke)
      tone(buzzerPin, 250); // Set buzzer to low tone
    }
  } else {
    // No fire or smoke detected
    digitalWrite(greenLEDPin, HIGH); // Turn on green LED
    digitalWrite(redLEDFirePin, LOW); // Turn off red LED (fire)
    digitalWrite(redLEDSmokePin, LOW); // Turn off red LED (smoke)
    noTone(buzzerPin); // Turn off buzzer
  }
  
  // Small delay for stability
  delay(100);
}

This code initializes the pins connected to the sensors, LEDs, and buzzer. It continuously reads the sensor values and updates the LEDs and buzzer based on the presence of fire or smoke. The green LED indicates normal operation, while the red LEDs and buzzer provide alerts for fire and smoke.