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

Arduino UNO Based GSM-Alert Fire Detection System

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

Circuit Documentation

Summary

The circuit in question is designed to monitor environmental conditions using a gas sensor (MQ2) and a heat flame sensor. It utilizes an Arduino UNO as the central microcontroller to process sensor data and control peripheral devices such as a buzzer, an LED, and a relay. Additionally, the circuit includes a SIM800L GSM Module for sending alerts via SMS when certain conditions are met. The circuit is powered by a 5V supply, which is distributed to the various components.

Component List

Arduino UNO

MQ2 Gas Sensor

Buzzer

SIM800L GSM Module

Heat Flame Sensor

1-Channel Relay (5V 10A)

LED: Two Pin (red)

Wiring Details

Arduino UNO

MQ2 Gas Sensor

Buzzer

SIM800L GSM Module

Heat Flame Sensor

1-Channel Relay (5V 10A)

LED: Two Pin (red)

Documented Code

#include <SoftwareSerial.h>

// Pin definitions
const int flameSensorPin = A1; // Both MQ2 and Flame Sensor connected to A1
const int relayPin = 2;
const int buzzerPin = 3;
const int ledPin = 4;
const int simTxPin = 5;
const int simRxPin = 6;

// Create a SoftwareSerial object for the GSM module
SoftwareSerial sim800l(simTxPin, simRxPin);

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

  // Initialize the SoftwareSerial port for the GSM module
  sim800l.begin(9600);

  // Initialize pins
  pinMode(flameSensorPin, INPUT);
  pinMode(relayPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  // Read sensor values
  int sensorValue = analogRead(flameSensorPin);
  Serial.print("Sensor Value: ");
  Serial.println(sensorValue);

  // Example condition to activate relay, buzzer, and LED
  if (sensorValue > 500) { // Threshold value for demonstration
    digitalWrite(relayPin, HIGH);
    digitalWrite(buzzerPin, HIGH);
    digitalWrite(ledPin, HIGH);

    // Send alert via GSM module
    sendAlert("Sensor value exceeded threshold!");
  } else {
    digitalWrite(relayPin, LOW);
    digitalWrite(buzzerPin, LOW);
    digitalWrite(ledPin, LOW);
  }

  delay(1000); // Delay for 1 second
}

void sendAlert(String message) {
  sim800l.println("AT+CMGF=1"); // Set SMS mode to text
  delay(100);
  sim800l.println("AT+CMGS=\"+1234567890\""); // Replace with the recipient's phone number
  delay(100);
  sim800l.println(message); // The SMS message
  delay(100);
  sim800l.write(26); // ASCII code for CTRL+Z to send the SMS
  delay(1000);
}

This code is designed to read sensor data from the flame sensor and MQ2 gas sensor, and if a certain threshold is exceeded, it activates a relay, buzzer, and LED. Additionally, it sends an alert via the SIM800L GSM Module. The code includes setup and loop functions, as well as a custom sendAlert function for sending SMS messages.