ESP32 S3 - Flame Sensor

Learn how to build a fire detection system using an ESP32 S3 and a flame sensor to monitor and detect flames for safety applications. This beginner-friendly tutorial covers everything you need to get started with infrared flame sensors.

What you'll build:

  1. A digital flame detector that reports fire presence to the Serial Monitor
  2. An analog flame intensity reader that measures fire strength in real time
  3. A foundation for building automated fire alarm and suppression systems
  4. A practical sensor integration project on the ESP32 S3 platform
esp32 S3 flame sensor

Hardware Preparation

1×ESP32 S3 WROOM N16R8
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×Flame Sensor
1×5-in-1 5-way Flame Sensor
1×Breadboard
1×Jumper Wires

Or you can buy the following kits:

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

A flame sensor is an infrared detector that senses flame presence and measures fire intensity through infrared light detection. It provides both a simple digital on/off signal and a continuous analog voltage proportional to the strength of the detected infrared radiation. The module's onboard potentiometer lets you fine-tune sensitivity to suit your environment.

infrared flame fire-sensor module

Key Specifications

  • Detects infrared radiation from flames (760nm to 1100nm wavelength)
  • Provides both digital (on/off) and analog (intensity) outputs
  • Adjustable sensitivity via onboard potentiometer
  • Works with 3.3V to 5V power supply
  • Fast response time for quick fire detection
  • Built-in LED indicators for power and flame status
  • Detection range typically 60–80 cm (varies by model)

Why It's Useful for Beginners:

  • Simple two or three-wire connection to ESP32 S3
  • Easy to understand digital output for basic fire detection
  • No complex programming required
  • Affordable and widely available
  • Great for learning about sensor integration

Important Limitations:

  • May produce false positives from sunlight or heat sources
  • Requires proper positioning and sensitivity adjustment
  • Should not be sole fire safety device in critical applications

Pinout

The flame sensor module provides four pins that give you both digital and analog access to its readings.

  1. VCC: Power supply input (3.3V to 5V)
  2. GND: Ground connection (0V)
  3. DO: Digital output pin — LOW when flame detected, HIGH when no flame
  4. AO: Analog output pin — voltage varies with infrared intensity level
Flame Sensor Pinout
image source: diyables.io

LED Indicators:

  • PWR-LED: Power indicator — lights when module is powered
  • DO-LED: Flame detection indicator — lights when flame is detected

5-in-1 Flame Sensor Module:

  • Features five independent flame sensors on one board
  • Each sensor has separate DO and AO pins
  • Sensors point in different directions for 360° coverage
  • Shares common VCC, GND, and potentiometer
  • Provides wider detection area than single sensor

How It Works

The infrared flame sensor detects specific wavelengths of infrared light emitted by flames.

Digital Output (DO Pin):

  • Adjust sensitivity by turning the onboard potentiometer
  • When infrared intensity exceeds threshold: DO pin goes LOW, LED turns on
  • When infrared intensity is below threshold: DO pin stays HIGH, LED turns off
  • Use for simple yes/no flame detection
  • Perfect for triggering alarms or automated systems

Analog Output (AO Pin):

  • Output voltage increases with higher infrared intensity
  • Output voltage decreases with lower infrared intensity
  • Provides continuous measurement of flame strength
  • Useful for distance estimation or flame size monitoring
  • Not affected by potentiometer adjustment

Detection Process:

  • Sensor continuously monitors infrared radiation
  • Built-in comparator converts analog signal to digital output
  • Both outputs available simultaneously for flexible applications

Wiring Diagram

Connect the flame sensor to your ESP32 S3 based on whether you need digital detection, analog measurement, or both. Ensure all connections are secure before powering the board.

Safety Notes

Always test with actual flame sources in a safe, controlled environment away from flammable materials. Do not rely solely on this sensor for critical fire safety applications, and keep the sensor away from direct sunlight during testing to avoid false readings.

Flame Sensor Pin ESP32 S3 Pin
VCC 3.3V
GND GND
DO GPIO6
AO A5 (GPIO5 / ADC1_CH5)

Wiring Diagram - Both Digital and Analog:

The wiring diagram between ESP32 S3 infrared flame sensor

This image is created using Fritzing. Click to enlarge image

ESP32 S3 Code - Read value from DO pin

The following code reads the digital output from the flame sensor to detect fire presence. It configures GPIO6 as a digital input, polls the pin every 500 milliseconds, and prints a human-readable fire detection status to the Serial Monitor so you can observe the sensor's response in real time.

/* * This ESP32 S3 code was developed by newbiely.com * * This ESP32 S3 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-s3/esp32-s3-flame-sensor */ #define DO_PIN 6 // The ESP32 S3 pin connected to DO pin of the flame sensor void setup() { // Initialize the Serial to communicate with the Serial Monitor. Serial.begin(115200); // initialize the ESP32'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

  1. New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
  2. Open Arduino IDE: Launch the Arduino IDE on your computer.
  3. Copy the code: Copy the code above and paste it into Arduino IDE.
  4. Select your board: Go to Tools > Board > ESP32S3 Dev Module.
  5. Select your port: Go to Tools > Port and select the correct COM port.
  6. Upload the code: Click the Upload button to program your ESP32 S3.
  7. Test the sensor: Point the flame sensor at a candle or lighter flame.
  8. Open Serial Monitor: Click the Serial Monitor icon (top right) and set baud rate to 115200.
  9. View results: Watch the flame detection status change in real-time.
  10. Adjust sensitivity: Turn the potentiometer if the sensor is too sensitive or not sensitive enough.
  11. Pro Tip: If the DO-LED stays on or off constantly, adjust the onboard potentiometer clockwise or counterclockwise until the LED responds correctly to flame presence.

Serial Monitor Output

Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32S3 Dev Module' on 'COM15')
New Line
9600 baud
[2026-06-16 10:23:45] No flame detected => The fire is NOT detected [2026-06-16 10:23:46] No flame detected => The fire is NOT detected [2026-06-16 10:23:47] Flame detected => The fire is detected [2026-06-16 10:23:47] Flame detected => The fire is detected [2026-06-16 10:23:48] Flame detected => The fire is detected [2026-06-16 10:23:49] Flame detected => The fire is detected [2026-06-16 10:23:50] No flame detected => The fire is NOT detected [2026-06-16 10:23:51] No flame detected => The fire is NOT detected
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

ESP32 S3 Code - Read value from AO pin

The following code reads the analog output from the flame sensor to measure flame intensity. It configures GPIO5 as an analog input, samples the ADC continuously, and displays the raw 12-bit value (0–4095) in the Serial Monitor — higher values indicate a stronger flame or closer proximity to the sensor.

/* * This ESP32 S3 code was developed by newbiely.com * * This ESP32 S3 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-s3/esp32-s3-flame-sensor */ #define AO_PIN A5 // The ESP32 S3 pin connected to AO pin of the flame sensor void setup() { // Initialize the Serial to communicate with the Serial Monitor. Serial.begin(115200); // set the ADC attenuation to 11 dB (up to ~3.3V input) analogSetAttenuation(ADC_11db); } void loop() { int infrared_value = analogRead(AO_PIN); Serial.print("The AO value: "); Serial.println(infrared_value); }

Detailed Instructions

  1. New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
  2. Open Arduino IDE: Launch the Arduino IDE on your computer.
  3. Copy the code: Copy the code above and paste it into Arduino IDE.
  4. Select your board: Go to Tools > Board > ESP32S3 Dev Module.
  5. Select your port: Go to Tools > Port and select the correct COM port.
  6. Upload the code: Click the Upload button to program your ESP32 S3.
  7. Test the sensor: Point the flame sensor toward a flame source.
  8. Open Serial Monitor: Click the Serial Monitor icon and set baud rate to 115200.
  9. Observe readings: Watch how values increase as you move the flame closer.
  10. Test distance: Move the flame farther away and see values decrease.
  11. Pro Tip: Record baseline values in your environment without flames, then use those values to set detection thresholds in your code for automatic fire alarms.

Serial Monitor Output

Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32S3 Dev Module' on 'COM15')
New Line
9600 baud
[2026-06-16 10:25:12] AO Value: 245 [2026-06-16 10:25:12] AO Value: 248 [2026-06-16 10:25:13] AO Value: 251 [2026-06-16 10:25:13] AO Value: 587 [2026-06-16 10:25:14] AO Value: 693 [2026-06-16 10:25:14] AO Value: 956 [2026-06-16 10:25:15] AO Value: 1024 [2026-06-16 10:25:15] AO Value: 1087 [2026-06-16 10:25:16] AO Value: 1098 [2026-06-16 10:25:16] AO Value: 1102 [2026-06-16 10:25:17] AO Value: 658 [2026-06-16 10:25:17] AO Value: 521 [2026-06-16 10:25:18] AO Value: 327 [2026-06-16 10:25:18] AO Value: 189 [2026-06-16 10:25:19] AO Value: 243
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

※ NOTE THAT:

This tutorial uses the analogRead() function to read values from an ADC (Analog-to-Digital Converter) connected to a sensor or component. The ESP32 S3's ADC is suitable for projects that do not require high accuracy. However, for projects needing precise measurements, keep the following in mind:

  • The ESP32 S3's ADC is not perfectly accurate and might require calibration for correct results. Each ESP32 S3 board can vary slightly, so calibration is necessary for each individual board.
  • Calibration can be challenging, especially for beginners, and might not always yield the exact results you want.

For projects requiring high precision, consider using an external ADC (e.g ADS1115) with the ESP32 S3 or using another Arduino, such as the Arduino Uno R4 WiFi, which has a more reliable ADC. If you still want to calibrate the ESP32 S3's ADC, refer to the ESP32 ADC Calibration Driver.

Application Ideas

The ESP32 S3's processing power and wireless connectivity make it an excellent platform for a wide range of flame-sensing applications.

  1. Smart fire alarm system: Add a buzzer and LED warnings for real-time home safety alerts.
  2. Automatic fire extinguisher trigger: Activate a relay-controlled suppression system in small enclosed spaces.
  3. Fire-fighting robot: Build a robot that navigates toward flames and activates a suppression mechanism.
  4. Industrial furnace monitor: Track flame presence in heating equipment to prevent unsafe shutoffs.
  5. Gas stove safety system: Detect if a flame goes out unexpectedly and alert the user immediately.
  6. Multi-zone fire detection: Deploy multiple sensors across a large area for comprehensive coverage.
  7. IoT fire alert system: Leverage the ESP32 S3's WiFi to send push notifications to your smartphone.

Video Tutorial

Watch the step-by-step video walkthrough for this ESP32 S3 project below.

Challenge Yourself

These challenges will help you go beyond the basics and build more capable flame-detection systems with your ESP32 S3.

  1. Beginner: Add a buzzer that sounds when flame is detected using the digital output.
  2. Beginner: Add an LED that lights up when flame intensity exceeds a threshold value.
  3. Intermediate: Create a flame intensity meter using multiple LEDs as a bar graph display.
  4. Intermediate: Combine digital and analog readings to build a smart fire alarm with distance warning.
  5. Advanced: Build a WiFi-enabled fire monitoring system that sends alerts to your smartphone.
  6. Advanced: Create a multi-sensor fire detection array using the 5-in-1 module for 360° coverage.

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!