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.
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
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)
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.
This pin powers the module, the operating voltage is +5V
This is the ground pin
You can also get digital output from this sensor using this pin, by setting a threshold value using the potentiometer
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.
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.
Tap on + sign to add below highlighted widgets
Add a notification widget as well.
Configure the gauge with below details.
Also configure the LED
Set the Value Display widget as per below settings
And finally your Blynk project setup is complete. You can rearrange the widgets and place them as you wish.
Some more Interesting Projects:
- IoT Vehicle Parking System using ESP8266 and Blynk
- NTP Digital Clock using ESP8266 and OLED Display
- NodeMCU based WiFi Network Scanner with OLED Display
- DHT11 Sensor with ESP-NOW and ESP32
- Raspberry Pi Flask Web Server with DHT11
- ESP32 Web Server PWM based LED Control
- IoT Heart Rate Monitoring with ThingSpeak Platform
- Temperature Monitoring with ESP-DASH Webserver
- Setting up a LDR Sensor with Arduino
- Wemos D1 Mini Web Server based Servo Motor Control
- ESP8266 Web Server for Controlling Electrical Devices
- Controlling ESP32 via Bluetooth using Blynk
Required Arduino Libraries
This code need 2 Arduino library. You can download Arduino IDE from Here.
Go to Sketch -> Include Library -> Manage Libraries
Now search for ESP8266 and install
Search for Blynk and install
If you are using ESP32 then you have to get ESP32 libraries.
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.
You will receive below alert notification when flame sensor detects flame or fire.
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.
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.