Home IoT Hub Series · 11

[Part 11] Catch flame signs while away from home - flame-sensor fire node

Detect flame with a simple flame sensor and trigger the hub warning slot.

This part adds a flame sensor as a simple fire-warning slot. It reacts to infrared light from a visible flame and sends 1 to the hub when detected.

Use it as an extra signal only. Smoke detectors and certified fire alarms are still required for real safety.

[Part 11] Catch flame signs while away from home - flame-sensor fire node hero image
System architecture and data pipeline note
This article is part of the Home IoT Hub system connected to the central NodeMCU server built in Part 2: Building the Brain. The flame sensor detects the infrared band from flame and updates the hub's fire-warning slot. The collected data is sent over the local IoT_Hub_Net network and updates slot 8 for flame/fire detection on the central server (/set?no8=value), becoming part of the decision pipeline for the 20-channel smart-home controller.

Parts and cost

PartQtyUnit price
Wemos D1 Mini1 pc$1.50
flame sensor module1 pc$0.70
Jumper wires 3 pc
Total$2.20

Pin wiring

[Part 11] Catch flame signs while away from home - flame-sensor fire node wiring diagram
Sensor / moduleBoard pin
VCC3.3V
GNDGND
DOD1 (GPIO5)

Full code

[Part 11] Catch flame signs while away from home - flame-sensor fire node - Code 2
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

const char* ssid     = "IoT_Hub_Net";
const char* password = "iothub1234";
const char* hubURL   = "http://192.168.1.1";

#define FLAME_PIN 5   // D1
#define SLOT_NO   8
#define INTERVAL  2000

void setup() {
  Serial.begin(115200);
  pinMode(FLAME_PIN, INPUT);

  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid, password);
  Serial.print("Connecting to IoT_Hub_Net");
  while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); }
  Serial.println("\nConnected!");
}

void loop() {
  int detected = !digitalRead(FLAME_PIN); // LOW = detected, invert to 1

  Serial.print("Flame: "); Serial.println(detected ? "FIRE!" : "OK");

  WiFiClient client; HTTPClient http;
  String url = String(hubURL) + "/set?no"
             + String(SLOT_NO) + "=" + String(detected);
  http.begin(client, url); http.GET(); http.end();
  Serial.println("HTTP -> " + url);

  delay(INTERVAL);
}

Upload and check

Connect the Wemos D1 Mini to the PC with a USB data cable, select the ESP8266 board and port in the Arduino IDE, upload the sketch, then open Tools → Serial Monitor and set the baud rate to 115200.

Serial Monitor

After uploading, open Tools → Serial Monitor in the Arduino IDE and set the baud rate to 115200. The following is an example Serial Monitor flow for checking normal operation. This is not a real screenshot. It shows flame-sensor state, sunlight filtering, and slot 8 warning updates.

[BOOT] Home IoT Node #11 - Flame sensor alert
[GPIO] flame_raw=HIGH, daylight_guard=PASS
[SENSOR] flame_detected=NO
[HTTP] GET /set?no8=0
[HUB] 200 OK - slot no8=NORMAL
[TEST] lighter test -> flame_raw=LOW -> no8=1
[WARN] keep sensor angle away from direct window light
  • If Connected or connected appears, the Wi-Fi step passed.
  • If HTTP 200 or 200 OK appears, the value reached the brain server.
  • If the value does not update, check both the slot number in the URL and the sensor wiring.

Build notes

  • Bring a small test flame near the sensor briefly and confirm the hub buzzer reacts. Then tune sensitivity with the module trimmer.
  • Power on the hub brain first so the node can join IoT_Hub_Net.
  • Use the same slot number written in the source code.
  • Open the serial monitor at 115200 baud and confirm HTTP 200.
  • If the value does not appear on the hub, recheck wiring, GPIO number, and Wi-Fi connection.

Building an Early Fire Alert for Your Home with a Flame Sensor

An IR flame sensor reads the 760-1100nm infrared band emitted by flames, catching fire faster than smoke ever appears. Added to your Home IoT Hub series, it flows naturally into buzzer alarms and smartphone notifications.

Troubleshooting checkpoints

The node code can look short, but real home installation is affected by placement, power, Wi-Fi quality, and sensor noise. Check these points before letting the node become a decision input for the brain server.

SymptomLikely causeField fix
Sunlight is mistaken for fireThe infrared band overlaps with strong direct sunlightAim the sensor downward away from windows and lower sensitivity with the potentiometer using a lighter as the reference.
The value spikes when lights turn onIncandescent, halogen, or reflected light reaches the receiverAdd a small shade tube and send 1 only after 2-3 consecutive detections.
It reacts weakly near an actual flameThe receiver angle does not cover the burner or target areaUse a lighter during installation to verify the real field of view.
Recovery after an alert is unstableThe fire slot drives buzzer logic, so even brief false positives matterCombine flame with gas or temperature-rise conditions to reduce false alarms in daily use.

How to Use It

  • Kitchen gas range: Instantly catches the moment a pot boils over and flames spread while you stepped away.
  • Candles and incense: Sounds the alarm at the early stage when a candle knocked over by a child or pet ignites a curtain or paper.
  • Boiler/electrical rooms: Watches for flames from wiring sparks or boiler ignition faults even in unoccupied spaces.
  • Overheating heating pads and heaters: Placed near winter fire-risk spots, the buzzer wakes you and buys evacuation time.
  • Alert integration: On detection, fire both the buzzer and an MQTT/Telegram push from the hub so you stay informed even when out.

Recommended Placement

  • Aim the angle at the fire source: The sensor has roughly a 60-degree field of view and a stable indoor range of about 1-2m. Fix it so the lens looks straight at the range or boiler.
  • Wall/upper corner over ceiling: Since it sees the flame's light rather than heat or smoke, it does not need to sit on the ceiling. An upper wall with a clear line to the fire source works best.
  • Avoid direct sun and strong lighting: Window sunlight and halogen/incandescent bulbs emit infrared and cause false triggers. Pick a spot where such light does not hit the lens directly.

Practical Tips and Cautions

  • Filtering false positives: In software, debounce with an 'alarm only after continuous detection for several hundred ms' rule to sharply cut false triggers from momentary sun glare or remote-control IR.
  • Sensitivity tuning: Set the threshold via the module's trimmer, then verify real reaction distance by testing a lighter flame from 1m away.
  • Never use it alone: This sensor is strictly a supplementary detector. Always pair it with a certified fire alarm and extinguisher, and never trust a DIY alarm as your only safety device.

Frequently Asked Questions

Q. How is it different from a smoke detector? A smoke detector sees smoke particles; a flame sensor sees a flame's infrared. The flame sensor catches open-flame fires faster but is weak against smoldering, so using both together is ideal.

Q. It keeps false-triggering on sunlight. Turn it to face away from windows, increase the debounce time, and drop the sensitivity threshold one step. If it persists, a shallow hood over the lens to block overhead direct light helps.

Q. Can I extend the detection range? Bigger flames are caught from farther away, but treat 1-2m as the reliable indoor range and split sensors per fire source, which also reduces false alarms.