IoT based Fire Security Alarm System using NodeMCU

IoT based Fire Security Alarm System using NodeMCU

In this tutorial we are going to build a fire security alarm using multiple sensors. This project will send an alert whenever it detects fire and smoke. It has also connected with a buzzer and an LED which will act as a audio and visual indication for alert. So lets quickly start building IoT based Fire Security Alarm System using NodeMCU. You can also build this project using ESP32.

Materials Required

Below material are needed to build this project.

  • ESP8266 NodeMCU x 1
  • Flame Sensor x 1
  • MQ2 Smoke Sensor x 1
  • 5V Buzzer x 1
  • Led Any color x 1
  • Transistor BC547 x 1
  • Resistor 1KΩ x 2
  • Jumper cables
  • Breadboard

Flame Sensor

Flame sensor is capable of detecting flame and infrared light sources. It can measure the wavelengths ranging from 760 nm to 1100 nm. The module uses a LM393 comparator chip to provide a stable digital output signal. This comparator has a driving ability of 15 mA. This flame detector sensor can be used in different project including fire alarms and other fire detecting devices or projects.


  • LM393 comparator chip
  • Detection Range: 760 nm to 1100 nm
  • Operating Voltage: 3.3 V to 5 V
  • Maximum Output Current: 15 mA
  • Digital Outputs: 0 and 1
  • Detection Angle: about 60 degrees
  • Adjustable sensitivity via potentiometer
  • LED lights indicators: power (red) and digital switching output (green)

Smoke Sensor

In this project we are using a MQ2 smoke sensor. This sensor can detect various gases including Methane, Butane and LPG. We are using a MQ2 gas sensor module in this project for better interface. Below is the pin diagram of the module.

Pin Number

Pin Name




This pin powers the module, the operating voltage is +5V



This is the ground pin


Digital Out

You can also get digital output from this sensor using this pin, by setting a threshold value using the potentiometer


Analog Out

This pin provides an output of 0-5V analog voltage based on the intensity of the gas


  • Operating Voltage is +5V
  • Can be used to Measure or detect LPG, Alcohol, Propane, Hydrogen, CO and even methane
  • Analog output voltage: 0V to 5V
  • Digital Output Voltage: 0V or 5V (TTL Logic)
  • Preheat duration 20 seconds
  • Can be used as a Digital or analog sensor
  • The Sensitivity of Digital pin can be varied using the potentiometer


Here all the red and black wired are Vcc and GND connection. You can also add an additional relay module to switch on exhaust or any other ac appliance. You can modify the code and add it. We are using A0 pin of MQ2 gas sensor and D0 pin of Flame sensor.

IoT based Fire Security alarm system using NodeMCU

Setting up a Blynk Project

Open the blynk app and tap on create a new project. Fill the details as shown below

You will receive the Auth token on your registered email id.

Blynk Token

Tap on + sign to add below highlighted widgets

Add a notification widget as well.

Configure the gauge with below details.

IoT based Fire Security alarm system using NodeMCU

Also configure the LED

IoT based Fire Security alarm system using NodeMCU

Set the Value Display widget as per below settings

IoT based Fire Security alarm system using NodeMCU

And finally your Blynk project setup is complete. You can rearrange the widgets and place them as you wish.

IoT based Fire Security alarm system using NodeMCU

Some more Interesting Projects:

Required Arduino Libraries

This code need 2 Arduino library. You can download Arduino IDE from Here.

  • ESP8266
  • Blynk

Go to Sketch  ->  Include Library  ->  Manage Libraries

Now search for ESP8266 and install

Arduino config

Search for Blynk and install

IoT based Fire Security alarm system using NodeMCU

If you are using ESP32 then you have to get ESP32 libraries.

Arduino IDE Setup


You can download the code from below link and open it using Arduino IDE. You have to unzip the the zip file after download and open it. Just add the Auth Token and your WiFi details in the code.

You can refer to below articles to upload the code

Building and Testing

We have connected the components as per the connection diagram and now its time to test the project. For both the alert LED will glow and buzzer will start beeping.

IoT based Fire Security alarm system using NodeMCU

You will receive below alert notification when flame sensor detects flame or fire.

IoT based Fire Security alarm system using NodeMCU

Once the smoke sensor detects smoke and the value in the gauge goes beyond 500 then smoke alert will be detected. You can change the value in the code as per your need.

IoT based Fire Security alarm system using NodeMCU


This a multi sensor project where we will interface flame sensor and MQ2 gas sensor with ESP8266 NodeMCU. This will send a notification using blynk app using WiFi. The project is simple and easy to build. This project is for beginners to understand the concepts of sensors and interfacing them. You can use ESP32 to build the same project as a exercise. Don’t forget to share the tutorial with others.

1 thought on “IoT based Fire Security Alarm System using NodeMCU”

Leave a Comment