Arduino UNO Based Fire Detection and Alert System with SIM900A GSM Module
View and Edit Project In Cirkit Designer
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
- Description: A microcontroller board based on the ATmega328P.
- Purpose: Acts as the central processing unit of the circuit, reading sensor data, controlling the buzzer, and communicating with the SIM900A module.
SIM900A
- Description: A GSM/GPRS module for cellular communication.
- Purpose: Used to send SMS alerts and make phone calls when the fire or gas is detected.
Heat Flame Sensor
- Description: A sensor module capable of detecting a flame or fire.
- Purpose: Monitors for the presence of fire and provides a digital signal to the Arduino UNO.
Buzzer
- Description: An electronic buzzer component.
- Purpose: Provides an audible alert when fire or gas is detected.
MQ135
- Description: A sensor for detecting a wide range of gases, including NH3, NOx, alcohol, benzene, smoke, and CO2.
- Purpose: Monitors air quality and the presence of hazardous gases.
Wiring Details
Arduino UNO
- 5V: Powers the MQ135 and Heat Flame Sensor.
- GND: Common ground for the buzzer, MQ135, SIM900A, and Heat Flame Sensor.
- D5: Connected to the buzzer for control.
- D4: Connected to the SIM900A TXD pin for serial communication.
- D3: Connected to the SIM900A RXD pin for serial communication.
- D2: Connected to the MQ135 D0 and Heat Flame Sensor DO for digital inputs.
SIM900A
- GND: Connected to the common ground.
- DB9-3 (RXD): Receives data from Arduino UNO D4.
- DB9-2 (TXD): Transmits data to Arduino UNO D3.
Heat Flame Sensor
- AO: Analog output (not connected in this circuit).
- DO: Digital output connected to Arduino UNO D2.
- GND: Connected to the common ground.
- VCC: Powered by Arduino UNO 5V.
Buzzer
- PIN: Controlled by Arduino UNO D5.
- GND: Connected to the common ground.
MQ135
- VCC: Powered by Arduino UNO 5V.
- GND: Connected to the common ground.
- A0: Analog output (not connected in this circuit).
- D0: Digital output connected to Arduino UNO D2.
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.