(DKHK100200)Lesson7-Flame detection sensor for arduino

Introduction

Overhere we will show you what is the flame sensor and how it works, you can follow the next lesson to get how to use the flame sensor with the Osoyoo UNO board.

Flame sensor is an electronic device which is capable of sensing/detection of fire or a high temperature zone. It gives an indication through an LED attached at its top, just after sensing the fire. These type of sensors are usually used for short ranges. They are able to detect the fire up to 3 feet. Flame sensors is the most common device available in the market these days due to its good results and cost efficiency.

Flame sensors are available in the market in two types one having three pins and the other having four pins respectively. Both of the sensors can be easily interfaced to any micro-controller. We are using four pin flame sensor in this tutorial. You will see the complete wiring diagram for interfacing flame sensor with Arduino and the complete Arduino source code and its description as well.

Preparations

Hardware

Software

About Flame Sensor

The Flame Sensor can detect flames in the 760 – 1100 nano meter wavelength range. Small flames like a lighter flame can be detected at roughly 0.8m. Detection angle is roughly 60 degrees and the sensor is particularly sensitive to the flame spectrum.The module consists of an IR sensor, potentiometer, OP-Amp circuitry and a led indicator. An on board LM393 op amp is used as a comparator to adjust the sensitivity level. The sensor has a digital and analog output and sensitivity can be adjusted via the blue potentiometer.

Features

It has both outputs, analog and digital. The analog output gives us a real time voltage output signal on thermal resistance while the digital output allows us to set a threshold via a potentiometer. In our tutorial we are going to use both of these outputs one by one and see how the sensor works.We can use the flame sensor to make an alarm when detecting the fire, for safety purpose in many projects and in many more ways.

Working Principle

flame sensor Pin Out

The pin out of the flame is as follows.

A0: This is the analog pin and this will be connected to the analog pin of the Arduino.

G/GND: This is the ground pin and this will be connected to the ground of the Arduino.

+/VCC: This is the input voltage pin of the sensor and this will be connected to the +5V of Arduino.

D0: This is the digital pin and this will be connected to the digital pin of Arduino.

Arduino Application Circuit

Arduino Code for Flame Sensor

Flame Sensor Digital (D0) Output

int Buzzer = 13; // Use buzzer for alert 
int FlamePin = 2;  // This is for input pin
int Flame = HIGH;  // HIGH when FLAME Exposed

void setup() {
  pinMode(Buzzer, OUTPUT);
  pinMode(FlamePin, INPUT); Serial.begin(9600);
  
}

void loop() {
  Flame = digitalRead(FlamePin);
  if (Flame== HIGH)
  { Serial.println("HIGH FLAME");
    digitalWrite(Buzzer, HIGH);
  }
  else
  { Serial.println("No flame");
    digitalWrite(Buzzer, LOW);
  }
}


Flame Sensor Analog (A0) Output

const int analogPin = A0;    // Flame Sensor (A0) to Arduino analog input pin A0
const int BuzzerPin = 13;       // Buzzer output pin
const int threshold = 400;   // Flame level threshold (You can vary the value depends on your need)

void setup() {
  
  pinMode(BuzzerPin, OUTPUT);
  // initialize serial communications: Serial.begin(9600);
}

void loop() {
  // read the value of the Flame Sensor:
  int analogValue = analogRead(analogPin); Serial.println(analogValue); //serial print the FLAME sensor value
  
  if (analogValue > threshold) {
    digitalWrite(BuzzerPin, HIGH); Serial.print("High FLAME");
  } 
  else if (analogValue = threshold){ Serial.print("Low FLAME");
    digitalWrite(BuzzerPin, HIGH);
    delay(400);
    digitalWrite(BuzzerPin, LOW);
  }
  else {
    digitalWrite(BuzzerPin, LOW); Serial.print("No flame");
  }

  delay(1);       
}