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

Arduino UNO-Based Fire and Smoke Detection System with LCD Display

View and Edit Project In Cirkit DesignerImage of Arduino UNO-Based Fire and Smoke Detection System with LCD Display

Circuit Documentation

Summary

This circuit is designed to detect gas and flame presence using an MQ-2 gas sensor and a KY-026 flame sensor. The data from these sensors is processed by an Arduino UNO, which then displays the status on a 16x2 I2C LCD. Additionally, a buzzer is used to provide audible alerts in case of detected threats.

Component List

  1. Arduino UNO

    • Description: A microcontroller board based on the ATmega328P.
    • 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
  2. MQ-2 Gas Sensor

    • Description: A sensor for detecting gas leaks (e.g., LPG, i-butane, propane, methane, alcohol, hydrogen, smoke).
    • Pins: GND, VCC, ANALOG, Digital
  3. KY-026 Flame Sensor

    • Description: A sensor for detecting flame or light source in the wavelength range of 760nm to 1100nm.
    • Pins: A0, GND, VCC, D0
  4. 16x2 I2C LCD

    • Description: A 16x2 character LCD display with I2C interface.
    • Pins: GND, VCC, SDA, SCL
  5. Buzzer

    • Description: A simple piezoelectric buzzer for sound alerts.
    • Pins: PIN, GND

Wiring Details

Arduino UNO

MQ-2 Gas Sensor

KY-026 Flame Sensor

16x2 I2C LCD

Buzzer

Code Documentation

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#define gasPin A0       
#define flamePin 8    

LiquidCrystal_I2C lcd(0x27, 16, 2);
int gasVal = 0;         
int flameVal = 0;     

void setup() {
  lcd.begin(16, 2);
  lcd.backlight();

  Serial.begin(9600);

  pinMode(gasPin, INPUT);
  pinMode(flamePin, INPUT);

  lcd.setCursor(0, 0);
  lcd.print("System Ready");
  delay(2000);
  lcd.clear();
}

void loop() {
  gasVal = analogRead(gasPin);       
  flameVal = digitalRead(flamePin);  

  if (gasVal > 300 && flameVal == LOW) {
    alert("Fire & Smoke!");
  } else if (gasVal > 500) {
    alert("Smoke Alert!"); 
  } else if (flameVal == LOW) {
    alert("Fire Alert!"); 
  } else {
    noAlert();
  }

  delay(500); 
}

void alert(const char* message) {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print(message);
}

void noAlert() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("No Threats");
}

This code initializes the LCD and sets up the pins for the gas and flame sensors. In the main loop, it reads the sensor values and displays appropriate messages on the LCD based on the sensor readings. The alert function is used to display alert messages, while the noAlert function displays a "No Threats" message when no danger is detected.