Arduino Nano - Flame Sensor

The flame sensor is a nifty device that picks up on infrared emissions from a flame, making it a useful tool for fire detection. Sometimes referred to as an infrared flame sensor or fire sensor, it outputs signals in two flavors: digital (LOW/HIGH) and analog.

In this guide, we'll walk through the process of utilizing an Arduino Nano alongside a flame sensor to detect and gauge the intensity of flames. We'll cover the basics, including:

arduino flame sensor

Afterward, you can modify the code to activate a warning horn (via a relay) when it detects fire.

Hardware Preparation

1×Arduino Nano
1×USB A to Mini-B USB cable
1×Flame Sensor
1×Jumper Wires
1×(Optional) 9V Power Adapter for Arduino Nano
1×(Recommended) Screw Terminal Adapter for Arduino Nano

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you. We appreciate your support.

Overview of Flame Sensor

The infrared flame sensor serves as a handy tool for identifying the presence of a flame or gauging the emitted infrared level from the flame. As a result, it becomes a reliable detector for fires. The flame sensor offers dual options through a digital output pin and an analog output pin.

These sensors are carefully crafted to selectively hone in on specific wavelengths of infrared radiation associated with flames. This design minimizes the chances of false alarms triggered by other sources of infrared radiation like human body heat or artificial lighting. However, it's crucial to note that, like any sensor, they do have their limitations, and in certain conditions, there might be instances of false positives or false negatives.

Pinout

The flame sensor includes four pins:

  • VCC pin: It needs to be connected to VCC (3.3V to 5V).
  • GND pin: It needs to be connected to GND (0V).
  • DO pin: It is a digital output pin. It is HIGH if the flame is not detected and LOW if detected. The threshold value for flame detection can be adjusted using a built-in potentiometer.
  • AO pin: It is an analog output pin. The output value decreases as the infraed level is decreased, and it increases as infraed level is increased.
Flame Sensor Pinout
image source: diyables.io

Furthermore, it has two LED indicators:

  • One PWR-LED indicator for power.
  • One DO-LED indicator for the flame state on the DO pin: it is on when flame is present.

How It Works

Regarding the DO pin:

  • The module includes a built-in dial to adjust the infrared sensitivity.
  • If the infrared strength surpasses the set threshold, indicating a flame detection, the sensor's output pin goes low, turning on the DO-LED.
  • Conversely, if the infrared intensity falls below the threshold, signaling no flame detection, the output pin goes high, turning off the DO-LED.

For the AO pin:

  • The AO pin registers higher values with increased infrared intensity in the surrounding area.
  • Conversely, lower infrared intensity in the surroundings results in lower values being read from the AO pin.

It's important to note that the dial setting doesn't impact the readings on the AO pin.

Wiring Diagram

Since the flame sensor module has two outputs, you can choose to use one or both of them, depending on what you need.

  • The wiring diagram between Arduino Nano and the flame sensor when using DO only.
The wiring diagram between Arduino Nano and Flame Sensor

This image is created using Fritzing. Click to enlarge image

  • The wiring diagram between Arduino Nano and the flame sensor when using AO only.
The wiring diagram between Arduino Nano and fire sensor

This image is created using Fritzing. Click to enlarge image

  • The wiring diagram between Arduino Nano and the flame sensor when using both AO an DO.
The wiring diagram between Arduino Nano and infrared flame sensor

This image is created using Fritzing. Click to enlarge image

Arduino Nano Code - Read value from DO pin

/* * This Arduino Nano code was developed by newbiely.com * * This Arduino Nano code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano/arduino-nano-flame-sensor */ #define DO_PIN 2 // Arduino Nano's pin connected to DO pin of the flame sensor void setup() { // Initialize the Serial to communicate with the Serial Monitor. Serial.begin(9600); // initialize the Arduino Nano pin as an input pinMode(DO_PIN, INPUT); } void loop() { int flame_state = digitalRead(DO_PIN); if (flame_state == HIGH) Serial.println("The flame is NOT detected"); else Serial.println("The flame is detected"); }

Detailed Instructions

  • Copy the above code and open with Arduino IDE
  • Click Upload button on Arduino IDE to upload code to Arduino Nano
  • Direct the flame sensor to a flame.
  • Check out the result on the Serial Monitor.
COM6
Send
The flame is NOT detected The flame is NOT detected The flame is NOT detected The flame is detected The flame is detected The flame is detected The flame is NOT detected The flame is NOT detected The flame is NOT detected
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Please keep in mind that if you notice the LED status remaining on constantly or off even when the sensor faces to a flame, you can adjust the potentiometer to fine-tune the sensitivity of the sensor.

Arduino Nano Code - Read value from AO pin

/* * This Arduino Nano code was developed by newbiely.com * * This Arduino Nano code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano/arduino-nano-flame-sensor */ #define AO_PIN A0 // Arduino Nano's pin connected to AO pin of the flame sensor void setup() { // Initialize the Serial to communicate with the Serial Monitor. Serial.begin(9600); } void loop() { int flameValue = analogRead(AO_PIN); Serial.print("infrared value: "); Serial.println(flameValue); }

Detailed Instructions

  • Copy the above code and open with Arduino IDE
  • Click Upload button on Arduino IDE to upload code to Arduino Nano
  • Direct the flame sensor to a flame.
  • Check out the result on the Serial Monitor.
COM6
Send
infrared value: 145 infrared value: 146 infrared value: 346 infrared value: 473 infrared value: 577 infrared value: 849 infrared value: 956 infrared value: 1001 infrared value: 1006 infrared value: 1017 infrared value: 1028 infrared value: 849 infrared value: 643 infrared value: 441 infrared value: 278
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Video Tutorial

Learn More

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!