Arduino Flame Sensor Fire Alarm Project

Arduino Flame Sensor Fire Alarm Project

Arduino Flame Sensor Fire Alarm Project will involve building a basic fire alarm system using an Arduino that is interfaced with a flame sensor module (to detect the presence of a flame), an active buzzer module (to produce an audible sound) and a 2-colour LED module (for a visual indication). In terms of how this project works, when the flame sensor detects the presence of a nearby flame, it will activate a buzzer that will repetitively beep and flash the LED until a flame is no longer detected. Regarding how a flame sensor works, there are various mechanisms that depend on the type of flame sensor, including ultraviolet (UV), infrared (IR), ultraviolet/infrared (UV/IR), multi-spectrum infrared (MSIR) and visual flame imaging flame sensors. 

The particular flame sensor used in this DIY PCBA board project is the IR type (HW-491), which is also the most common type with Arduino-compatible flame sensors. Essentially, IR sensors work by detecting infrared radiation that is very distinctly emitted from flames and when the built-in photodiode detects that specific range of wavelengths, it will send a digital signal (1) to the Arduino board. Upon the Arduino microcontroller receiving that HIGH signal from the flame sensor, this project is programmed to then activate the active buzzer, which will beep every 150ms, and the 2-colour LED module, which will be flashing a red colour every 150ms to indicate the presence of a flame. In the absence of a flame, there will be no beeping of the buzzer and the LED will be green in colour. One important point to note is that if your flame sensor is incorrectly detecting the presence of a flame, you may need to calibrate its sensitivity by turning the module’s built-in potentiometer.

This project reflects a very practical application of a flame sensor module as part of a fire alarm circuit, which has many home, commercial & industrial PCBA uses. Oftentimes, commercially-made fire alarms may rely on similar technology in terms of having a flame sensor as an input device which is connected to an output device (speaker, LEDs, flame suppression systems, etc) that when triggered, lets consumers know of the presence of a flame. Therefore, integrating a project like this onto a PCB to be placed into a small enclosure as a portable fire alarm that can be mounted onto several surfaces in a residential building is definitely a useful, viable idea. The compactness of this circuit on a breadboard can further be enhanced when designing a custom PCB for this project using surface mount components (SMT) where this circuit can take form as a standalone product. Nowadays, many commercial products are assembled (PCBA) utilizing SMT assembly as they allow for a much smaller form factor and resultantly, greater electrical density on a PCBA board. These are the components needed to build this project:

  • Arduino Nano (other Arduino-compatible boards will work)
  • USB cable (compatible with the Arduino board)
  • Breadboard
  • Male-Male Jumper Wires (8)
  • HW-491 Flame Sensor Module
  • HW-512 Active Buzzer Module
  • HW-480 Red/Green 2-Colour LED Module (common cathode)
  • 220Ω resistors (2)

Flame sensor fire alarm project circuit wiring diagram

Depending on your Arduino board, you may or may not require a breadboard to plug your board in. In this example, an Arduino Nano is used, thus requiring a breadboard but if you are using an Arduino Uno, for example, the jumper wires can be plugged in from the components on the breadboard directly to the board pins. 

The components needed for this specific project are very similar to some other projects as the modules make up most of the project. Regarding the flame sensor module pinout, most models have a 4-pin configuration with a digital output (DO) and an analogue output (AO) pin. For this DIY project, the digital output (DO) pin will only be used as the main purpose of the sensor is to send back a HIGH or LOW signal depending on whether a flame is detected or not. If your sensor has a 3-pin configuration, go ahead and use the standard output/signal pin. In terms of the LED module that is used, the reason that two 220Ω resistors are connected in series with the two outputs from this module is to prevent the LEDs from burning out when applying a supply voltage of +5 volts. If a regular LED is being used in place of the LED module, the resistor is also a requirement to protect the LED from shorting out. A circuit diagram of the wiring is also featured below.

  • HW-491 Flame Sensor Module: Connect the digital output (DO)/signal pin to D3 on the Arduino board, the positive (+) pin to +5v and the GND (G) pin to GND.
  • HW-480 Red/Green 2-Colour LED Module: Insert one 220Ω resistor in the breadboard in series with the output pin for the red colour LED signal (R) and insert another 220Ω resistor in series with the output pin for the green colour LED signal (G). Connect the red colour output pin (R) to D5 and the green colour output pin (G) to D6. Connect the negative (-) pin of the LED module to GND on your Arduino.
  • HW-512 Active Buzzer Module: Connect the positive (+) pin to D4 and the negative (-) pin to GND on your Arduino.

Flame sensor fire alarm circuit code programming

Code Details

int sensorPin = 3;

int buzzerPin = 4;

int redPin = 5;

int greenPin = 6;

 

int flame;

 

void setup()

{

 Serial.begin(9600);

 pinMode(sensorPin, INPUT);

 pinMode(buzzerPin, OUTPUT);

 pinMode(redPin, OUTPUT);

 pinMode(greenPin, OUTPUT);

}

 

 

void loop()

{

 flame = digitalRead(sensorPin);

 if (flame == 1)

 {

   Serial.println(“Flame detected.”);

   digitalWrite(redPin, HIGH);

   digitalWrite(greenPin, LOW);

   digitalWrite(buzzerPin, HIGH);

   delay(150);

   digitalWrite(redPin, LOW);

   digitalWrite(buzzerPin, LOW);

   delay(150);

 }

 else

 {

   Serial.println(“No flame detected.”);

   digitalWrite(redPin, LOW);

   digitalWrite(greenPin, HIGH);

   digitalWrite(buzzerPin, LOW);

 }

 delay(500);

}

Code explanation

  • This code includes many concepts that were featured in previous projects, especially the use of if-else statements, digitalWrite() functions (to define the state of various modules) and serial monitor commands.
  • To start with, the first block of code defines the digital pins that each module is connected to on the Arduino board. Since four digital pins are in use, each of those is given a specific name that will be used later (e.g. sensorPin which represents the pin D3 that the flame sensor is connected to). An additional integer is defined (flame) that is not set to a specific value but will act as the placeholder for whatever signal (0 or 1) is being received from the flame sensor. For example, if the flame sensor detects the presence of a flame, the sensor will send back a 1 or HIGH signal to the Arduino and this information is then stored in the flame variable which can always change (e.g. if the flame is no longer being detected).
  • Moving onto the void setup section, the serial communication baud rate is set to 9600 to set up for serial data, which will later be printed onto the serial monitor on the Arduino IDE for debugging purposes. Next, the flame sensor is set as a digital input device (sends digital signals (1 or 0) to the Arduino in the presence/absence of a flame). The active buzzer module and 2-colour LED module pins are then set as digital output devices (the Arduino board will send digital signals (1 or 0) to these modules).
  • Regarding the void loop section, the flame integer that was defined earlier is now assigned to whatever digital input value is being received from the flame sensor. This is done by using the digitalRead() function that assigns the flame variable to the input signal of sensorPin, which is the flame sensor. 
  • Now, an if-else statement is used that will set the output modules (2-colour LED and buzzer modules) to a specific state whenever the if statement holds true. In this case, if the flame variable is equivalent to 1 (i.e. when the flame sensor detects a flame), the LED will switch to a red colour and the buzzer will turn on (produce an audible noise). In order to make the LED continuously flash red while the buzzer beeps upon the presence of a flame, a 150ms interval is added in between alternating digital states of the LED and buzzer via the delay() function. A short message is also printed out to the serial monitor for debugging purposes (e.g. calibrating the flame sensor).
  • However, since this is an if-else statement, whenever the if statement does not hold true (i.e. when the flame sensor does not detect any flame), the LED will change to a green colour and the buzzer will stop beeping. Again, a quick message is also sent to the serial monitor. At last, there is a short 500ms delay at the end of the loop.

Next steps

Now that FS Technology has completed this project, it can easily integrate into and form the basis of a much larger project such as a home automation system, portable fire alarm, fire suppression unit, etc. A major principle that was covered in the code was the communication between digital input and output devices, using the Arduino as the microcontroller to process/relay the signals. In this case, the flame sensor was what sent the digital signal to the Arduino in the presence/absence of a flame and after processing what to do with that information, the Arduino then sends its own digital signal to the output devices (2-colour LED module and active buzzer module). As mentioned at the start of this project, for a more permanent application, you may want to consider migrating this project to a PCB, which comes with so many benefits in regards to the small form factor, lightweight and portability. Although using through hole PCB assembly can work well, SMT PCBA will definitely reduce the cost and overall size of the finished product.

DIY Electronics Project Blog