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

Arduino Mega 2560 Fire Detection and Water Pump System with LCD Display

View and Edit Project In Cirkit DesignerImage of Arduino Mega 2560 Fire Detection and Water Pump System with LCD Display

Circuit Documentation

Summary

This circuit is designed to detect fire using a KY-026 Flame Sensor and respond by activating a water pump and a buzzer. The system is controlled by an Arduino Mega 2560 microcontroller, which also interfaces with a 16x2 I2C LCD to display the status of the system. The L293D motor driver is used to control the water pump, and the entire system is powered by two 18650 Li-ion batteries.

Component List

Arduino Mega 2560

L293D

18650 Li-ion Battery x 2

Water Pump

KY-026 Flame Sensor

16x2 I2C LCD

Buzzer

Resistor

Rocker Switch

Wiring Details

Arduino Mega 2560

L293D

18650 Li-ion Battery x 2

Water Pump

KY-026 Flame Sensor

16x2 I2C LCD

Buzzer

Resistor

Rocker Switch

Code Documentation

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

LiquidCrystal_I2C lcd(0x27, 16, 2);

const int sensorMin = 0;     // sensor minimum
const int sensorMax = 1024;  // sensor maximum

#include <AFMotor.h>
AF_DCMotor motor1(1);

const int buzzer = 22;

void setup() 
{
  Serial.begin(9600);
  lcd.begin();
  lcd.backlight();
  lcd.setCursor(1, 0);
  lcd.println("Reading Sensor  ");
  motor1.setSpeed(255);
  motor1.run(RELEASE);
  delay(2000);
}

void loop() 
{
  int sensorReading = analogRead(A8);
  int range = map(sensorReading, sensorMin, sensorMax, 0, 3);
  switch (range) {
    case 0:    // A fire closer than 1.5 feet away.
      motor1.run(FORWARD);
      lcd.backlight();
      lcd.setCursor(1, 0);
      //lcd.print("** Close Fire **");
      lcd.print(" Water Flow ON ");

      tone(buzzer, 3000);
      delay(1000);
      noTone(buzzer);
      delay(1000);

      break;
    case 1:    // A fire between 1-3 feet away.
      motor1.run(RELEASE);
      lcd.backlight();
      lcd.setCursor(1, 0);
      //lcd.print("* Distant Fire *");
      lcd.print(" Water Flow OFF ");
      break;
    case 2:    // No fire detected.
      motor1.run(RELEASE);
      lcd.backlight();
      lcd.setCursor(1, 0);
      //lcd.print("*** No Fire ***");
      lcd.print(" Water Flow OFF ");
      break;
  }
  delay(1);
}

This code initializes the LCD and motor, reads the flame sensor value, and controls the water pump and buzzer based on the sensor reading. The LCD displays the status of the water flow, and the buzzer sounds an alarm if a fire is detected.