Arduino Flame Sensor Alarm using KY-026

Hello world! in this little instructable i will show how to use the KY-026 Arduino Flame Sensor as a alarm.
It’s multifunctional, for example you can use it to alarm you that your racing cars brakes are getting Red Hot.
Or use it with a sprinkler attached to it when it senses flames for example flames with no smoke, so a smoke detector cannot be used, it will also detect much quicker then a smoke alarm. It’s Just an example. Anyways it has use for many things, like deactivating a fuel line such as a propane or a natural gas line, and activating a fire suppression system. It could also notify you that a flame is still there for some industrial purposes.. so much more i think.

To turn a device on or off is easy to do in the code.

I just made this code for the Arduino Flame Sensor quickly for this Instructable, you can play with it a bit.

Schematic:
arduino flame sensor

Parts list:
Arduino uno. I used the RobotDyn Uno, a real good chinese copy with 7 analog pins.
Relay Ky-019
Flame Sensor Ky-026
Buzzer
red & green led.
Push button for reset (optional)
Lamp with fitting and power cable to connect to the relay to test the alarm, or just an alarm strobe (optional)
Bunch of MM FF FM Jumper wires.

Code:

//Author Danny van den Brande. arduinosensors.nl, also check out my forum to find more info and example codes for most common sensors @ forum.arduinosensors.nl
//Arduino Flame Sensor alarm, Do whatever you want with this.
// What can you do with this? you can turn on a sprinkler, or any other device, like a Siren with sound by using the relay.
// Or if you change the code to work the other way arround you can switch of something that works with gas, for example.
int Relay = 7 ; // Pin for relay
int Buzzer = 5; //Pin for buzzer
int RedLed = 6 ;// The pin for the RedLed
int GreenLed = 8 ;
int Digitalpin = 3; 
int Analoogpin = A3; // define the flame sensor interface
 
int val ;// define numeric variables val
float sensor; //read analoog value

// here i set up the tones, you can change them @ void loop.
int tones[] = {261, 277, 293, 311, 329, 349, 369, 392, 415, 440, 466, 493, 523 ,554};
//              1    2    3    4    5    6    7    8    9    10   11   12   13   14
// You can add more tones but i added 14. Just fill in what tone you would like to use, @ void loop you see " tone(Buzzer, tones[12]); " below,  digitalWrite(Buzzer, HIGH);
// here you can change the tones by filling in a number between 1 and 14
 
void setup ()
{ 
  Serial.begin(9600);
  pinMode (Relay, OUTPUT) ;
  digitalWrite(Relay, LOW);
  pinMode (Buzzer, OUTPUT) ;
  digitalWrite(Buzzer, LOW);
  pinMode (RedLed, OUTPUT) ;// define RedLed as output interface
  pinMode (GreenLed, OUTPUT) ;
  pinMode (Digitalpin, INPUT) ;//
  pinMode (Analoogpin, INPUT) ;// output interface defines the flame sensor
  //+++++++++++++++++++++++++++++++++++++++++++
  //Part of buzzer tones
  for (int i = 0; i < Buzzer; i++)     {
}
  
}
 
void loop ()
{
  sensor = analogRead(Analoogpin);
  Serial.println(sensor);  
 
  val = digitalRead (Digitalpin) ;// digital interface will be assigned a value of 3 to read val
    if (val == HIGH) // When the flame sensor detects a signal, RedLed flashes
  {
    digitalWrite (RedLed, HIGH);
    digitalWrite(Buzzer, HIGH);
    tone(Buzzer, tones[6]);
    delay (100);
    digitalWrite (RedLed, LOW);
    digitalWrite(Buzzer, LOW);
    noTone(Buzzer);
    delay (100);
    digitalWrite (RedLed, HIGH);
    digitalWrite(Buzzer, HIGH);
    tone(Buzzer, tones[1]);
    delay (100);
    digitalWrite (RedLed, LOW);
    digitalWrite(Buzzer, LOW);
    noTone(Buzzer);
    delay (100);
    digitalWrite(Relay, HIGH);
// Set relay to LOW if you want the alarm to switch off a device, setting the device to HIGH will turn on a device for example a sprinkler
// Then un-Comment //  digitalWrite(Relay, HIGH); at the else statement at the bodem of the code.
    delay (100);
    digitalWrite (RedLed, HIGH);
    digitalWrite (GreenLed, LOW);
    digitalWrite(Buzzer, HIGH);
    tone(Buzzer, tones[3]);
    delay (100);
  }
  else
  {
    digitalWrite (GreenLed, HIGH);
    digitalWrite (RedLed, HIGH);
    delay(10);
    digitalWrite (RedLed, LOW);
    digitalWrite(Buzzer, HIGH);
    noTone(Buzzer);
//  digitalWrite(Relay, HIGH); Uncomment if you want the alarm to switch off a device, when flames are detected.
//  for example something that works with gas.
  }
  delay(1000);
}

Good luck with building the Arduino Flame Sensor alarm!

Danny van den Brande

http://www.arduinosensors.nl

Programmer, Game Designer, 3D Designer, Web Designer, Graphic Designer. Jup this website looks crappy.. :) But enjoy the projects! Everything you need is here.

Leave a Reply

Your email address will not be published. Required fields are marked *