Arduino Projects

Arduino Fire Alarm System with GSM Alert Text Message & Buzzer

Description:

 

Arduino Fire Alarm System with GSM Alert Text Message & Buzzer- In this tutorial, you will learn how to make an Arduino based GSM Fire Alarm System with SMS Alert and Buzzer. In this project, a Flame Detector is used for the Fire detection. When the fire is detected by the Sensor the buzzer is turned ON for 8 seconds and a message is sent to the owner.

In this tutorial, we will cover

  1. GSM Sim900A Specifications and Pinout
  2. Flame Sensor Specifications and Pinout
  3. The complete Circuit diagram and Finally
  4. Arduino Fire Alarm System Programming

Without any further delay let’s get started!!!

Note: for the complete step by step explanation and demonstration watch video given at the end of this article.


Amazon Links:

12v Adaptor:

Arduino Uno

Arduino Nano

Flame IR Sensor/fire detector sensor:

5V buzzer

Sim900A GSM Module:

DC 5V 2A Adaptor

Other Tools and Components:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!



About the GSM Sim900a Mini Modem Module:

This is the GSM Sim900A Module. The first thing that you will notice about this GSM module is that it has no onboard voltage regulator, so be very careful while applying the voltage; Because voltages greater than 5 volts can easily damage this module. The ideal voltage for this GSM module is 4.7v but you can easily power up this GSM Sim900A module using a 5v adaptor. if you don’t have a 5v adaptor then you can make your power supply using lm317t adjustable variable voltage regulator, I have a very detailed tutorial on lm317t explaining everything.

There are a few things that I really like about the GSM sim900A module which are

  1. This is the cheapest GSM module available on the market.
  2. Another cool thing is, it can be easily interfaced with 5V supported controller boards like Arduino Uno, Arduino mega, Arduino Nano, etc and also with 3.3v controller boards like Nodemcu ESP8266 Wifi Module and ESP32, etc. The GSM Sim900A module interfacing with Nodemcu ESP8266 and ESP32 will be explained in one of my future articles.

GSM Sim900A Specifications:

As I said earlier the GSM Sim900A Module has no onboard voltage regulator. Although it has a power supply pin which can be connected with the Arduino’s 5 volts. When no sensors are connected with the Arduino then you can Run this GSM module without any problem. But the time you start connecting different sensors with the Arduino, then Arduino cannot provide enough current to the Sim900A Module due to which the Arduino starts resetting.

So, my recommendation is to use an external regulated 5v power supply.


GSM Sim900A Pinout:

Arduino Fire Alarm
gsm sim900a

The white connector labeled with 4.7 – 5V, This is where we connect the external 5volt regulated power supply. It has a total of 9 male headers. The three male headers on the right side are not connected.

  • Pin number 1 is the VCC which can be connected with the Arduino’s 5volts. In my case as I will power up this module using the external power supply so I will leave this pin unconnected.
  • Pin number 2 is the ground, which will be connected with the Arduino’s ground.
  • Pin number 3 is the 5v TXD,
  • Pin number 4 is the 5v RXD,
  • Pin number 5 is the 3.3v TXD, and
  • Pin number 6 is the 3.3v RXD.

As Arduino is based on the 5v controller board so we will be using the 5v TXD and 5v RXD pins of the GSM Sim900A module.


About the Flame Detector:

Arduino Fire Alarm

This is the Flame Sensor Module which is also known as the Infrared IR Fire Sensor Detector. This Flame Sensor is extremely sensitive to IR wavelengths between 760-1100nm light. This flame sensor is ideal for short-range fire detection and can be used to monitor projects or as a safety, precaution to cut devices OFF / ON or to turn ON buzzers or Send SMS. It can be used in hundreds of projects. I have found that this Flame Sensor is mostly accurate up to about 3 feet. I think this much range is enough.

Arduino Fire Alarm

On the right, we have a black IR LED sensor. The Flame Sensor Module has a total of 4 male headers on the left side which are clearly labeled as

  1. A0 which is the Analog output pin of the Flame Sensor
  2. G this is the ground pin and it should be connected with the ground pin of the power supply or the Arduino board.
  3. + pin is the input supply pin and this is where we connect 3.3v or 5v from the Arduino Board.
  4. D0 is the digital output signal pin which can be connected with any i/o pin of the Arduino board or it can be directly connected with TTL supported circuits for directly controlling the buzzers and relays etc.

This Flame sensor module is also provided with a Potentiometer which can be used for adjusting the Fire Flame detection sensitivity.

The Flame sensor module is also provided with two LEDs L1 and L2. One LED is turned ON when you power up the Flame Sensor module while the other LED only lights up when it detects the flame.

This IR Flame Sensor module is based on the LM393 low offset voltage dual comparator. If you want to read more about the LM393 comparator, you can download the datasheet given below.


About the Buzzer:

Arduino Fire Alarm

This is a 5v buzzer; it has a total of three male headers. The middle pin is not used. The + pin is connected with one of the Arduino’s I/O pins while the – pin is connected with the Arduino’s ground.

Arduino Fire Alarm System Circuit Diagram:

Arduino Fire Alarm

As you can see the circuit diagram is very simple, the VCC and GND pins of the Flame Detector are connected with the Arduino’s 5 volts and ground. While the digital output pin of the Flame Detector is connected with the Arduino’s digital pin 4.

The S pin of the 5v Buzzer is connected with the PWM pin 5 of the Arduino, while the – pin is connected with the Arduino’s Ground.

The GSM Sim900A module TXD pin is connected with the Arduino’s pin number 7, The RXD pin is connected with the Arduino’s pin number 8, while the ground pin of the GSM Sim900A module is connected with the Arduino’s ground. As I explained earlier the recommend voltage for this GSM module is 4.7 to 5 volts.

I interfaced all the components as per the circuit diagram already explained. Now let’s have a look at the Fire Alarm System Arduino programming.



Arduino Fire Alarm System Programming:

// Arduino Fire Alarm System, GSM Fire Alarm communicator
// https://www.electroniclinic.com/

#include <SoftwareSerial.h>
SoftwareSerial SIM900(7, 8); // gsm module connected here
String textForSMS;

int FlameSensor = 4; // Flame Sensor
int Buzzer = 5; // Alarm/light can be connected with this Buzzer

void setup() {

randomSeed(analogRead(0));
Serial.begin(9600);
SIM900.begin(9600); // original 19200. while enter 9600 for sim900A
Serial.println(" logging time completed!");
pinMode(FlameSensor, INPUT); 
pinMode(Buzzer, OUTPUT); 
digitalWrite(Buzzer, LOW); 
delay(5000); // wait for 5 seconds
  
}

void loop() {

  
  if ( digitalRead(FlameSensor) == HIGH) // 
  {
  textForSMS =  "\nFire Detected!";  
  analogWrite(Buzzer, 200); 
  sendSMS(textForSMS);
  Serial.println(textForSMS);
  Serial.println("message sent."); 
  delay(8000);
  }
  if ( digitalRead(FlameSensor) == LOW) // 
  {
  Serial.println("No Fire Detected"); 
  digitalWrite(Buzzer, LOW);
  delay(1000);
  }
  
}


void sendSMS(String message)
{
  SIM900.print("AT+CMGF=1\r");                     // AT command to send SMS message
  delay(1000);
 SIM900.println("AT + CMGS = \"+923339537499\"");  // recipient's mobile number, in international format
 
  delay(1000);
  SIM900.println(message);                         // message to send
  delay(1000);
  SIM900.println((char)26);                        // End AT command with a ^Z, ASCII code 26
  delay(1000); 
  SIM900.println();
  delay(100);                                     // give module time to send SMS
 
}


GSM SIM900A Arduino Fire Alarm System Code Explanation:

I started off by including the SoftwareSerial library. The SoftwareSerial library is used for creating multiple serial ports. As you know in Arduino we have only one serial port which is available on pin number 0 and pin number 1 and this is normally used for debugging purposes. So if we connect the GSM Sim900A module with the Arduino’s default Serial Port then we won’t be able to send data to the Serial monitor. So, that’s why I always say never connect any Serial Communication supported device with the Arduino’s default serial port. We can use the SoftwareSerial library for creating a serial port on other digital pins.

#include <SoftwareSerial.h>

I defined a Serial Port with name SIM900 on the Arduino’s digital pins 7 and 8.

SoftwareSerial SIM900(7, 8); // gsm module connected here

textForSMS is a variable of the type String which is used to store the text message, which is sent when the fire is detected.

String textForSMS;

Next, I defined Pins for the Flame Sensor and Buzzer. The Flame sensor is connected with Arduino’s digital pin 4, while the Buzzer is connected with the Arduino’s PWM pin 5. By connecting the buzzer with the PWM pin this way we can control the sound intensity.

int FlameSensor = 4; // Flame Sensor

int Buzzer = 5; // Alarm/light can be connected with this Buzzer\

void setup() {

Don’t connect any sensor with the Analog pin A0.

randomSeed(analogRead(0));

I activated the serial communication using the Serial.begin() function. while 9600 is the baud.

Serial.begin(9600);

Next, I activated the GSM Sim900A module. The GSM Sim900A module supports 9600. If you are using any other GSM module make sure you check the Baud Rate, which you can find in the datasheet.

SIM900.begin(9600); // original 19200. while enter 9600 for sim900A

Serial.println(” logging time completed!”);

Using the pinMode() function I set the Flame Sensor as the input and Buzzer as the output.

pinMode(FlameSensor, INPUT);

pinMode(Buzzer, OUTPUT);

By default I want to keep the buzzer low. For this I used the digitalWrite() function.

digitalWrite(Buzzer, LOW);

delay(5000); // wait for 5 seconds

}

Then starts the void loop() function.

void loop() {

Inside the void loop() function we have only two if conditions.

This if condition, is used to check if the Flame is detected. So, if the flame is detected by the Sensor, the Flame detector will give High signal, which is read by the Arduino using the digitalRead() function.

if ( digitalRead(FlameSensor) == HIGH) //

{

The Fire Detected! Message is stored in the textForSMS variable. You can write any text as per your requirement.

textForSMS =  “\nFire Detected!”;

The buzzer is turned ON. Currently, I am using 200, this value can be from 0 to 255. You can try different values which will give you different sound levels.

analogWrite(Buzzer, 200);

finally, using the sendSMS() function the Fire Detected! Message is sent, and then it waits for 8 seconds.

sendSMS(textForSMS);

Serial.println(textForSMS);

Serial.println(“message sent.”);

delay(8000);

}

This if condition means if no fire is detected then simply send a message to the Serial monitor and Turn off the buzzer.

  if ( digitalRead(FlameSensor) == LOW) //

{

Serial.println(“No Fire Detected”);

digitalWrite(Buzzer, LOW);

delay(1000);

}

 

}

Once you are done with the programming, then you can comment the Serial.println() functions, because when you practically install this GSM Arduino Fire Alarm system then there is no need to send messages to the serial monitor, as there will be no computer connected.


sendSMS() is a user defined function, it has no return type and it takes only one argument as the input which is of the type String. The instructions used inside this function are exactly the same, I have been using this function in almost all of my GSM based projects.

void sendSMS(String message)

{

SIM900.print(“AT+CMGF=1\r”);                     // AT command to send SMS message

delay(1000);

SIM900.println(“AT + CMGS = \”+923339537499\””);  // recipient’s mobile number, in international format

delay(1000);

SIM900.println(message);                         // message to send

delay(1000);

SIM900.println((char)26);                        // End AT command with a ^Z, ASCII code 26

delay(1000);

SIM900.println();

delay(100);                                     // give module time to send SMS

}

At the end, I successfully detected the Fire and I was able to send an alert message. With this my project on the Arduino Fire Alarm System comes to an end. This project can be easily modified, multiple sensors can be connected.

Arduino Fire Alarm


Watch Video Tutorial:

 

Other Related Projects based on the GSM SIM900A module:

Flood Monitoring System with SMS Alert using Arduino and GSM

Door Lock System using Arduino and GSM, Wireless Electronic Lock


Door Opening GSM alarm Wireless home security system using Arduino

How to use GSM and Bluetooth Together To monitor Any Sensors wirelessly using Arduino

RFID & GSM based student Attendance Alert message to parents


Arduino GSM Project: Security Alert message to multiple numbers

Request Temperature Data Using GSM and Arduino

Arduino and Gsm based laser security system

Car accident location tracking using GSM, GPS, and Arduino

GSM Alarm System Using Arduino and a PIR Sensor

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button