How to interface KY-026 flame sensor with Arduino

What is a flame sensor, how do flame detectors work & how to connect the flame sensor with Arduino are some questions that may arise when working with flame sensors and Arduino.

Hello guy! Welcome back to my blog today we are going to see about KY 026 flame sensor and Arduino so let’s begin.

What is a flame sensor??

Detection of fire can be done using three-parameter smoke, flame, and heat. Detection using flame means using light to detect the presence of fire. As the name itself says it detects flame. It uses infrared radiation to detect flames. The flame detector detects the infrared spectral band for specific patterns that are released by hot gases. More than 90% of the flame’s total radiation is infrared. Detection of fire using a flame sensor is much faster than smoke and heat detector this sensor When there is a fire, then the flame sensors detect infrared radiation using an IR LED within the range of 760nm – 1100nm from the fire which outputs data is fed to Arduino.  The response of flame sensors is faster as well as more accurate compared with heat, smoke, and temperature sensors. The output of the sensor is both analog and digital. This sensor gives output in form of analog output (A0) and digital output (D0).when the digital pin (D0) is connected to the Arduino pin it gives output in form of HIGH and LOW. When it detects the flame it gives the value HIGH & when there is no flame it gives output LOW. For analog output, it gives output in the range of analog voltage from 0 to 1023.

Arduino fire detector

How flame sensor works??

A flame sensor uses infrared light to detect the presence of fire. It consists of an Infrared LED to sense the infrared radiation from the fire. We have a ky-026 flame sensor module to detect the presence of fire. The infrared LED on the module sense infrared light and feds the signal to the comparator which compares the detected value and predefined value set by the potentiometer and gives both analogs as well as a digital output. If the detected value is more than the threshold value then the digital output will be Low and if the detected value is more than the threshold value then the digital output will be high. 

ir flame sensor Arduino

When the flame sensor detects a fire or flame the resistance of the IR LED decreases, so the voltage of the IR LED is HIGH and fed to the LM393 comparator. One of the inputs to the comparator is from a pre-defined value from the potentiometer and the second input is from IR LED value. The comparator compares these two values to produce an output signal. Comparator output switches the digital output and LED. We have a variable resistor to set reference comparator input. We change the reference values using a variable resistor. If we rotate the knob in a clockwise direction then sensitivity increases and then rotate the knob in anti-clockwise direction sensitivity then sensitivity decreases.

Note - The signal may be inverted, which means when a high value is measured it will be showing low voltage at the digital output.

Application of fire/flame sensors

  • Firefighting robot
  • Fire detection
  • Industrial application in the boiler furnace
  • Fire alarms  
  • Gas stations
  • Mines & research labs.
  • Ignition systems.
  • A chemical production plant unit
  • Petrol pumps & warehouses

 Advantages of flame sensors

  • Fast response
  • Low cost and easy to use
  • Better than smoke & heat detectors
  • Accuracy can be adjustable
  • Both analog and digital output

Specifications of flame sensor

  • Operating Voltage - 3.3V ~ 5.5V
  • Wavelength Detection - 760nm ~ 1100nm
  •  Detection Angle - 60°
  • Board Dimensions - 1.5cm x 3.6cm
  • Two output modes – analog & digital
  • LED lights indicators:  Red Power, Green Trigger
  • Maximum Current: 15mA

Circuit Diagram

flame sensor interfacing with Arduino

Connect the ground pin of the ky-026 sensor to the ground pin of Arduino, the VCC pin to 5v, the Analog pin to A0, and the Signal pin to 9. Also, connect the positive lead of LED to Arduino pin 11.

Code -

int flame_pin_dig=8;    // for digital pin
int flame_pin_An= A0;  // for analog pin
int flame_sensor_An;
int flame_sensor_dig;  
int led_pin=11;        // led pin define
void setup() 
{
 pinMode(flame_pin_An,INPUT);
 pinMode(flame_sensor_dig,INPUT);
 pinMode(led_pin,OUTPUT);
 Serial.begin(115200);
}

void loop() 
{
flame_sensor_dig=digitalRead(flame_pin_dig);  // for digital values
Serial.println(flame_sensor_dig);  
 flame_sensor_An = analogRead(flame_pin_An);   // for analog values
 Serial.println(flame_sensor_An); 

if(flame_sensor_dig==HIGH && flame_sensor_An < 35)
{
  digitalWrite(led_pin,HIGH);
  Serial.println("Flame detected");  
}
else
{
  digitalWrite(led_pin,LOW); 
  Serial.println("Flame NOT detected");  
}  

 delay(1000);
 }

First, initialize pins of flame sensor & LED. We have declared a variable to read both analog and digital values from the flame sensor. In the void setup, we configure pins as INPUT or OUTPUT. We want to read values from the sensor pin so we will declare it as INPUT and LED as OUTPUT. We also configure the baud rate to 115200.

In a void loop, we continuously read values from the flame sensor and store values in variables. if we place fire or flame close to the flame sensor then the output we get is HIGH. here we used LED which gets turned ON when output is HIGH & turns OFF when output is LOW (No flame present). 

OUTPUT -

flame sensor Arduino

Now we used the serial monitor to observe the output. To open up the serial monitor, click on Tools > Serial Monitor or use the shortcut (SHIFT + CONTROL + M). Here you can see in the Serial monitor when there is no flame or fire near the flame sensor then the digital output will be 0 and the analog output will be 1023. But when we place a fire or flame near the flame sensor then the digital output will be 1 and the analog output will be 23. We can adjust the sensitivity by rotating the potentiometer in the clockwise or anti-clockwise direction.

Conclusion –

As the output response of this sensor is fast we can use this sensor to avoid the risk of getting major damage in sensitive zones or at home or in industrial areas. These sensors are low cost easy to use which makes them more reliable and convenient but a problem that may arise while working with these sensors is that the output of the sensor may get affected due to surrounding lights & easily damaged by high temperatures. So it’s better to place the flame sensor at some particular distance also not only fire but also ovens, bulbs, lamps, and welding generates infrared light so there might be a chance of false alarms. The flame sensor also has limitations as not all fires have a flame this sensor can have a drawback while detecting fire. Flog, oil, dust, dirt, or water vapor on sensors led lens may also affect the output. Today we have learned about what flame sensors, the working principle of flame sensors is, and how to use flame sensors with Arduino.

"I hope you find this IoT blog very helpful to you. In the upcoming lesson, we will see more about IoT sensors till then bye. See you all in my next blog."

Close Menu