Fire and Gas Monitoring System(IoT Project)
The Fire and Gas Monitoring System is designed to enhance safety in residential, commercial, and industrial environments. It continuously monitors for fire and gas leaks using a fire sensor and an MQ2 gas sensor. When a hazardous condition is detected, the system alerts the user via an LCD display and activates a buzzer. This system provides an effective way to quickly respond to fire outbreaks and gas leaks, potentially preventing damage and saving lives.
Project : 2
Fire and
Gas Monitoring System
Description
The Fire and Gas Monitoring System is designed to enhance
safety in residential, commercial, and industrial environments. It continuously
monitors for fire and gas leaks using a fire sensor and an MQ2 gas sensor. When
a hazardous condition is detected, the system alerts the user via an LCD
display and activates a buzzer. This system provides an effective way to
quickly respond to fire outbreaks and gas leaks, potentially preventing damage
and saving lives.
Required Components
- Arduino
Board: The central microcontroller to process sensor data and control
the display and buzzer (e.g., Arduino Uno, Mega).
- Fire
Sensor: A sensor to detect the presence of fire or high temperatures.
- MQ2
Gas Sensor: A sensor to detect smoke and various gases like LPG, CO,
and methane.
- LCD
Display with I2C Interface: A 16x2 LCD to display the status of fire
and gas detection.
- Buzzer:
An audible alert that sounds when a hazardous condition is detected.
- Connecting
Wires: Wires to connect all components to the Arduino.
- Breadboard
(Optional): For easier prototyping and connections.
Working Principle
- Initialization:
- The
Arduino initializes serial communication for debugging purposes.
- The
LCD is initialized and a welcome message is displayed.
- Sensor
pins and the buzzer pin are configured.
- Sensor
Reading:
- The
fire sensor provides a digital output (HIGH or LOW) indicating the
presence of fire.
- The
MQ2 gas sensor provides an analog output that corresponds to the
concentration of detected gases.
- Data
Processing:
- The
Arduino reads the digital output from the fire sensor.
- It
also reads the analog value from the MQ2 gas sensor, which is then
compared to a predefined threshold to determine the presence of hazardous
gas levels.
- Display
and Alerts:
- The
sensor readings are displayed on the LCD, showing whether fire is
detected and the gas concentration level.
- If
fire is detected or the gas concentration exceeds the threshold, the
buzzer is activated to alert the user.
- Continuous
Monitoring:
- The
system continuously monitors the environment by repeatedly reading sensor
values and updating the display and buzzer status.
Code:
#include
<Wire.h>
#include
<LiquidCrystal_I2C.h>
// Define the I2C
address for the LCD
LiquidCrystal_I2C
lcd(0x27, 16, 2); // Adjust the address 0x27 if needed
// Define sensor pins
const int
fireSensorPin = 2;
const int
mq2SensorPin = A0;
const int buzzerPin =
8;
void setup() {
// Initialize the serial communication
Serial.begin(9600);
// Initialize the LCD
lcd.begin();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Initializing...");
// Initialize sensor pins
pinMode(fireSensorPin, INPUT);
pinMode(mq2SensorPin, INPUT);
pinMode(buzzerPin, OUTPUT);
// Wait for a second to initialize
delay(1000);
lcd.clear();
}
void loop() {
// Read the fire sensor value
int fireSensorValue =
digitalRead(fireSensorPin);
// Read the MQ2 sensor value
int mq2SensorValue =
analogRead(mq2SensorPin);
// Print the sensor values to the Serial
Monitor
Serial.print("Fire Sensor: ");
Serial.print(fireSensorValue);
Serial.print(" MQ2 Sensor: ");
Serial.println(mq2SensorValue);
// Display sensor values on the LCD
lcd.setCursor(0, 0);
lcd.print("Fire: ");
lcd.print(fireSensorValue ? "No" :
"Yes");
lcd.setCursor(0, 1);
lcd.print("Smoke: ");
lcd.print(mq2SensorValue);
// Check if fire or smoke is detected
if (fireSensorValue == LOW || mq2SensorValue
> 300) { // Adjust threshold as needed
digitalWrite(buzzerPin, HIGH); // Turn on
buzzer
} else {
digitalWrite(buzzerPin, LOW); // Turn off buzzer
}
delay(500); // Wait for 0.5 second before
next reading
}
Conclusion
The Fire and Gas Monitoring System is a reliable and
efficient solution for detecting fire and gas leaks. It provides real-time
monitoring and immediate alerts through an LCD display and buzzer, allowing for
quick responses to potential hazards. This system can significantly enhance
safety measures in various settings, reducing the risk of damage and harm caused
by fire and gas leaks. The integration of sensors with an Arduino
microcontroller and a user-friendly display makes it a versatile and valuable
addition to any safety protocol.