The flame sensor sees the infrared light that flames give off. When it detects one, the buzzer sounds a warning and the Serial Monitor shows how strong the signal is. You'll learn how analog and digital sensor outputs work together.
What you need
- UNO R3 board and USB cable
- Flame sensor module (45-in-1 Sensor Kit)
- Active buzzer module (45-in-1 Sensor Kit)
- Breadboard and jumper wires (not included in the Sensor Kit: use the ones from the UNO R3 Starter Kit or any others)
- A TV remote control for safe testing
Safety first
This is a learning project, not a fire or smoke alarm. Never rely on it to protect people or property. Test it with a TV remote control (see below), which is completely safe. If you test it with a real flame, only an adult should hold a lighter or candle, at least 30 cm from the sensor and away from anything that can burn.
Wiring

| From | To |
|---|---|
| Flame module AO (analog out) | UNO A0 |
| Flame module G | GND (breadboard − rail) |
| Flame module + | 5V (breadboard + rail) |
| Flame module DO (digital out) | UNO pin 2 |
| Buzzer module S | UNO pin 8 |
| Buzzer module + and − | 5V and GND |
Pin labels differ between module versions. Always follow the labels printed on your module.
Build it step by step
- Wire the flame module and the buzzer module as in the diagram.
- Upload the code and open the Serial Monitor at 9600 baud.
- Point a TV remote at the sensor from about 10 cm and hold down a button. The infrared light from the remote looks like a flame to the sensor.
- Turn the small blue knob on the module until the module's second LED switches on with the remote, but not without it.
- If the alarm does the opposite of what you expect, change
DETECTEDin the code toHIGH.
The code
const int FLAME_ANALOG = A0;
const int FLAME_DIGITAL = 2;
const int BUZZER_PIN = 8;
const int DETECTED = LOW; // most modules pull DO LOW when they see a flame
void setup() {
Serial.begin(9600);
pinMode(FLAME_DIGITAL, INPUT);
pinMode(BUZZER_PIN, OUTPUT);
}
void loop() {
int strength = analogRead(FLAME_ANALOG); // changes with the amount of infrared light
bool flame = digitalRead(FLAME_DIGITAL) == DETECTED;
Serial.print("Analog: ");
Serial.print(strength);
Serial.println(flame ? " FLAME DETECTED" : "");
if (flame) {
// fast warning beeps
digitalWrite(BUZZER_PIN, HIGH);
delay(80);
digitalWrite(BUZZER_PIN, LOW);
delay(80);
} else {
digitalWrite(BUZZER_PIN, LOW);
delay(200);
}
}
How it works
Flames give off a lot of infrared light, which our eyes can't see. The dark sensor on the module is an infrared detector. AO gives a voltage that changes with the amount of infrared light. The module also compares that voltage with the knob setting and switches DO when it crosses the threshold, so the UNO can use DO as a simple yes/no signal and AO to show the strength. A TV remote works for testing because it also sends infrared light.
Make it your own
- Use the analog value to beep faster as the signal gets stronger.
- Add the RGB LED module and show red when a flame is detected.
- Compare different TV remotes and see which one the sensor detects from furthest away.
Troubleshooting
- The alarm is always on: sunlight and bright lamps contain infrared light too. Turn the knob, or shade the sensor.
- Nothing happens with the remote: hold the button down, point the remote straight at the sensor and turn the knob.
-
It's silent when it should beep: change
DETECTEDtoHIGH.
Learn the basics first
New to these parts? These lessons explain them step by step: Build an automatic night light (analog sensors) and Make a tilt alarm with a buzzer.
0 comments