Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.
Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.
Notes: For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.
Flame Sensor Arduino: Build Your Own Fire Detection System
I’ve spent years designing embedded systems and safety circuits, and one question keeps popping up in maker forums: how do you build a reliable fire detection system without spending a fortune? The answer sits on my workbench right now: a flame sensor Arduino setup that costs less than $10 and takes about 30 minutes to assemble.
This guide walks you through everything you need to know about interfacing flame sensors with Arduino boards, from understanding the underlying hardware to writing production-ready code.
What Is a Flame Sensor and How Does It Work?
A flame sensor is essentially an infrared photodiode tuned to detect wavelengths between 760nm and 1100nm, which happens to be the exact range emitted by burning flames. When fire ignites, it radiates infrared light that the sensor’s photodiode picks up. This signal then passes through an LM393 comparator chip that converts the analog reading into a clean digital output.
The detection mechanism is straightforward: the photodiode’s resistance changes proportionally to the IR intensity hitting it. More infrared radiation means lower resistance, which the comparator interprets against a threshold voltage set by an onboard potentiometer.
Key Components Inside a Flame Sensor Module
Component
Function
IR Photodiode (YG1006)
Detects infrared radiation from flames
LM393 Comparator
Converts analog signal to digital output
Potentiometer
Adjusts detection sensitivity threshold
Power LED
Indicates module is receiving power
Signal LED
Lights up when flame is detected
Most modules you’ll encounter, like the popular HW-072 or KY-026, use this same architecture. The YG1006 phototransistor inside is specifically sensitive to IR due to its black epoxy packaging.
Flame Sensor Arduino Specifications
Before wiring anything, you need to understand what you’re working with. Here are the technical specs that matter:
Parameter
Value
Operating Voltage
3.3V to 5V DC
Detection Wavelength
760nm to 1100nm
Detection Angle
Approximately 60 degrees
Detection Distance
30cm to 100cm (varies with flame size)
Output Types
Digital (DO) and Analog (AO)
Current Consumption
~20mA
The detection distance deserves special attention. A candle flame might register at 30cm, while a larger fire could trigger the sensor from nearly a meter away. Environmental factors like ambient IR sources and sensor cleanliness also affect performance.
Flame Sensor Pinout Explained
Most flame sensor modules have three or four pins:
Pin
Label
Connection
1
VCC
Arduino 5V
2
GND
Arduino GND
3
DO
Digital pin (for threshold detection)
4
AO
Analog pin (for intensity measurement)
The digital output gives you a simple HIGH/LOW signal based on whether flame intensity exceeds the threshold set by the potentiometer. The analog output provides a continuous reading from 0 to 1023, letting you measure flame intensity rather than just presence.
Wiring the Flame Sensor to Arduino
The circuit is about as simple as it gets in electronics. Here’s what you need to connect:
Basic Wiring Connections
Flame Sensor Pin
Arduino Pin
VCC
5V
GND
GND
DO
Digital Pin 2
AO
Analog Pin A0 (optional)
For a complete fire alarm system, add these components:
Component
Arduino Pin
Notes
Buzzer (+)
Digital Pin 3
Through 220Ω resistor if needed
Buzzer (-)
GND
Direct connection
LED Anode
Digital Pin 4
Through 220Ω resistor
LED Cathode
GND
Direct connection
Double-check your connections before powering on. A reversed polarity on the sensor won’t necessarily destroy it immediately, but it won’t work correctly either.
Arduino Code for Flame Detection Using Digital Output
Let’s start with the simplest approach: reading the digital output pin. This method works well when you just need to know whether a flame is present or not.
// Flame Detection using Digital Output
const int flamePin = 2; // Digital input from sensor
const int buzzerPin = 3; // Buzzer output
const int ledPin = 4; // LED indicator
void setup() {
pinMode(flamePin, INPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int flameStatus = digitalRead(flamePin);
if (flameStatus == LOW) { // LOW means flame detected
digitalWrite(ledPin, HIGH);
tone(buzzerPin, 1000); // 1kHz alarm tone
Serial.println(“FIRE DETECTED!”);
} else {
digitalWrite(ledPin, LOW);
noTone(buzzerPin);
Serial.println(“No fire detected”);
}
delay(100);
}
Note that most flame sensors output LOW when fire is detected, not HIGH. This catches people off guard when they first start working with these modules. The logic is inverted because the photodiode’s resistance drops when exposed to IR, pulling the output low.
Arduino Code for Flame Detection Using Analog Output
The analog approach gives you more nuanced data. You can differentiate between a nearby candle and a distant bonfire, or implement multiple alert levels.
// Flame Detection using Analog Output with Intensity Levels
const int flamePinAnalog = A0;
const int buzzerPin = 3;
const int ledPin = 4;
// Threshold values (lower = more IR detected = closer flame)
const int closeFireThreshold = 300;
const int distantFireThreshold = 700;
void setup() {
pinMode(buzzerPin, OUTPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int flameIntensity = analogRead(flamePinAnalog);
Serial.print(“Flame Intensity: “);
Serial.println(flameIntensity);
if (flameIntensity < closeFireThreshold) {
// Close fire – urgent alarm
digitalWrite(ledPin, HIGH);
tone(buzzerPin, 2000, 200);
Serial.println(“WARNING: Close fire detected!”);
}
else if (flameIntensity < distantFireThreshold) {
// Distant fire – warning
digitalWrite(ledPin, HIGH);
tone(buzzerPin, 1000, 500);
Serial.println(“Alert: Distant fire detected”);
}
else {
// No fire
digitalWrite(ledPin, LOW);
noTone(buzzerPin);
}
delay(100);
}
The threshold values above are starting points. You’ll need to calibrate them based on your specific sensor and environment. Run the code with Serial Monitor open, note the readings with and without a flame present, then adjust accordingly.
Advanced Fire Alarm System with Two-Tone Siren
For a more attention-grabbing alarm, here’s code that mimics a fire truck siren:
// Fire Alarm with Two-Tone Siren
const int flamePin = 2;
const int buzzerPin = 3;
const int ledPin = 4;
void setup() {
pinMode(flamePin, INPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
if (digitalRead(flamePin) == LOW) {
digitalWrite(ledPin, HIGH);
fireAlarmSiren();
Serial.println(“FIRE DETECTED – ALARM ACTIVE”);
} else {
digitalWrite(ledPin, LOW);
noTone(buzzerPin);
}
delay(50);
}
void fireAlarmSiren() {
// High-low alternating tones
for (int i = 0; i < 3; i++) {
tone(buzzerPin, 1500);
delay(150);
tone(buzzerPin, 800);
delay(150);
}
}
Calibrating Your Flame Sensor Arduino Setup
Proper calibration separates a working prototype from a reliable safety device. Here’s my calibration process:
Step 1: Baseline Reading
Upload this calibration sketch:
const int flamePinAnalog = A0;
const int flamePinDigital = 2;
void setup() {
pinMode(flamePinDigital, INPUT);
Serial.begin(9600);
Serial.println(“Calibration Mode – Record readings”);
}
void loop() {
int analogVal = analogRead(flamePinAnalog);
int digitalVal = digitalRead(flamePinDigital);
Serial.print(“Analog: “);
Serial.print(analogVal);
Serial.print(” | Digital: “);
Serial.println(digitalVal);
delay(500);
}
Step 2: Record Values
Document readings under different conditions:
Condition
Analog Reading
Digital Output
No flame, indoor
950-1023
HIGH
No flame, bright sunlight
700-850
Varies
Candle at 50cm
400-600
LOW
Candle at 20cm
100-300
LOW
Lighter at 30cm
200-400
LOW
Step 3: Adjust Sensitivity
Turn the onboard potentiometer while monitoring readings. Clockwise typically increases sensitivity, counterclockwise decreases it. Find the sweet spot where normal conditions read HIGH but a test flame triggers LOW.
Common Problems and Troubleshooting
After helping dozens of makers debug their flame sensor projects, I’ve compiled the issues I see most often:
Sensor Not Detecting Flames
Check these first:
Verify VCC is connected to 5V (not 3.3V unless your module supports it)
Confirm the sensor faces the flame directly within the 60-degree detection cone
Clean the photodiode lens with isopropyl alcohol
Test with a larger flame source like a candle instead of a lighter
False Alarms Without Any Fire
Common causes:
Direct sunlight hitting the sensor contains IR
Incandescent light bulbs emit IR
TV remotes use IR and can trigger detection
Sensitivity potentiometer set too high
Solutions:
Adjust the potentiometer to reduce sensitivity
Add a physical shroud around the sensor to block ambient IR
Use averaging in your code to filter noise
Position sensor away from windows and IR sources
Inconsistent Readings
Try this averaging filter:
int getAverageReading(int pin, int samples) {
long total = 0;
for (int i = 0; i < samples; i++) {
total += analogRead(pin);
delay(10);
}
return total / samples;
}
This smooths out electrical noise and brief IR spikes that might cause erratic behavior.
Real-World Applications for Flame Sensor Arduino Projects
The flame sensor Arduino combination finds practical use across several domains:
Home Fire Detection
A DIY fire alarm monitoring a gas stove, fireplace, or workshop. Wire multiple sensors to cover different angles and rooms. Add a GSM module to send SMS alerts when fire is detected.
Fire Fighting Robots
Competition and educational robots use arrays of flame sensors to locate and navigate toward fire sources. Three sensors positioned at different angles help determine fire direction:
Sensor Position
Detection Indicates
Left sensor only
Fire is to the left
Right sensor only
Fire is to the right
Center sensor only
Fire is straight ahead
Multiple sensors
Large fire or close proximity
Industrial Safety Systems
Manufacturing facilities use flame sensors to monitor equipment, detect welding accidents, or trigger suppression systems. These typically require more robust sensors and redundancy.
Kitchen Safety Monitors
Monitor cooking areas and trigger ventilation or shut off gas supplies when open flames are detected unexpectedly.
Enhancing Your Fire Detection System
Once you have basic detection working, consider these improvements:
Add WiFi Connectivity
Using an ESP8266 or ESP32 instead of standard Arduino adds internet connectivity:
// Pseudo-code for WiFi alert
if (fireDetected) {
sendHTTPRequest(“https://yourserver.com/alert”);
// Or use IFTTT, Blynk, or similar IoT platforms
}
Implement Multiple Sensor Arrays
Cover larger areas with multiple sensors. The 5-in-1 flame sensor modules mount five detectors on a single PCB, each pointing in a different direction for wider coverage.
Combine with Smoke Detection
Pair your flame sensor with an MQ-2 gas and smoke sensor for comprehensive fire detection that catches both flaming fires and smoldering combustion.
Useful Resources and Downloads
Here are resources I reference regularly when working with flame sensors:
Resource
Link
Arduino IDE
https://www.arduino.cc/en/software
HW-072 Datasheet
Search “YG1006 phototransistor datasheet”
LM393 Comparator Reference
https://www.ti.com/product/LM393
Fritzing (Circuit Diagrams)
https://fritzing.org/
Arduino Project Hub
https://projecthub.arduino.cc/
Component Sources
Component
Where to Buy
Flame Sensor Module
Amazon, AliExpress, Adafruit
Arduino Uno
Official Arduino Store, SparkFun
Piezo Buzzer
Any electronics supplier
Jumper Wires
Electronics starter kits
Safety Considerations
A few important warnings before you deploy any fire detection system:
This is not a certified safety device. DIY flame sensor projects should supplement, not replace, commercially certified smoke detectors and fire alarms. Building codes in most jurisdictions require UL-listed detection equipment.
Test regularly. Sensors degrade over time. Dust accumulates. Components fail. Schedule monthly tests with a controlled flame source.
Handle fire sources carefully. When testing with candles or lighters, have a fire extinguisher nearby, work in well-ventilated areas, and never leave flames unattended.
Mount sensors appropriately. High temperatures can damage the sensor. Maintain at least 30cm distance from potential fire sources.
Frequently Asked Questions
What is the detection range of a flame sensor with Arduino?
Most IR flame sensors detect flames between 30cm and 100cm, depending on flame size and ambient conditions. Larger flames emit more infrared radiation and can be detected from greater distances. Direct sunlight and other IR sources may reduce effective range by raising the noise floor.
Can a flame sensor detect all types of fires?
No. IR flame sensors detect visible flames that emit infrared radiation. They won’t detect smoldering fires without open flame, electrical fires in early stages, or fires hidden behind obstructions. For comprehensive coverage, combine flame sensors with smoke detectors.
Why does my flame sensor trigger without any fire present?
False triggers usually come from ambient IR sources: sunlight, incandescent bulbs, halogen lamps, TV remotes, or other heat-emitting objects. Reduce sensitivity using the onboard potentiometer, add physical shielding around the sensor, or implement software filtering with averaging algorithms.
How do I connect multiple flame sensors to one Arduino?
Connect each sensor’s digital output to a separate digital pin (D2, D3, D4, etc.) or analog output to separate analog pins (A0, A1, A2). All sensors can share common VCC and GND connections. Adjust your code to read all pins and determine which sensor or sensors detected the flame.
What’s the difference between digital and analog output on flame sensors?
Digital output provides a simple binary signal: HIGH (no flame) or LOW (flame detected) based on the threshold set by the potentiometer. Analog output gives a continuous voltage proportional to detected IR intensity, ranging from 0 to 1023 on Arduino’s ADC. Use digital for simple presence detection; use analog when you need to measure flame intensity or implement multiple alert levels.
Wrapping Up
Building a flame sensor Arduino fire detection system teaches fundamental concepts in sensor interfacing, analog/digital signal processing, and safety system design. The low cost of components makes it accessible for learning, while the practical application of fire detection gives the project real value.
Start with the basic digital detection code, get that working reliably, then gradually add complexity: analog intensity measurement, multiple sensors, WiFi alerts, or integration with home automation systems. Each addition reinforces electronics and programming concepts while building something genuinely useful.
The flame sensor might be one of the simplest modules you’ll ever work with, but don’t underestimate its value. Combined with thoughtful placement and proper calibration, these inexpensive IR detectors form the foundation of effective fire monitoring systems.
Inquire: Call 0086-755-23203480, or reach out via the form below/your sales contact to discuss our design, manufacturing, and assembly capabilities.
Quote: Email your PCB files to Sales@pcbsync.com (Preferred for large files) or submit online. We will contact you promptly. Please ensure your email is correct.
Notes: For PCB fabrication, we require PCB design file in Gerber RS-274X format (most preferred), *.PCB/DDB (Protel, inform your program version) format or *.BRD (Eagle) format. For PCB assembly, we require PCB design file in above mentioned format, drilling file and BOM. Click to download BOM template To avoid file missing, please include all files into one folder and compress it into .zip or .rar format.