ELECTRO MOTIF
Published

Smart Flame Detection & Alarm System

A compact and low-cost flame detection system using Arduino Nano that detects fire using an analog flame sensor and triggers a buzzer alarm

BeginnerWork in progress1 hour49
Smart Flame Detection & Alarm System

Things used in this project

Hardware components

Gravity: Analog Flame Sensor For Arduino
DFRobot Gravity: Analog Flame Sensor For Arduino
×1
LED (generic)
LED (generic)
×2
Buzzer
Buzzer
×1
Arduino Nano R3
Arduino Nano R3
×1
Jumper wires (generic)
Jumper wires (generic)
×1
USB Cable Assembly, USB Type A Plug to Micro USB Type B Plug
USB Cable Assembly, USB Type A Plug to Micro USB Type B Plug
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

flame_code.ino

C/C++
Code for flame detection using Arduino Nano with buzzer alert and LED indication based on analog threshold.
// ===================== CONFIGURATION =====================
const int FLAME_SENSOR_PIN = A0;
const int BUZZER_PIN       = 4;

const int RED_LED_PIN      = 9;
const int GREEN_LED_PIN    = 12;

// Optional (only if actually used in hardware)
const int RED_LOW_PIN      = 8;
const int GREEN_LOW_PIN    = 11;

const int THRESHOLD        = 300;   // Adjust based on calibration
const int BUZZER_FREQ      = 2000;  // Hz

// ===================== SETUP =====================
void setup() {
  Serial.begin(9600);

  pinMode(RED_LED_PIN, OUTPUT);
  pinMode(GREEN_LED_PIN, OUTPUT);
  pinMode(BUZZER_PIN, OUTPUT);

  pinMode(RED_LOW_PIN, OUTPUT);
  pinMode(GREEN_LOW_PIN, OUTPUT);

  // Ensure LOW-side pins are grounded (if used)
  digitalWrite(RED_LOW_PIN, LOW);
  digitalWrite(GREEN_LOW_PIN, LOW);

  // Initial safe state
  digitalWrite(RED_LED_PIN, LOW);
  digitalWrite(GREEN_LED_PIN, HIGH);
}

// ===================== LOOP =====================
void loop() {
  int sensorValue = readFlameSensor();

  Serial.print("Flame Sensor Value: ");
  Serial.println(sensorValue);

  if (isFlameDetected(sensorValue)) {
    activateAlarm();
  } else {
    deactivateAlarm();
  }

  delay(200);
}

// ===================== FUNCTIONS =====================

// Read analog value from flame sensor
int readFlameSensor() {
  return analogRead(FLAME_SENSOR_PIN);
}

// Check if flame is detected
bool isFlameDetected(int value) {
  return (value < THRESHOLD);
}

// Activate alarm system
void activateAlarm() {
  tone(BUZZER_PIN, BUZZER_FREQ);
  digitalWrite(RED_LED_PIN, HIGH);
  digitalWrite(GREEN_LED_PIN, LOW);
}

// Deactivate alarm system
void deactivateAlarm() {
  noTone(BUZZER_PIN);
  digitalWrite(RED_LED_PIN, LOW);
  digitalWrite(GREEN_LED_PIN, HIGH);
}

Credits

ELECTRO MOTIF
5 projects • 0 followers
Electronics enthusiast focused on PCB design, power electronics, and embedded hardware. I design circuits and share hardware projects.

Comments