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

Arduino UNO Based Fire Detection and Alert System with SIM900A GSM Module

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Fire Detection and Alert System with SIM900A GSM Module

Circuit Documentation

Summary

The circuit in question is designed to detect the presence of fire or hazardous gases and respond accordingly. It utilizes an Arduino UNO as the central microcontroller to interface with a SIM900A GSM module for communication, a heat flame sensor for fire detection, a buzzer for audible alerts, and an MQ135 sensor for air quality and gas detection. The Arduino UNO is programmed to read inputs from the sensors, activate the buzzer upon fire detection, and use the SIM900A module to send SMS alerts and make phone calls to predefined numbers.

Component List

Arduino UNO

SIM900A

Heat Flame Sensor

Buzzer

MQ135

Wiring Details

Arduino UNO

SIM900A

Heat Flame Sensor

Buzzer

MQ135

Documented Code

#include <SoftwareSerial.h>

// Define phone numbers for SMS alerts
const String PHONE_1 = "+91..........";
const String PHONE_2 = ""; // Optional
const String PHONE_3 = ""; // Optional

// Define SIM900A module pins
#define rxPin 4
#define txPin 3
SoftwareSerial sim800L(rxPin, txPin);

// Define flame sensor pin
#define flame_sensor_pin 2

// Flag to indicate fire detection
boolean fire_flag = 0;

// Define buzzer pin
#define buzzer_pin 5

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

  // Set pin modes
  pinMode(flame_sensor_pin, INPUT);
  pinMode(buzzer_pin, OUTPUT);
  digitalWrite(buzzer_pin, LOW);

  // Initialize SIM900A module
  Serial.println("Initializing...");
  sim800L.println("AT");
  delay(1000);
  sim800L.println("AT+CMGF=1");
  delay(1000);
}

void loop() {
  // Read SIM900A module output
  while (sim800L.available()) {
    Serial.println(sim800L.readString());
  }

  // Read flame sensor input
  int flame_value = digitalRead(flame_sensor_pin);

  // If flame is detected
  if (flame_value == LOW) {
    // Activate buzzer
    digitalWrite(buzzer_pin, HIGH);

    // If fire is detected for the first time
    if (fire_flag == 0) {
      Serial.println("Fire Detected.");
      fire_flag = 1;
      send_multi_sms();
      make_multi_call();
    }
  } else {
    // Deactivate buzzer
    digitalWrite(buzzer_pin, LOW);
    fire_flag = 0;
  }
}

// Function to send SMS to multiple numbers
void send_multi_sms() {
  if (PHONE_1 != "") {
    Serial.print("Phone 1: ");
    send_sms("Fire is Detected", PHONE_1);
  }
  if (PHONE_2 != "") {
    Serial.print("Phone 2: ");
    send_sms("Fire is Detected", PHONE_2);
  }
  if (PHONE_3 != "") {
    Serial.print("Phone 3: ");
    send_sms("Fire is Detected", PHONE_3);
  }
}

// Function to make calls to multiple numbers
void make_multi_call() {
  if (PHONE_1 != "") {
    Serial.print("Phone 1: ");
    make_call(PHONE_1);
  }
  if (PHONE_2 != "") {
    Serial.print("Phone 2: ");
    make_call(PHONE_2);
  }
  if (PHONE_3 != "") {
    Serial.print("Phone 3: ");
    make_call(PHONE_3);
  }
}

// Function to send an SMS
void send_sms(String text, String phone) {
  Serial.println("sending sms....");
  delay(50);
  sim800L.print("AT+CMGF=1\r");
  delay(1000);
  sim800L.print("AT+CMGS=\"" + phone + "\"\r");
  delay(1000);
  sim800L.print(text);
  delay(100);
  sim800L.write(0x1A); // ASCII code for Ctrl+Z
  delay(5000);
}

// Function to make a phone call
void make_call(String phone) {
  Serial.println("calling....");
  sim800L.println("ATD" + phone + ";");
  delay(20000); // 20 sec delay
  sim800L.println("ATH");
  delay(1000); // 1 sec delay
}

This code is designed to be uploaded to the Arduino UNO microcontroller. It sets up the necessary pins for communication with the SIM900A module and the sensors, reads the flame sensor's digital output, and triggers the buzzer and communication actions when a fire is detected. The code includes functions to send SMS messages and make phone calls to predefined phone numbers using the SIM900A module.