
What is a Flame Sensor?
A flame sensor is a device used to detect the presence of a flame or fire. It works by sensing infrared light produced by a flame, typically in the wavelength range of 760 nm to 1100 nm. Flame sensors are useful in fire detection systems, flame-based monitoring systems, and safety systems where detecting fire early is critical.
The sensor module typically has four pins: VCC, GND, A0 (analog output), and D0 (digital output). The sensor can provide both analog and digital signals, allowing it to detect flame intensity (analog) or just the presence of a flame (digital).
Interfacing a Flame Sensor with Arduino
Components:
- Arduino (any model, like Uno)
- Flame Sensor Module
- Jumper wires
- Breadboard (optional)
Wiring the Flame Sensor to Arduino:
1. VCC → 5V pin on Arduino
2. GND → GND pin on Arduino
3. D0 (Digital Output) → Digital Pin (e.g., D2) on Arduino
4. A0 (Analog Output, optional) → Analog Pin (e.g., A0) on Arduino
Code Example (using Digital Output):
int flamePin = 2; // Pin connected to the D0 of flame sensor
int flameState = 0; // Variable to store the sensor reading
void setup() {
pinMode(flamePin, INPUT); // Set the flame sensor pin as input
Serial.begin(9600); // Initialize serial communication
}
void loop() {
flameState = digitalRead(flamePin); // Read the flame sensor's digital output
if (flameState == LOW) { // LOW indicates flame detected (sensor outputs LOW when flame is present)
Serial.println("Flame Detected!");
} else {
Serial.println("No Flame");
}
delay(100); // Small delay for stability
}
How the Code Works:
pinMode(flamePin, INPUT): Sets the flame sensor pin as an input.
digitalRead(flamePin): Reads the value from the flame sensor (HIGH/LOW). The sensor typically outputs LOW when a flame is detected and HIGH when no flame is detected.
Testing:
1. Upload the code to the Arduino using the Arduino IDE.
2. Open the Serial Monitor to observe the "Flame Detected" or "No Flame" messages as you expose the sensor to a flame (e.g., a lighter).
You can also use the A0 (analog output) pin to measure the flame's intensity, which gives more nuanced results for flame proximity or size.
Comments