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

Arduino UNO Based Smoke and Flame Detection System with I2C LCD Feedback and Buzzer Alert

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Smoke and Flame Detection System with I2C LCD Feedback and Buzzer Alert

Circuit Documentation

Summary of the Circuit

This circuit is designed to monitor environmental conditions using an MQ135 smoke sensor and a KY-026 flame sensor. The data from these sensors is displayed on an I2C LCD 16x2 screen. Additionally, a buzzer is included in the circuit to provide an audible alert when smoke or flame is detected. The core of the circuit is an Arduino UNO microcontroller, which processes the sensor data, controls the LCD display, and manages the buzzer state based on the sensor inputs.

Component List

Arduino UNO

MQ135 Gas Sensor

KY-026 Flame Sensor

I2C LCD 16x2 Screen

Buzzer

Wiring Details

Arduino UNO

MQ135 Gas Sensor

KY-026 Flame Sensor

I2C LCD 16x2 Screen

Buzzer

Documented Code

/*
 * Smoke and Flame Sensor using a Display
 * This Arduino sketch reads data from an MQ135 smoke sensor and a KY-026 flame
 * sensor. It displays the smoke level on an I2C LCD 16x2 screen and activates
 * a buzzer if smoke or flame is detected.
 */

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

// Pin definitions
const int smokeSensorPin = A0;
const int flameSensorPin = 8;
const int buzzerPin = 9;

// I2C LCD address and dimensions
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  // Initialize serial communication
  Serial.begin(9600);

  // Initialize LCD
  lcd.begin();
  lcd.backlight();

  // Initialize pins
  pinMode(smokeSensorPin, INPUT);
  pinMode(flameSensorPin, INPUT);
  pinMode(buzzerPin, OUTPUT);

  // Initial LCD display
  lcd.setCursor(0, 0);
  lcd.print("Smoke: ");
  lcd.setCursor(0, 1);
  lcd.print("Flame: ");
}

void loop() {
  // Read sensor values
  int smokeLevel = analogRead(smokeSensorPin);
  int flameDetected = digitalRead(flameSensorPin);

  // Display smoke level on LCD
  lcd.setCursor(7, 0);
  lcd.print(smokeLevel);

  // Display flame status on LCD
  lcd.setCursor(7, 1);
  if (flameDetected == LOW) {
    lcd.print("Yes");
  } else {
    lcd.print("No ");
  }

  // Activate buzzer if smoke or flame is detected
  if (smokeLevel > 300 || flameDetected == LOW) {
    digitalWrite(buzzerPin, HIGH);
  } else {
    digitalWrite(buzzerPin, LOW);
  }

  // Print sensor values to serial monitor
  Serial.print("Smoke Level: ");
  Serial.print(smokeLevel);
  Serial.print(" | Flame Detected: ");
  Serial.println(flameDetected == LOW ? "Yes" : "No");

  // Delay for a short period
  delay(500);
}

This code is responsible for reading the analog value from the MQ135 smoke sensor and the digital value from the KY-026 flame sensor. It then displays these values on the I2C LCD screen and activates the buzzer if either sensor detects a threshold condition. The code uses the LiquidCrystal_I2C library to interface with the LCD and standard Arduino functions for reading inputs and controlling outputs.