FIRE DETECTION THROUGH ESP32 MOBILE APP (IoT Project in Nepal)
This project is designed to detect fire using an ESP32 microcontroller and a flame sensor. The system monitors the flame sensor's readings and sends data to a mobile app via the Blynk platform. Additionally, it displays the status on an LCD screen. If fire is detected, an alert message is displayed on both the mobile app and the LCD. This project demonstrates how IoT can be leveraged for fire detection and safety systems.
Project : 47
Introduction
This project is designed to detect fire using an ESP32
microcontroller and a flame sensor. The system monitors the flame sensor's
readings and sends data to a mobile app via the Blynk platform. Additionally,
it displays the status on an LCD screen. If fire is detected, an alert message
is displayed on both the mobile app and the LCD. This project demonstrates how
IoT can be leveraged for fire detection and safety systems.
Components Required
1.
ESP32
Microcontroller: The main control unit that processes sensor data and
communicates with the Blynk app.
2.
Flame Sensor:
Detects the presence of fire or flame.
3.
LiquidCrystal_I2C
Display: For displaying the fire status locally.
4.
WiFi Network:
For the ESP32 to connect and send data to the Blynk server.
5.
Connecting Wires:
To connect the sensor and the LCD to the ESP32.
6.
Power Supply:
To power the ESP32 and other components.
Pin
Configuration
•
Flame
Sensor Pin: Connected to GPIO 34 of the ESP32.
•
LCD Pins:
Connected via I2C (SDA and SCL pins on ESP32).
Libraries Used
1.
BlynkSimpleEsp32:
For communication with the Blynk app.
2.
Wire: For
I2C communication.
3.
LiquidCrystal_I2C:
For interfacing with the LCD display.
4.
WiFi: For
connecting the ESP32 to a WiFi network.
Code:
//Copy
the blynk credential from your acoount device and paset it here
#define
BLYNK_TEMPLATE_ID "TMPL670BbO1Nl"
#define
BLYNK_TEMPLATE_NAME "Data Monitoring"
#define
BLYNK_AUTH_TOKEN "4Q5w-qYfY3jO82qXBaL3O0E3irLFfDwb"
#define
BLYNK_PRINT Serial
#include
<BlynkSimpleEsp32.h>
#include
<Wire.h>
#include
<WiFi.h>
#include
<LiquidCrystal_I2C.h>
LiquidCrystal_I2C
lcd(0x27, 16, 2);
#define
Sensor_PIN 34
char auth[] = BLYNK_AUTH_TOKEN; char ssid[]
= "nepatronix_2.4"; //Enter
your WIFI SSID name char pass[] = "CLB269DA03"; //Enter your WIFI password BlynkTimer
timer;
void notify() { int value = analogRead(Sensor_PIN);
Serial.println(value); Blynk.virtualWrite(V1,
value); display(14, 1,
String(value)); if (value < 200) {
display(1, 1, "No Fire ");
}
else { display(1, 1,
"Fire Detected ");
}
delay(100);
}
void
setup() {
Serial.begin(9600); Wire.begin();
lcd.init(); lcd.clear(); lcd.backlight(); lcd.setCursor(1, 0);
lcd.print("**NEPATRONIX**");
delay(2000);
lcd.clear();
pinMode(Sensor_PIN, INPUT);
display(1, 0, "Fire Status: ");
Blynk.begin(auth, ssid, pass); //Connecting to Blynk Server with ssid
and password delay(500);
Serial.println(WiFi.localIP());
timer.setInterval(100L, notify);
}
void
loop() {
Blynk.run(); //run the blynk function in loop timer.run();
}
void
display(int col, int row, String msg) {
lcd.clear();
lcd.setCursor(col, row);
lcd.print(msg);
}
Working
1.
Initialization:
o
The ESP32 initializes serial communication at
9600 baud rate. o The I2C communication is set up for the LCD, and an initial
message is displayed. o WiFi connection is established using the provided
SSID and password.
o
The Blynk connection is initiated with the
provided authentication token.
2.
Main Loop:
o
The main loop runs continuously, checking for
sensor data and Blynk updates. o The sensor value is read and displayed on the LCD and
sent to the Blynk app.
o
If the sensor value indicates fire (value >=
200), a fire detected message is displayed; otherwise, a no fire message is
shown.
3.
Notification
Function:
o
Reads the flame sensor value.
o
Sends the sensor value to the Blynk app and
updates the LCD.
o
Displays a fire detected message if the value
exceeds a threshold (e.g., 200), otherwise, it displays no fire.
Testing
1.
Setup:
Assemble all components as per the pin configuration.
2.
Power Up:
Power the ESP32 and ensure all components are properly powered.
3.
WiFi Connection:
Ensure the ESP32 is connected to the WiFi network and can communicate with the
Blynk server.
4.
Sensor Testing:
Place a flame near the sensor to test its response. The LCD and Blynk app
should display a fire detected message when a flame is present and no fire when
absent.
5.
Monitoring:
Continuously monitor the sensor readings on the LCD and the Blynk app to ensure
proper functioning.
Conclusion
The Fire Detection Through ESP32 Mobile App project
successfully demonstrates how to use an ESP32 microcontroller for fire
detection. By integrating a flame sensor with the ESP32 and utilizing the Blynk
platform for mobile app notifications, the project provides a reliable and
real-time fire monitoring system. The use of an LCD display ensures local
visibility of the fire status, making it a comprehensive solution for fire
safety applications.