Flame Sensor Arduino: How to Use It for Fire Detection

Introduction

Fire detection is crucial for both residential and industrial applications. A flame sensor is a device that detects fire by sensing infrared or ultraviolet light emitted by flames. When combined with an Arduino, it can help create an automated fire detection system. In this guide, we'll cover everything you need to know about using a flame sensor with Arduino, from wiring and coding to troubleshooting and advanced applications.

Important: this is a student project and a learning demo. It is not a certified fire alarm — never rely on a DIY Arduino sensor for life safety. A real fire alarm system must be a certified, professionally installed device.

Understanding Flame Sensors

Types of Flame Sensors

  1. Infrared (IR) Flame Sensors – Detect infrared radiation emitted by flames.
  2. Ultraviolet (UV) Flame Sensors – Detect UV rays produced by combustion.
  3. Combined UV-IR Sensors – Offer enhanced fire detection by sensing both UV and IR light.

How a Flame Sensor Works

A flame sensor detects specific wavelengths of light emitted by a fire. The sensor module converts this light into an electrical signal, which is then interpreted by a microcontroller such as an Arduino.

The module used in this guide has four pins: VCC, GND, DO (digital output) and AO (analog output). A phototransistor at the front senses the infrared light from the flame; an LM393 comparator chip on the board compares the signal against a threshold set by the onboard sensitivity potentiometer. When flame is detected, the digital output DO goes LOW — that is the signal your Arduino reads. The analog output AO gives a value (0–1023) that falls as the flame gets closer, so you can also measure how near the fire is.

How a flame sensor works — photo transistor, LM393 comparator and sensitivity pot

Flame Sensor Specifications

  • Operating Voltage: 3.3V to 5V
  • Detection Range: 760nm – 1100nm (for IR sensors)
  • Response Time: Fast response, typically within milliseconds
  • Detection Angle: 60–120 degrees depending on the sensor type

Choosing the Right Flame Sensor for Arduino

  • If you need quick response time, use a UV-based flame sensor.
  • For standard applications, IR flame sensors are cost-effective.
  • Ensure the sensor's voltage is compatible with Arduino (typically 5V).

Components Required for Arduino Flame Sensor Project

ComponentPurposePrice / link
Arduino UnoMain controllerArduino UNO R3 DIP — Rs 1,200
IR Flame Sensor ModuleDetects the flameRs 140
Jumper wiresConnectionsRs 180
5mm LEDOutput indication (optional — the UNO's built-in LED on D13 works too)Rs 6
Active buzzerAlarm sound (optional)Rs 35

Circuit Diagram and Wiring Setup

Wiring table

Flame sensor / partArduino
VCC5V
GNDGND
DO (digital output)D7
Buzzer +D8
Buzzer −GND
LEDD13 (the UNO's built-in LED — no extra wiring needed)

how to use flame sensor with arduino with pins

Arduino Code

The digital output of the flame sensor is active-low: DO is HIGH when there is no flame, and goes LOW when flame is detected. That is the one thing students get wrong most often — if your code checks for HIGH, the alarm will sound when there is no fire and stay silent when there is one.

int flamePin = 7;   // Flame sensor DO
int buzzerPin = 8;  // Buzzer +
int ledPin = 13;    // UNO built-in LED

void setup() {
  pinMode(flamePin, INPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int flameState = digitalRead(flamePin);

  if (flameState == LOW) {        // LOW = flame detected (active-low output)
    digitalWrite(ledPin, HIGH);
    tone(buzzerPin, 1000);        // 1 kHz alarm tone
    Serial.println("Fire detected!");
  } else {
    digitalWrite(ledPin, LOW);
    noTone(buzzerPin);
  }

  delay(1000);
}

Testing the Flame Sensor with Arduino

  • Light a small flame (e.g., candle) near the sensor and observe the LED/buzzer.
  • Adjust the sensitivity using the onboard potentiometer if needed.
  • Try moving the flame closer and further away: the digital output only tells you flame / no flame, but the analog output AO (read with analogRead()) falls as the flame gets closer — that is how you measure distance to the fire.

Applications of Flame Sensors

  1. Home Fire Alarm Systems
  2. Industrial Fire Detection
  3. Robotic Fire Extinguishers

For a bigger safety project, see our IoT geyser safety system — it uses the same idea (a sensor, a cut-off, and an alert) on a real appliance. And if you want the alarm to switch a siren or a pump, our relay module guide shows how a relay safely switches a bigger load.

Troubleshooting Common Issues

  • Check the wiring and power supply if the sensor isn't detecting fire.
  • If false alarms occur, adjust the sensor's sensitivity.
  • If the alarm sounds with no flame at all, check your code: the sensor output is active-low, so the alarm condition must be flameState == LOW, not HIGH.
  • If the sensor only works at very close range, turn the sensitivity potentiometer slowly until it triggers at the distance you need — and remember that bright sunlight and welding light can also trigger an IR flame sensor.

Where to Buy the Parts

The Arduino UNO R3 DIP (Rs 1,200), IR flame sensor module (Rs 140), jumper wires (Rs 180), 5mm LED (Rs 6) and active buzzer (Rs 35) are available at QKZEE Technologies, Shop 20, 1st Floor, Al-Khalil Center, Hall Road, Lahore, and online at qkzeetech.com with delivery all over Pakistan — see the links above.

Still Stuck?

If the sensor does not detect the flame, or the alarm sounds with no flame, message us — tell us whether the DO pin reads HIGH or LOW with no flame, what distance you are testing at, and whether the sensitivity potentiometer has been adjusted, and we will help you find the fault.

WhatsApp UsYouTube

FAQs

Why does the alarm sound when there is no fire?

Because the sensor output is active-low: DO is HIGH with no flame and LOW with flame. If your code treats HIGH as 'fire detected', the alarm sounds all the time. The condition must be flameState == LOW.

Why does the sensor not detect the flame?

Check the wiring (VCC to 5V, GND to GND, DO to D7), then turn the sensitivity potentiometer slowly while holding a candle in front of the sensor. Also check the detection angle — the sensor only sees about 60–120 degrees in front of it.

Can I use the analog output (AO) instead of DO?

Yes — read it with analogRead() on an analog pin. The value falls as the flame gets closer, so you can set your own threshold in code instead of using the potentiometer. That gives you a distance reading, not just flame / no flame.

Does sunlight trigger the flame sensor?

Yes, it can — the sensor detects infrared light, and sunlight and welding light contain plenty of it. Test indoors, and for a real installation use a sensor with a narrow detection band or combine it with a second sensor type.

Can this replace a real fire alarm?

No. This is a student learning project. A real fire alarm must be a certified, professionally installed device — never rely on a DIY Arduino sensor for life safety.

What is the detection range of the flame sensor?

For the IR module used here, about 760nm–1100nm wavelength, with a detection angle of 60–120 degrees. The practical range depends on the flame size and the sensitivity setting — typically under a metre for a candle flame.

Conclusion

Using a flame sensor with Arduino is an effective way to detect fire and enhance safety. With proper wiring, calibration, and coding, you can build a reliable fire detection system for various applications. Remember the two things that matter most: the sensor output is active-low (LOW means fire), and this is a learning project — not a substitute for a certified fire alarm.