Flame Sensor with Arduino
Keep an eye on a candle you have burning or a fireplace!
Written By: Cherie Tan
![](https://files.littlebird.com.au/guides/6_poster.png)
![Dash icon](https://fast.littlebird.com.au/static/guides/dash.webp)
Difficulty
Easy
![Steps icon](https://fast.littlebird.com.au/static/guides/steps.webp)
Steps
5
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.
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.