Flame alarm

Detect the infrared light of a flame and sound a warning, and learn how flame sensors work.
  • Level:Beginner
  • Duration: 40 min
  • Ages 12+
  • Platform: Arduino
Community project EEMENTOR team

Components used

Flame alarm – EEMENTOR STEM project

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

Breadboard wiring diagram: Flame alarm
Breadboard view. Check each connection against the wiring table below.
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

  1. Wire the flame module and the buzzer module as in the diagram.
  2. Upload the code and open the Serial Monitor at 9600 baud.
  3. 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.
  4. Turn the small blue knob on the module until the module's second LED switches on with the remote, but not without it.
  5. If the alarm does the opposite of what you expect, change DETECTED in the code to HIGH.

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 DETECTED to HIGH.

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

Leave a comment

Please note, comments need to be approved before they are published.

Build it yourself

Get the parts used in this project, tested by our engineers.

45-in-1 Sensor Kit | Compatible with Arduino IDE and ESP32 $29.00

Shop the parts

More projects

  • Pulse visualiser

    • Level:Intermediate
    • Duration: 45 min
    • Platform: Arduino

    by EEMENTOR team

  • Flame alarm

    • Level:Beginner
    • Duration: 40 min
    • Platform: Arduino

    by EEMENTOR team

Community projects

Built something awesome? Share it.

Send us your project and we'll feature it in the hub, credited to you, so other makers can learn from it.

  1. Sign in and tell us about your build
  2. Our team reviews your submission
  3. We publish it in the hub, credited to you