The KY-026 flame sensor module detects flames using an infrared receiver that will pick up light emissions from heat sources.
This tutorial is applicable to all Arduino compatible boards.
Material
- Computer
- Arduino UNO
- USB cable A Male/B Male
- Flame sensor KY-026
Principle of operation
Any heat source (above 0Kelvin) emits infrared light. The KY-026 flame detection module for Arduino measures the intensity of the infrared light emitted by the fire over a wavelength range of 760 to 1100 nm. The module has digital and analog outputs and a potentiometer to adjust the sensitivity. Commonly used in fire detection systems.
Scheme
We will connect the analog output to pin A0 of the Arduino and the digital output to pin 2. The sensor can be powered by the 5V output of the Arduino.
Code
In the flame sensor management code, we will read the digital output of the sensor and turn on the on-board LED if its state is HIGH. We will also read the analog value and display it on the serial monitor.
const int ledPin = 13; const int digitalPin = 2; const int analogPin = A0; int digitalVal; int analogVal; void setup(){ Serial.begin(9600); pinMode(ledPin, OUTPUT); pinMode(digitalPin, INPUT); Serial.println(F("Flame Sensor Initialized")); } void loop(){ readFlameSensor(); delay(500); } void readFlameSensor(){ // Read the digital interface digitalVal = digitalRead(digitalPin); if (digitalVal == HIGH){ digitalWrite(ledPin, HIGH); Serial.println(F(" -> Flame detected")); }else{ digitalWrite(ledPin, LOW); } // Read the analog interface analogVal = analogRead(analogPin); Serial.print(F("Sensor Value"));Serial.println(analogVal); }
Results
If you hold a lighter flame up to the sensor, you should see the sensor status and measurement change on the serial monitor.
Applications
- Associate this sensor with a siren to create a fire alarm
Sources
Retrouvez nos tutoriels et d’autres exemples dans notre générateur automatique de code
La Programmerie