Fires can cause irreversible damage if not detected in time. While smoke detectors and heat sensors are commonly used, they often fall short—smoke sensors may miss fires with minimal smoke, and temperature sensors usually trigger only after a significant rise in heat, leaving little room to act.
A more effective and immediate method involves detecting infrared radiation—a type of energy naturally emitted by flames. That’s where the Flame Sensor Module comes into play. Compact, inexpensive, and efficient, it allows us to detect the presence of a flame almost instantly.
In this tutorial, we’ll walk through how to connect a flame sensor module with an Arduino to create a simple fire detection setup. By the end, you’ll be able to sense fire and trigger an alert in real-time.
Understanding How a Flame Sensor WorksThe flame sensor module operates by sensing infrared (IR) light that is typically emitted by flames. At the heart of the module is a photodiode that detects IR radiation. When a flame is present, the intensity of IR increases, which the sensor picks up.
This IR signal is then passed through an LM393 comparator IC, which compares it against a preset threshold. If the intensity crosses that limit, the module outputs a digital LOW signal, indicating the detection of fire.
Additionally, the module offers an analog output that gives a variable voltage depending on how intense the IR radiation is—essentially telling us how strong the flame is.
The onboard potentiometer lets you adjust the sensor’s sensitivity, and two LEDs indicate status:
- Power LED (usually red) shows that the module is powered.
- Signal LED (typically green or blue) switches OFF when flame is detected.
- Operating Voltage: 3.3V–5V (Arduino-friendly)
- Detection Angle: ~60° cone angle for precise targeting
- Sensing Range: Effective up to 1–2 meters
- Sensitivity Adjustment: Onboard potentiometer
- Form Factor: Small, lightweight module for easy prototypin
The flame sensor module comprises:
- Photodiode: Detects infrared light from fire.
- LM393 Comparator: Converts analog IR signals into clear digital output based on threshold.
- Potentiometer: Allows you to fine-tune the threshold sensitivity.
- Power LED: Lights up when power is supplied.
- Signal LED: Turns off when IR detection crosses the threshold, indicating fir
The module usually has four pins:
VCC
: Connects to the 5V supply from Arduino.GND
: Ground connection.AO
: Analog Output – represents intensity of the flame.DO
: Digital Output – switches state (HIGH to LOW) based on IR threshold.
Before deploying the flame sensor in any serious project, calibration is crucial—especially if you're using the digital output. Calibration helps adjust the sensitivity using the onboard potentiometer to ensure it detects flame accurately in your intended environment.
For this task, we’ll use 1 Flame Sensor Module, Arduino UNO, I2C-based 16x2 LCD display, Breadboard & jumper wires, a flame source (like a lighter).
Here’s how to wire the components:
Flame Sensor → Arduino UNO:
VCC → 5V
GND → GND
AO → A0
DO → Digital Pin 10
I2C LCD → Arduino UNO:
VCC → 5V
GND → GND
SDA → A4
SCL → A5
🔸 Important Note: Since A4 and A5 are used for I2C communication, avoid using them as standard analog pins in this setup. Also, ensure that the I2C LCD’s address jumpers (A0, A1, A2) are not shorted, so the display address remains 0x27.
If all are shorted, the address becomes 0x20.
Once this setup is done, upload the calib3ration code and observe the analog readings and digital output status on the LCD display. Adjust the potentiometer until you get the desired response threshold for your environment.
Arduino Code/*
Interfacing flame Sensor with Arduino UNO using Analog input pin of Arduino and displaying the Analog counts on the I2C LCD.
Code by www.playwithcircuit.com
*/
#include <LiquidCrystal_I2C.h> // Library to Run I2C LCD
// define the size of filter array
#define FILTER_SIZE 30
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Define the analog input pin, for the flame sensor's analog output
const int FlameSensorAnalogPin = A0;
// Define the digital input pin, for the flame sensor's digital output
const int FlameSensorDigitalPin = 10;
// Variable to store the Analog count from flame sensor
int FlameCounts;
// Variable to store the filtered Analog count from flame sensor
int filteredFlameCounts;
// Analog value filter
int Filter(int sensorValue);
void setup() {
// initialize the LCD
lcd.init();
// Turn ON the Backlight
lcd.backlight();
// Clear the display buffer
lcd.clear();
// Make digital pin of sensor as input
pinMode(FlameSensorDigitalPin, INPUT);
// Print a message to the LCD
lcd.setCursor(0, 0);
lcd.print("Initializing");
// Print a message to the LCD
lcd.setCursor(0, 1);
lcd.print("Please Wait...");
// flush out the first 100 values and give time to flame sensor counts to be stable
for (int i = 0; i < 100; i++) {
// Read the value from the flame sensor
FlameCounts = analogRead(FlameSensorAnalogPin);
// Filter the input counts
filteredFlameCounts = Filter(FlameCounts);
delay(10);
}
// Clear the display buffer
lcd.clear();
// Print a message to the LCD
lcd.setCursor(0, 0);
lcd.print("Ana. Cnts: ");
// Print a message to the LCD
lcd.setCursor(0, 1);
lcd.print("Dig. Oupt: ");
}
void loop() {
// Static variables to save the last flame sensor counts
static int LastFlameCounts = 0xFFFF;
// Read the value from the flame sensor
FlameCounts = analogRead(FlameSensorAnalogPin);
// Filter the input counts
filteredFlameCounts = Filter(FlameCounts);
// If current flame sensor counts is not equal to last saved counts
if (LastFlameCounts != filteredFlameCounts) {
// Print a message to the LCD
lcd.setCursor(0, 0);
lcd.print("Ana. Cnts: ");
lcd.print(filteredFlameCounts);
lcd.print(" ");
// Print a message to the LCD
lcd.setCursor(0, 1);
lcd.print("Dig. Oupt: ");
lcd.print(digitalRead(FlameSensorDigitalPin));
}
LastFlameCounts = filteredFlameCounts;
// Wait for 10ms before the next loop
delay(10);
}
// Averaging filter to filter Analog values
int Filter(int sensorValue) {
static int analogArray[FILTER_SIZE] = { 0 };
unsigned long int filteredValue = 0;
int i;
// Shift the element, removing the oldest value stored at index 0
for (i = 0; i < (FILTER_SIZE - 1); i++) {
analogArray[i] = analogArray[i + 1];
}
// Put the current value in the last element of Array i.e. at index FILTER_SIZE-1
analogArray[FILTER_SIZE - 1] = sensorValue;
for (i = 0; i < FILTER_SIZE; i++) {
filteredValue += analogArray[i];
}
// Return Filtered Analog Value
return (filteredValue / FILTER_SIZE);
}
Fire Detection System using Flame Sensor and Arduino/*
Interfacing Flame Sensor with Arduino UNO using Analog input pin of Arduino and displaying fire detected on I2C LCD.
code by www.playwithcircuit.com
*/
#include <LiquidCrystal_I2C.h> // Library to Run I2C LCD
// Buzzer pin
#define BUZZER_PIN 11
// Maximum counts to detect the flame
#define FLAME_DETECT_COUNTS 300
// define the size of filter array
#define FILTER_SIZE 30
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Define the analog input pin, for the flame sensor's analog output
const int FlameSensorAnalogPin = A0;
// Variable to store the Analog count from flame sensor
int FlameCounts;
// Variable to store the Filtered Analog count from flame sensor
int filteredFlameCounts;
// Analog value filter
int Filter(int sensorValue);
void setup() {
// initialize the LCD
lcd.init();
// Turn ON the Backlight
lcd.backlight();
// Clear the display buffer
lcd.clear();
// Make buzzer pin as output
pinMode(BUZZER_PIN, OUTPUT);
// Turn OFF buzzer pin
digitalWrite(BUZZER_PIN, LOW);
// Print a message to the LCD
lcd.setCursor(0, 0);
lcd.print("Initializing");
// Print a message to the LCD
lcd.setCursor(0, 1);
lcd.print("Please Wait...");
// flush out the first 100 values AND give time to flame sensor counts to be stable
for (int i = 0; i < 100; i++) {
// Read the value from the flame sensor
FlameCounts = analogRead(FlameSensorAnalogPin);
// Filter the input counts
filteredFlameCounts = Filter(FlameCounts);
delay(10);
}
// Clear the display buffer
lcd.clear();
// Print a message to the LCD
lcd.setCursor(0, 0);
lcd.print("Fire Detected: ");
// Print a message to the LCD
lcd.setCursor(0, 1);
lcd.print(" ");
}
void loop() {
// Read the value from the flame sensor
FlameCounts = analogRead(FlameSensorAnalogPin);
// Filter the input counts
filteredFlameCounts = Filter(FlameCounts);
// if the counts are less than flame_detect_counts, the buzzer is activated
// for this sensor when the flame is detected, the Analog counts decreases
if (filteredFlameCounts < FLAME_DETECT_COUNTS) {
lcd.setCursor(0, 1);
lcd.print("YES");
digitalWrite(BUZZER_PIN, !digitalRead(BUZZER_PIN));
delay(100);
} else {
lcd.setCursor(0, 1);
lcd.print("NO ");
// Turn OFF buzzer pin
digitalWrite(BUZZER_PIN, LOW);
// Wait for 10ms before the next loop
delay(10);
}
}
// Averaging filter to filter Analog values
int Filter(int sensorValue) {
static int analogArray[FILTER_SIZE] = { 0 };
unsigned long int filteredValue = 0;
int i;
// Shift the element removing the oldest value stored at index 0
for (i = 0; i < (FILTER_SIZE - 1); i++) {
analogArray[i] = analogArray[i + 1];
}
// Put the current value in the last element of Array i.e. at index FILTER_SIZE-1
analogArray[FILTER_SIZE - 1] = sensorValue;
for (i = 0; i < FILTER_SIZE; i++) {
filteredValue += analogArray[i];
}
// Return Filtered Analog value
return (filteredValue / FILTER_SIZE);
}
OutputTo learn more checkout: Fire Detection System using Flame Sensor and Arduino
Comments