← Back to insights
ESP8266SensorsRemote MonitoringBeginner

IoT Flame and Fire Detection System Using ESP8266 and Blynk

Build a simple IoT flame detection system using ESP8266, a flame sensor, relay, warning light, and Blynk for local alerts and remote fire notifications.

  • ESP8266
  • Nodemcu
  • Flame Sensor
  • Fire Detection
  • Blynk
  • Relay
  • IOT
  • Safety Monitoring
Published
Updated
Reading time
2 min read
Author
Saroj Chaudhary
Role
IoT & Embedded Systems Engineer

A flame sensor can be used with the ESP8266 to detect the presence of a nearby flame and automatically activate a warning output.

In this project, the ESP8266 reads a flame sensor, switches a warning light through a relay, and sends a fire alert through Blynk.

The local warning works directly from the ESP8266, while Blynk provides remote monitoring and notification.

Important: This is an educational prototype and should not be used as a replacement for a certified fire alarm or life-safety system.

Components Required

Component Quantity
ESP8266 NodeMCU 1
Flame Sensor Module 1
Relay Module 1
Low-voltage Warning Light / Bulb 1
Suitable DC Power Supply 1
Breadboard 1
Jumper Wires As required

For classroom testing, use a low-voltage DC warning light rather than exposed AC mains wiring.

System Working

Flame Detected
      |
      v
Flame Sensor
      |
      v
   ESP8266
   /     \
  v       v
Relay    Wi-Fi
  |       |
  v       v
Warning  Blynk
 Light   Notification

When flame is detected:

Flame detected → Warning light ON → Blynk fire alert

When no flame is detected:

No flame → Warning light OFF

Circuit Connections

Flame Sensor

Flame Sensor ESP8266
VCC 3.3V
GND GND
DO D5 / GPIO14

This project uses the sensor’s digital output (DO).

Most flame sensor modules include a small potentiometer that can be used to adjust the detection threshold.

Relay Module

Relay ESP8266
IN D1 / GPIO5
GND GND
VCC According to relay module

Use a relay module that can be reliably triggered from a 3.3V ESP8266 GPIO signal.

The warning light is connected through the relay’s COM and NO contacts.

Blynk Setup

Create a Blynk Template and Device and obtain:

BLYNK_TEMPLATE_ID
BLYNK_TEMPLATE_NAME
BLYNK_AUTH_TOKEN

Create one Virtual Pin:

V0 → Flame Status

Suggested values:

0 → Normal
1 → Flame Detected

Also create a Blynk Event with the event code:

fire_alert

The ESP8266 can trigger the event using Blynk.logEvent().

ESP8266 Program

#define BLYNK_PRINT Serial

#define BLYNK_TEMPLATE_ID "YOUR_TEMPLATE_ID"
#define BLYNK_TEMPLATE_NAME "Fire Detection"
#define BLYNK_AUTH_TOKEN "YOUR_AUTH_TOKEN"

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char ssid[] = "YOUR_WIFI_NAME";
char pass[] = "YOUR_WIFI_PASSWORD";

const int FLAME_PIN = D5;
const int RELAY_PIN = D1;

const bool FLAME_ACTIVE_LOW = true;
const bool RELAY_ACTIVE_LOW = true;

bool previousFlameState = false;

void setWarning(bool state)
{
  if (RELAY_ACTIVE_LOW)
    digitalWrite(RELAY_PIN, state ? LOW : HIGH);
  else
    digitalWrite(RELAY_PIN, state ? HIGH : LOW);
}

bool flameDetected()
{
  int sensorState = digitalRead(FLAME_PIN);

  if (FLAME_ACTIVE_LOW)
    return sensorState == LOW;

  return sensorState == HIGH;
}

void checkFlame()
{
  bool flame = flameDetected();

  setWarning(flame);

  if (Blynk.connected())
  {
    Blynk.virtualWrite(V0, flame ? 1 : 0);
  }

  if (flame && !previousFlameState)
  {
    Serial.println("WARNING: Flame detected!");

    if (Blynk.connected())
    {
      Blynk.logEvent("fire_alert", "Flame detected by ESP8266 sensor.");
    }
  }

  if (!flame && previousFlameState)
  {
    Serial.println("Flame no longer detected.");
  }

  previousFlameState = flame;
}

void setup()
{
  Serial.begin(115200);

  pinMode(FLAME_PIN, INPUT);
  pinMode(RELAY_PIN, OUTPUT);

  setWarning(false);

  Blynk.begin(
    BLYNK_AUTH_TOKEN,
    ssid,
    pass
  );

  Serial.println("Flame Detection System Started");
}

void loop()
{
  Blynk.run();
  checkFlame();

  delay(200);
}

Testing

Normal Condition

Keep the flame away from the sensor.

Expected result:

Flame Status → 0
Warning Light → OFF

Flame Detection

Carefully bring a small controlled flame near the sensor.

Expected result:

Flame Status → 1
Warning Light → ON
Blynk Event → fire_alert
Remote notification → triggered

Remove the flame.

Expected result:

Flame Status → 0
Warning Light → OFF

If the sensor behaves in reverse, change:

const bool FLAME_ACTIVE_LOW = true;

to:

const bool FLAME_ACTIVE_LOW = false;

If the relay behaves in reverse, change:

const bool RELAY_ACTIVE_LOW = true;

to:

const bool RELAY_ACTIVE_LOW = false;

Common Problems

Sensor always detects flame

Adjust the potentiometer on the flame sensor and check the digital output using Serial Monitor.

Relay works in reverse

Change the RELAY_ACTIVE_LOW setting.

Blynk alert does not arrive

Check the Wi-Fi connection, Blynk credentials, Event Code, and notification settings.

ESP8266 resets when relay switches

Use a stable power supply and keep relay/load switching noise away from the ESP8266 supply.

Final Result

The completed system provides:

  • flame detection
  • automatic warning-light activation
  • local alarm operation
  • flame status monitoring through Blynk
  • remote fire-event notification
Flame

Sensor

ESP8266
  ├──→ Relay → Warning Light

  └──→ Wi-Fi → Blynk → Remote Alert

Safety Note

This project is intended for education and prototyping only.

Do not depend on a hobby flame sensor, ESP8266, Wi-Fi, Blynk, or a breadboard circuit as the only protection against fire.

For real buildings or safety-critical installations, use properly designed and certified fire detection and alarm equipment.

Related Articles

ESP8266Beginner

Automatic Night Light with IoT Monitoring Using ESP8266 and Blynk

Build an automatic night light using ESP8266, an LDR sensor, relay, bulb, and Blynk for light-level monitoring and manual override control.

  • ESP8266
  • Nodemcu
  • LDR
2 min readIoT
Read article
ESP8266Beginner

IoT Home Intruder Detection System Using ESP8266/ESP32 and Blynk

Build an IoT home intruder detection system using ESP8266 or ESP32, PIR and IR sensors, and Blynk for movement detection, entry monitoring, security status, and remote intrusion alerts.

  • ESP8266
  • ESP32
  • Nodemcu
4 min readESP32
Read article
ESP8266Beginner

Motion Activated Smart Room Light Using ESP8266/ESP32 and Blynk

Build a motion-activated smart room light using ESP8266 or ESP32, a PIR sensor, relay, bulb, and Blynk with automatic timeout control and remote monitoring.

  • ESP8266
  • ESP32
  • PIR Sensor
2 min readESP32
Read article

Author

Saroj Chaudhary

IoT & Embedded Systems Engineer

Founder-led engineering notes from IoTSolutions, focused on practical device, firmware, and telemetry decisions.

Apply the idea

Need help turning this article into a working prototype plan?

If you are working through device architecture, connectivity, firmware structure, or dashboard scope, IoTSolutions can help turn the question into a cleaner build path.