Arduino Nano 33 IoT - Flame Sensor

The flame sensor can sense and measure the infrared light that comes from a flame. It is useful for detecting fires and is also called an infrared flame sensor or fire sensor. This sensor gives two kinds of information: one works like a simple switch (on or off) and the other gives an analog signal that shows how strong the flame is.

In this guide, you will learn how to use an Arduino Nano 33 IoT board with a flame sensor to find flames. We will go through the following steps:

Arduino Nano 33 IoT infrared flame fire sensor

Then you can change the code to make a warning horn sound when a fire is detected.

Hardware Preparation

1×Arduino Nano 33 IoT
1×Micro USB Cable
1×Flame Sensor
1×5-in-1 5-way Flame Sensor
1×Breadboard
1×Jumper Wires
1×Recommended: Screw Terminal Expansion Board for Arduino Nano
1×Recommended: Breakout Expansion Board for Arduino Nano
1×Recommended: Power Splitter 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.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of Flame Sensor

infrared flame fire-sensor module

The infrared flame sensor can find a fire or measure the invisible light the flame gives off. This helps us discover fires. The sensor works with two types of signals: a digital signal and an analog signal.

These sensors are made to pick up certain kinds of infrared light from flames while ignoring other sources, like the heat from people or indoor lights. However, like any sensor, they are not perfect and can sometimes make mistakes—either saying there is a fire when there isn’t (false positive) or missing a fire when there is one (false negative).

Pinout

You can find two kinds of flame sensor modules.

A single flame sensor has four pins:

  • VCC pin: Connect this pin to a power supply between 3.3V and 5V.
  • GND pin: Connect this pin to ground (0V).
  • DO pin: This is a digital output pin. It shows HIGH when no flame is detected and LOW when a flame is detected. You can change the flame detection level using the built-in knob.
  • AO pin: This is an analog output pin. Its value goes down when the infrared level decreases, and it goes up when the infrared level increases.
Flame Sensor Pinout
image source: diyables.io

Also, it has two LED lights:

  • One LED shows if the system has power.
  • One LED connected to the DO pin shows the flame status—it lights up when there is a flame.

The 5-in-1 flame sensor combines five flame sensors on one board. They all share the same potentiometer, VCC, and ground, but each sensor has its own digital output (DO) and analog input (AI) pins and faces a different direction. This setup makes the overall detection range larger.

How It Works

For the digital output (DO) pin:

  • The module has a built-in knob that lets you adjust how sensitive the infrared sensor is.
  • If the infrared light is stronger than the set limit, the sensor detects a flame, the sensor’s output goes LOW, and the DO-LED lights up.
  • If the infrared light is weaker than the set limit, the sensor does not detect a flame, the sensor’s output goes HIGH, and the DO-LED stays off.

About the AO pin:

  • When there is a lot of infrared light around, the AO pin shows a high value.
  • When there is a little infrared light around, the AO pin shows a low value.

Keep in mind that the knob does not change the value on the AO pin.

Wiring Diagram

The flame sensor module has two outputs. You can use one or both of them based on what you need.

  • Wiring diagram showing how to connect the Arduino Nano 33 IoT to a flame sensor using both its analog and digital outputs.
The wiring diagram between Arduino Nano and 33 IoT infrared flame sensor

This image is created using Fritzing. Click to enlarge image

  • Simple wiring diagram that shows how to connect the Arduino Nano 33 IoT to the flame sensor using only the digital output (DO).
The wiring diagram between Arduino Nano and 33 IoT Flame Sensor

This image is created using Fritzing. Click to enlarge image

  • The connection drawing that shows how to hook up the Arduino Nano 33 IoT and the flame sensor using only AO.
The wiring diagram between Arduino Nano and 33 IoT fire sensor

This image is created using Fritzing. Click to enlarge image

※ NOTE THAT:

Please note that the Arduino Nano 33 IoT pins A4 and A5 have built-in pull-up resistors for I2C communication. Although these pins can be used as digital input pins, it is recommended to avoid using them for digital input. If you must use them, do not use internal or external pull-down resistors for these pins

Arduino Nano 33 IoT Code - Read value from DO pin

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-flame-sensor */ #define DO_PIN 2 // The Arduino Nano ESP3 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 33 IoT's pin as an input pinMode(DO_PIN, INPUT); } void loop() { int flame_state = digitalRead(DO_PIN); if (flame_state == HIGH) Serial.println("No flame dected => The fire is NOT detected"); else Serial.println("Flame dected => The fire is detected"); }

Detailed Instructions

If you are new to the Arduino Nano 33 IoT, be sure to check out our Getting Started with Arduino Nano 33 IoT tutorial. Then, follow these steps:

  • Connect the components to the Arduino Nano 33 IoT board as depicted in the diagram.
  • Use a USB cable to connect the Arduino Nano 33 IoT board to your computer.
  • Launch the Arduino IDE on your computer.
  • Select the Arduino Nano 33 IoT board and choose its corresponding COM port.
  • Copy the code above and open it in the Arduino IDE.
  • Click the Upload button to load the code onto your Arduino Nano 33 IoT.
  • Point the flame sensor at a flame.
  • Check the result in the Serial Monitor.
COM6
Send
No flame dected => The fire is NOT detected No flame dected => The fire is NOT detected Flame dected => The fire is detected Flame dected => The fire is detected Flame dected => The fire is detected No flame dected => The fire is NOT detected No flame dected => The fire is NOT detected No flame dected => The fire is NOT detected
Autoscroll Show timestamp
Clear output
9600 baud  
Newline  

Remember, if you see that the LED stays on all the time or stays off even when the sensor points at a flame, you can turn the potentiometer to adjust the sensor's sensitivity.

Arduino Nano 33 IoT Code - Read value from AO pin

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-flame-sensor */ #define AO_PIN A7 // The Arduino Nano 33 IoT 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 infrared_value = analogRead(AO_PIN); Serial.print("The AO value: "); Serial.println(infrared_value); }

Detailed Instructions

If you are new to the Arduino Nano 33 IoT, be sure to check out our Getting Started with Arduino Nano 33 IoT tutorial. Then, follow these steps:

  • Connect the components to the Arduino Nano 33 IoT board as depicted in the diagram.
  • Use a USB cable to connect the Arduino Nano 33 IoT board to your computer.
  • Launch the Arduino IDE on your computer.
  • Select the Arduino Nano 33 IoT board and choose its corresponding COM port.
  • Copy the code above and open it in the Arduino IDE.
  • Press the Upload button in the Arduino IDE to send the code to your Arduino Nano 33 IoT.
  • Point the flame sensor toward a flame.
  • View the result in the Serial Monitor.
COM6
Send
245 246 246 573 677 949 955 1004 1007 1013 1018 641 543 340 179
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!