IoT Fire Monitoring System Using NodeMCU, Flame Sensor, MQ-2 and DHT11 Using KiwisIoT
by ananthi rk in Circuits > Microcontrollers
22 Views, 0 Favorites, 0 Comments
IoT Fire Monitoring System Using NodeMCU, Flame Sensor, MQ-2 and DHT11 Using KiwisIoT
Fire accidents can cause serious damage to homes, laboratories, offices, industries, and other environments. Early detection of fire and smoke can help provide a quick warning.
In this project, we build a simple IoT Fire Monitoring System using a NodeMCU ESP8266.
The system uses three sensors:
- Flame Sensor – detects flame
- MQ-2 – measures smoke/gas level
- DHT11 – measures temperature and humidity
The sensor data is sent to the KiwisIoT dashboard through Wi-Fi, allowing the readings to be monitored remotely.
Supplies
Hardware Required
- NodeMCU ESP8266
- Flame Sensor Module
- MQ-2 Smoke Sensor
- DHT11 Sensor
- Jumper Wires
- USB Cable
- Wi-Fi Network
Software Required
- Arduino IDE
- ESP8266 Board Package
- DHT Sensor Library
- KiwisIoT Library
- KiwisIoT Dashboard
- USB Driver for NodeMCU
Circuit Connections
Flame Sensor
MQ-2 Sensor
DHT11
Circuit Overview
KiwisIoT Platform Setup
1. Login to KiwisIoT
Open the KiwisIoT platform and log in to your account.
After logging in, create a new dashboard/panel for the Fire Monitoring System.
2. Create a New Panel
Create a panel with the following name:
- Panel Name: Fire Monitoring System
3. Add Widgets
Create four widgets in the dashboard.
4. Configure Flame Status
Add a LABEL widget.
- Widget Type: LABEL
- Name: FLAME STATUS
- Channel ID: 0
The ESP8266 sends:
- FLAME DETECTED when a flame is detected
- NO FLAME when no flame is detected
5. Configure Smoke Level
Add a GAUGE or VALUE DISPLAY widget.
- Widget Type: GAUGE / VALUE
- Name: SMOKE LEVEL
- Channel ID: 1
- Unit: %
The MQ-2 sensor reading is converted into a 0–100% scale and sent to Channel 1.
6. Configure Temperature
Add another GAUGE or VALUE DISPLAY widget.
- Widget Type: GAUGE / VALUE
- Name: TEMPERATURE
- Channel ID: 2
- Unit: °C
The DHT11 temperature value is sent to Channel 2.
7. Configure Humidity
Add another GAUGE or VALUE DISPLAY widget.
- Widget Type: GAUGE / VALUE
- Name: HUMIDITY
- Channel ID: 3
- Unit: %
The DHT11 humidity value is sent to Channel 3.
8. Copy the Topic ID
After creating the dashboard, copy the Topic ID provided by KiwisIoT.
It will look similar to:
Replace the placeholder in your Arduino code:
with your actual Topic ID.
9. Final Dashboard Structure
Your KiwisIoT dashboard should contain:
🔥 Fire Monitoring System
- FLAME STATUS → Channel 0 → Flame detected / No flame
- SMOKE LEVEL → Channel 1 → Smoke percentage
- TEMPERATURE → Channel 2 → Temperature in °C
- HUMIDITY → Channel 3 → Humidity in %
Once the ESP8266 connects to Wi-Fi and KiwisIoT, the sensor values will be updated on the dashboard approximately every 5 seconds.
Arduino Code
Code Explanation
The Arduino program controls the Flame Sensor, MQ-2 Smoke Sensor, DHT11, and communicates with the KiwisIoT dashboard. The code reads the sensor values and sends them to different dashboard channels every 5 seconds.
1. Include Required Libraries
- KiwisIoT.h is used to connect the NodeMCU to the KiwisIoT platform.
- DHT.h is used to read temperature and humidity from the DHT11 sensor.
2. Wi-Fi Configuration
These lines store the Wi-Fi network name and password.
Replace the placeholder values with your actual Wi-Fi credentials.
3. KiwisIoT Topic ID
The Topic ID identifies the KiwisIoT dashboard that will receive the sensor data.
Replace dash_XXXXXXXXXXXXX with the Topic ID generated from your KiwisIoT dashboard.
4. Define Sensor Pins
These definitions specify where each sensor is connected to the NodeMCU:
5. Configure the DHT11 Sensor
Here, the code specifies that the connected sensor is a DHT11.
The dht object is then used to read temperature and humidity.
6. Setup Function
The setup() function runs only once when the NodeMCU starts.
It performs these operations:
- Starts Serial Monitor at 115200 baud.
- Configures the Flame Sensor pin as an input.
- Starts the DHT11 sensor.
- Starts the Wi-Fi and KiwisIoT connection.
- Displays a startup message in the Serial Monitor.
7. Keep KiwisIoT Connection Active
This function is called inside the loop() function to keep the KiwisIoT communication active.
8. Read Flame Sensor
The NodeMCU reads the digital output from the Flame Sensor.
The code checks:
If the sensor output is LOW, the code treats it as flame detected.
The flame status is sent to Channel ID 0.
If no flame is detected:
So Channel 0 displays the current flame status.
9. Read MQ-2 Smoke Sensor
The NodeMCU reads the analog value from the MQ-2 sensor through A0.
The raw reading is converted into a 0–100 scale:
Then the value is limited between 0 and 100:
Finally, the value is sent to KiwisIoT:
Therefore, Channel ID 1 is used for the normalized smoke-level reading.
Note: The 0–100 value is only a normalized sensor reading. It is not a calibrated smoke concentration measurement such as ppm.
10. Read Temperature
The DHT11 measures the temperature and stores the value in the temperature variable.
The code checks whether the reading is valid:
If valid, it sends the temperature to Channel ID 2:
The temperature is displayed in degrees Celsius.
11. Read Humidity
The DHT11 also measures humidity.
The code checks whether the value is valid:
Then the humidity value is sent to Channel ID 3:
The value is displayed as a percentage.
12. Update Interval
The program waits for 5 seconds before starting the next reading cycle.
Therefore, the sensor data is updated approximately every 5 seconds.
Channel Mapping Summary
Channel IDSensor/DataOutput
0
Flame Sensor
FLAME DETECTED / NO FLAME
1
MQ-2
Normalized 0–100 reading
2
DHT11
Temperature °C
3
DHT11
Humidity %
So the overall flow is:
Sensors → NodeMCU ESP8266 → Wi-Fi → KiwisIoT → Dashboard
How the System Works
Step 1 – Flame Detection
The Flame Sensor is connected to D5.
When a flame is detected, the sensor output becomes LOW.
The NodeMCU checks:
and sends:
to KiwisIoT.
Step 2 – Smoke Detection
The MQ-2 analog output is connected to A0.
The NodeMCU reads the analog sensor value:
The raw value is converted into a simple 0–100 scale:
The result is then displayed on the KiwisIoT dashboard.
Note: This 0–100 value is a normalized sensor reading, not a calibrated smoke concentration measurement such as ppm.
Step 3 – Temperature
The DHT11 measures temperature:
The temperature is sent to KiwisIoT using Channel ID 2.
Step 4 – Humidity
The DHT11 also measures humidity:
The humidity value is sent using Channel ID 3.
Step 5 – IoT Monitoring
The NodeMCU connects to Wi-Fi and sends all sensor readings to KiwisIoT.
The dashboard allows you to monitor:
- Flame status
- Smoke level
- Temperature
- Humidity
Testing the Project
After uploading the code to the NodeMCU:
- Open the Serial Monitor.
- Set the baud rate to 115200.
- Wait for the NodeMCU to connect to Wi-Fi.
- Place a safe flame source near the Flame Sensor for testing.
- Check the flame status.
- Test the MQ-2 using a suitable smoke source in a controlled environment.
- Observe the temperature and humidity values.
- Open the KiwisIoT dashboard.
- Verify that all four values are updating.
Expected Serial Monitor Output
KiwisIoT Dashboard Result
The final dashboard should contain four widgets:
Flame Status
FLAME DETECTED
Smoke Level
Smoke Level: 38%
Temperature
Temperature: 30°C
Humidity
Humidity: 65%
Applications
This project can be used as an educational prototype for:
- Home fire monitoring
- Office safety monitoring
- Laboratory monitoring
- Industrial environment monitoring
- Early fire-warning prototypes
- IoT-based safety systems
- Academic IoT projects
Conclusion
This project demonstrates how NodeMCU ESP8266, Flame Sensor, MQ-2, and DHT11 can be combined with KiwisIoT to create an IoT-based fire monitoring prototype.
The system detects flame, monitors a normalized smoke level, measures temperature and humidity, and sends the collected information to an online dashboard through Wi-Fi.
It provides a useful foundation for developing more advanced IoT-based fire and safety monitoring projects.