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](/iot-lab/assets/flame-sensor-fire-alert-hero.png)
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
| Part | Qty | Unit price |
|---|---|---|
| Wemos D1 Mini | 1 pc | $1.50 |
| flame sensor module | 1 pc | $0.70 |
| Jumper wires 3 pc | — | — |
| Total | $2.20 |
Pin wiring
| Sensor / module | Board pin |
|---|---|
| VCC | 3.3V |
| GND | GND |
| DO | D1 (GPIO5) |
Full code
#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
Connectedorconnectedappears, the Wi-Fi step passed. - If
HTTP 200or200 OKappears, 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.
| Symptom | Likely cause | Field fix |
|---|---|---|
| Sunlight is mistaken for fire | The infrared band overlaps with strong direct sunlight | Aim the sensor downward away from windows and lower sensitivity with the potentiometer using a lighter as the reference. |
| The value spikes when lights turn on | Incandescent, halogen, or reflected light reaches the receiver | Add a small shade tube and send 1 only after 2-3 consecutive detections. |
| It reacts weakly near an actual flame | The receiver angle does not cover the burner or target area | Use a lighter during installation to verify the real field of view. |
| Recovery after an alert is unstable | The fire slot drives buzzer logic, so even brief false positives matter | Combine 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.
This article is part of the 20-channel Home IoT system built from the Part 2 central brain server and the distributed edge nodes in Parts 3-19. Use this map to check the slot and sensor flow across the series.
[Part 1] Home IoT Hub overview[Part 2] Central brain server · slots 1-20[Part 3] Stop guessing room comfort · slots 1/2[Part 4] Did I close the door? · slots 9[Part 5] Is the fridge really cooling? · slots 12[Part 6] Should I open the window? · slots 3[Part 7] Stop bathroom mold before it starts · slots 19[Part 8] Is the boiler actually running? · slots 5/17[Part 9] Did I leave the gas stove on? · slots 6[Part 10] Get warned before gas smell becomes obvious · slots 7[Part 11] Catch flame signs while away from home · slots 8[Part 12] Is bad air making you foggy? · slots 13/14[Part 13] Why is the power bill so high? · slots 15[Part 14] Is water leaking, and how much are we using? · slots 16[Part 15] Do not leave windows open in the rain · slots 18[Part 16] Are the lights off and the door locked? · slots 11/10[Part 17] Control the air conditioner from the IoT hub · slots 4[Part 18] Is the dog bowl empty? · slots 20[Part 19] Cool the room only when someone is there · slots 1/4[Part 20] The house finally fits on one screen · slots all