An ESP32-Powered Flame Sensing System for Unstoppable Safety!

Introduction to ESP32 with Flame Sensor

A flame sensor is used to detect the presence of fire or flame. It is a critical component in fire detection systems and is capable of sensing light in the range of 760nm to 1100nm (infrared light). When integrated with the ESP32, it becomes a powerful tool for safety automation in both home and industrial settings.

Components Required

This project demonstrates how to connect a flame sensor to an ESP32 board to detect fire presence and output a response via Serial Monitor.

  • Connect Flame Sensor VCC to ESP32 3.3V
  • Connect Flame Sensor GND to ESP32 GND
  • Connect Flame Sensor DO (Digital Out) to ESP32 GPIO 5
  • Open Arduino IDE and install the ESP32 board definitions
  • Select 'ESP32 Dev Module' from Tools > Board
  • Connect ESP32 to your PC via USB
  • Select the correct COM port
  • Create a new sketch and paste the provided code
  • Upload the code to the ESP32
  • Open Serial Monitor and observe flame detection messages

Formula: Flame Detection = DO Pin Output (LOW when flame is detected)

Components List

  • 1 × ESP32 Development Board
  • 1 × Flame Sensor Module
  • Jumper Wires
  • Breadboard (optional)

Pin Configuration

  • VCC: Connect to 3.3V of ESP32
  • GND: Connect to GND of ESP32
  • DO: Connect to GPIO 5 of ESP32

Ensure the sensor is oriented correctly toward the flame source and avoid direct sunlight for accurate results.

Wiring and Connections

  • -> 3.3V
  • -> GND
  • -> GPIO 5

Code for ESP32 with Flame Sensor

1const int flamePin = 5;
2
3void setup() {
4  Serial.begin(115200);
5  pinMode(flamePin, INPUT);
6}
7
8void loop() {
9  int flameState = digitalRead(flamePin);
10  if (flameState == LOW) {
11    Serial.println("Flame Detected!");
12  } else {
13    Serial.println("No Flame.");
14  }
15  delay(1000);
16}

Code Explanation

  • const int flamePin = 5;: Assigns GPIO 5 to the flame sensor’s digital output pin.
  • pinMode(flamePin, INPUT);: Sets the GPIO pin as an input to read digital signals from the flame sensor.
  • digitalRead(flamePin);: Reads the current state of the sensor—LOW means flame is detected.
  • Serial.println(...);: Prints whether flame is detected or not on the Serial Monitor.
  • delay(1000);: Introduces a 1-second delay between each reading.

Applications

  • Fire detection and safety systems
  • Smart firefighting robots
  • Industrial fire monitoring
  • Home fire alarm systems

Conclusion

You’ve successfully interfaced a flame sensor with the ESP32 using a digital output pin. This setup can detect the presence of a flame and alert users via Serial Monitor, offering a foundation for more complex safety systems.