Introduction

Flame sensors can detect flame and infrared light sources.

In this guide, you will learn how to use a flame sensor module with the Arduino. The flame sensor can be used to keep an eye on a candle you have burning or a fireplace. 

Completing this guide will enable you to monitor a project or as a safety precaution to cut a device on or off.
    • Connect Arduino 5V to the Flame Sensor.

    • Connect Ground to the Flame Sensor.

    • Connect Analogue 0 to the Flame Sensor.

  1. const int sensorMin = 0;     // sensor minimum
    const int sensorMax = 1024;  // sensor maximum
    
    void setup() {
      Serial.begin(9600);
    }
    void loop() {
      int flameSensor = analogRead(A0);
      int range = map(flameSensor, sensorMin, sensorMax, 0, 3);
    
      // range value:
      switch (range) {
      case 0:
        Serial.println("Fire within 40cm");
        break;
      case 1:    // A fire between 1-3 feet away.
        Serial.println("Fire between 40cm - 1m");
        break;
      case 2:    // No fire detected.
        Serial.println("No Fire");
        break;
      }
      delay(1000);  // 1 second be
    }
    • Copy the code and upload it in the IDE.

    • Open the Serial Monitor

    • The sensor will detect the IR wavelengths given off by the flames.

    • This part of the guide should be done under Adult Supervision!

    • Test your Flame Sensor with a Flame!