Arduino Code and Video: Flame Sensor Module for Arduino
In this tutorial, we'll explore how to use a flame sensor module with an Arduino. The flame sensor detects the presence of a flame and can trigger an alarm or indicator when it does. By the end of this project, you will have a working system that responds to flame detection with an audible alert and visual feedback.


The flame sensor module operates using an infrared LED to detect flames. When a flame is detected, the module outputs a signal that can be used to activate other components, such as a buzzer or an LED. This project will involve wiring the flame sensor to the Arduino and writing a simple program to handle the input and output.
For a clearer understanding of the code and wiring, I encourage you to check the associated video (in video at 00:00).
Hardware Explained
The main components in this project include the flame sensor module, an Arduino board, and a buzzer or LED for alerting. The flame sensor has four pins: a digital output pin (DO), an analog output pin (AO), a power pin (VCC), and a ground pin (GND). The digital output pin sends a HIGH signal when a flame is detected, while the analog output provides varying values based on the intensity of the flame.
The Arduino reads the digital output to determine if there is a flame present. When the sensor detects a flame, the Arduino can then activate an alarm or light using an output pin. The sensitivity of the flame detection can be adjusted using a built-in potentiometer on the module.
Datasheet Details
| Manufacturer | Generic |
|---|---|
| Part number | LM393 |
| Logic/IO voltage | 5 V |
| Supply voltage | 2–36 V |
| Output current (per channel) | 20 mA |
| Peak current (per channel) | 50 mA |
| PWM frequency guidance | N/A |
| Input logic thresholds | 0.8 V (low), 2.0 V (high) |
| Voltage drop / RDS(on) / saturation | 0.2 V |
| Thermal limits | 125 °C |
| Package | TO-220 |
| Notes / variants | Adjustable sensitivity |
- Ensure proper voltage supply between 2 to 36 V for the module.
- Keep the sensor's infrared LED clear for optimal flame detection.
- Use a heatsink if the module operates near its peak current limits.
- Be cautious with wiring to avoid short circuits or incorrect connections.
- Adjust the sensitivity using the onboard potentiometer for different applications.
- Verify that the alarm output can handle the connected load (buzzer/LED).
Wiring Instructions


To wire the flame sensor module to the Arduino, start by connecting the VCC pin of the flame sensor to the 5V pin on the Arduino. Then, connect the GND pin of the sensor to one of the GND pins on the Arduino. The digital output pin (DO) from the flame sensor should be connected to digital pin 2 on the Arduino, which we will refer to as FLAME in the code. Finally, connect an alarm device, such as a buzzer, to digital pin 8 on the Arduino, referred to as ALARM.
Make sure that all connections are secure, as loose connections can lead to inconsistent behavior. If you want to use the analog output, connect the analog output pin (AO) to an analog pin on the Arduino, such as A0, but this is optional for basic functionality. In the video, alternative wiring methods are also discussed (in video at 02:30).
Code Examples & Walkthrough
The following code snippet initializes the flame sensor and sets up the serial monitor:
#define FLAME 2 // connect DO pin of sensor to this pin
#define ALARM 8 // pin 8 for Alarm
void setup() {
Serial.begin(9600);
Serial.println("Robojax.com Fire Module Test");
pinMode(FLAME, INPUT); // define FLAME input pin
pinMode(ALARM, OUTPUT); // define ALARM output pin
}
Here, we define the pins for the flame sensor and alarm, and initialize serial communication at 9600 baud. This allows us to print messages to the serial monitor for debugging.
Next, we read the flame sensor in the main loop:
void loop() {
int fire = digitalRead(FLAME); // read FLAME sensor
if(fire == HIGH) {
digitalWrite(ALARM, HIGH); // set the buzzer ON
Serial.println("Fire! Fire!");
} else {
digitalWrite(ALARM, LOW); // Set the buzzer OFF
Serial.println("Peace");
}
delay(200);
}
This part of the code checks the state of the flame sensor. If it detects a flame (HIGH), it activates the alarm and prints "Fire! Fire!" to the serial monitor. If there is no flame (LOW), it turns off the alarm and prints "Peace". The loop includes a delay of 200 milliseconds, which can be adjusted to change the sensitivity of the detection.
Demonstration / What to Expect
When the system is powered on, the serial monitor will display "Robojax.com Fire Module Test" followed by "Peace" until a flame is detected. Once a flame is detected, the buzzer will sound, and the LED will light up, indicating a fire condition. You can test the sensitivity of the sensor by adjusting the potentiometer on the module. Be cautious of false positives, such as those caused by infrared signals from remote controls (in video at 04:15).
Video Timestamps
- 00:00 - Introduction to the flame sensor module
- 02:30 - Wiring instructions
- 04:15 - Demonstration of flame detection
Resources & references
-
ExternalLM393 datasheet (PDF)ti.com
Files📁
No files available.