Arduino UNO Q - Flame Sensor

A flame sensor detects infrared radiation from fire and outputs both a digital signal (flame/no flame) and an analog signal (flame intensity). On Arduino UNO Q, the 12-bit ADC gives finer intensity readings. With Bridge and Telegram, you get instant fire alerts on your phone.

In this tutorial, you will learn:

Arduino UNO Q Flame Sensor

※ NOTE THAT:

The flame sensor detects infrared radiation. Use it for early fire detection and as part of a safety system — always pair it with proper fire alarms and safety equipment. Never rely on this sensor alone for life-safety applications.

Hardware Preparation

1×Arduino UNO Q
1×USB Cable for Arduino Uno Q
1×Flame Sensor
1×Jumper Wires
1×Recommended: Screw Terminal Block Shield for Arduino Uno
1×Recommended: Sensors/Servo Expansion Shield for Arduino Uno
1×Recommended: Breadboard Shield for Arduino Uno
1×Recommended: Enclosure for Arduino Uno
1×Recommended: Prototyping Base Plate & Breadboard Kit for Arduino UNO

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 the Flame Sensor

The flame sensor contains an infrared photodiode that is sensitive to the specific infrared wavelengths produced by flames. It includes an onboard potentiometer to adjust the digital detection threshold.

Flame Sensor Pinout

Pinout

  • VCC pin: 3.3V to 5V power supply
  • GND pin: Ground
  • DO pin: Digital output — HIGH = no flame, LOW = flame detected. Sensitivity is set by the onboard potentiometer.
  • AO pin: Analog output — higher value = more infrared/flame, lower value = less flame

LED Indicators

  • PWR-LED: Power indicator
  • DO-LED: Lights up when flame is detected (DO pin LOW)

How It Works

  • DO pin: The potentiometer sets a threshold. When the infrared level exceeds the threshold, DO goes LOW (flame detected). Adjust the potentiometer until the DO-LED reliably triggers near a flame.
  • AO pin: Outputs a continuous analog voltage proportional to the infrared intensity. On Arduino UNO Q, this is read as a 12-bit value (0–4095) — higher values mean more infrared/flame.

※ NOTE THAT:

Flame sensors respond to any strong infrared source, not just fire. Strong sunlight or infrared LEDs can also trigger the sensor. Shield the sensor from direct sunlight to avoid false alarms.

Wiring Diagram

The wiring diagram between Arduino UNO Q Flame Sensor

This image is created using Fritzing. Click to enlarge image

Flame Sensor Pin Arduino UNO Q MCU
VCC 5V
GND GND
DO D2
AO A0

How To Program For Flame Sensor

  • Configure the DO pin as a digital input:
pinMode(DO_PIN, INPUT);
  • Read both outputs:
int do_state = digitalRead(DO_PIN); // HIGH = no flame, LOW = flame int ao_value = analogRead(AO_PIN); // 0-4095, higher = more flame
  • Check for flame from digital output:
if (do_state == LOW) { Serial.print("FLAME DETECTED! Intensity (AO): "); Serial.println(ao_value); }

Arduino UNO Q Code

The Arduino UNO Q has two processors working together:

  • The STM32 MCU reads both DO and AO outputs from the flame sensor every 500 ms
  • The Qualcomm MPU runs Debian Linux with Wi-Fi — in this section, only the MCU is programmed. A later section shows how both processors work together via Bridge.
/* * This Arduino UNO Q code was developed by newbiely.com * * This Arduino UNO Q code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-flame-sensor */ // COPYRIGHT newbiely.com // AUTHOR: newbiely // This code is made available for public use without restriction. // For complete instructions, tutorials, and further information, visit: // https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-flame-sensor // Flame sensor: // DO pin: HIGH = no flame, LOW = flame detected // AO pin: analog — higher value = more infrared/flame (12-bit ADC: 0-4095) #define DO_PIN 2 // The Arduino UNO Q MCU pin connected to DO of the flame sensor #define AO_PIN A0 // The Arduino UNO Q MCU pin connected to AO of the flame sensor void setup() { Serial.begin(9600); pinMode(DO_PIN, INPUT); Serial.println("Arduino UNO Q Flame Sensor ready"); } void loop() { int do_state = digitalRead(DO_PIN); // HIGH = no flame, LOW = flame int ao_value = analogRead(AO_PIN); // 0-4095, higher = more flame if (do_state == LOW) { Serial.print("FLAME DETECTED! Intensity (AO): "); Serial.println(ao_value); } else { Serial.print("No flame. AO value: "); Serial.println(ao_value); } delay(500); }

Detailed Instructions

First time with Arduino UNO Q? Follow the Getting Started with Arduino UNO Q tutorial before proceeding.

  • Connect: Wire the flame sensor to the Arduino UNO Q MCU as shown in the wiring diagram.
  • Open Arduino App Lab: Launch Arduino App Lab and wait until it detects your Arduino UNO Q.
  • Create a new App: Click the Create New App button.
Create New App in Arduino App Lab on Arduino UNO Q
  • Give the App a name, for example: FlameSensor
  • Click Create to confirm.
Arduino App Lab App folders and files on Arduino UNO Q
  • Paste the sketch: Copy the MCU code above and paste it into sketch/sketch.ino.
  • Upload: Click the Run button in Arduino App Lab.
Click Run button in Arduino App Lab on Arduino UNO Q
  • Point the flame sensor towards a candle flame — observe the Serial Monitor output.
  • Adjust the potentiometer on the module if the DO pin does not respond correctly.

App Lab Console Output

DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
Message (Enter to send a message to "Newbiely" on usb(2820070321))
New Line
9600 baud
[2026-04-29 09:00:01] Arduino UNO Q Flame Sensor ready [2026-04-29 09:00:02] No flame. AO value: 45 [2026-04-29 09:00:03] No flame. AO value: 48 [2026-04-29 09:00:04] FLAME DETECTED! Intensity (AO): 2156 [2026-04-29 09:00:05] FLAME DETECTED! Intensity (AO): 2843 [2026-04-29 09:00:06] FLAME DETECTED! Intensity (AO): 3102 [2026-04-29 09:00:07] No flame. AO value: 51

Bridge: Linux + MCU

This section shows how to program both processors of the Arduino UNO Q so the Linux side can read flame state and receive fire events via Bridge:

  • The flame sensor is connected to the MCU — the MCU reads DO and AO every 500 ms and caches the values
  • The MPU cannot read the sensor pins directly — it calls Bridge functions to get state, intensity value, or events
  • The MPU has Wi-Fi — running full Debian Linux, it can send urgent Telegram fire alerts the moment a flame is detected
  • Arduino_RouterBridge enables RPC communication between the two processors
  • ⚠️ /dev/ttyHS1 (Linux) and Serial1 (MCU) are RESERVED by the router — never open them in user code

MCU Code (Bridge)

/* * This Arduino UNO Q code was developed by newbiely.com * * This Arduino UNO Q code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-flame-sensor */ // COPYRIGHT newbiely.com // AUTHOR: newbiely // This code is made available for public use without restriction. // For complete instructions, tutorials, and further information, visit: // https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-flame-sensor #include "Arduino_RouterBridge.h" #define DO_PIN 2 // The Arduino UNO Q MCU pin connected to DO of the flame sensor #define AO_PIN A0 // The Arduino UNO Q MCU pin connected to AO of the flame sensor // Cached values bool cached_flame = false; int cached_ao = 0; bool flame_event = false; bool prev_flame = false; unsigned long last_read_ms = 0; const unsigned long READ_INTERVAL = 500; String get_state(String arg) { return cached_flame ? "flame" : "no_flame"; } String get_value(String arg) { return String(cached_ao); } String get_event(String arg) { if (flame_event) { flame_event = false; return "flame_detected"; } return "none"; } void setup() { Bridge.begin(); Monitor.begin(); pinMode(DO_PIN, INPUT); Bridge.provide("get_state", get_state); Bridge.provide("get_value", get_value); Bridge.provide("get_event", get_event); Monitor.println("Arduino UNO Q Flame Sensor Bridge ready"); } void loop() { unsigned long now = millis(); if (now - last_read_ms >= READ_INTERVAL) { last_read_ms = now; int do_state = digitalRead(DO_PIN); // LOW = flame cached_ao = analogRead(AO_PIN); cached_flame = (do_state == LOW); if (cached_flame && !prev_flame) { flame_event = true; Monitor.print("FLAME DETECTED! AO value: "); Monitor.println(cached_ao); } else if (!cached_flame && prev_flame) { Monitor.println("Flame gone. No flame detected."); } prev_flame = cached_flame; } }

Python Code (Bridge)

/* * This Arduino UNO Q code was developed by newbiely.com * * This Arduino UNO Q code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-flame-sensor */ # COPYRIGHT newbiely.com # AUTHOR: newbiely # This code is made available for public use without restriction. # For complete instructions, tutorials, and further information, visit: # https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-flame-sensor from arduino.app_utils import * import time def loop(): state = Bridge.call("get_state") value = Bridge.call("get_value") print(f"Flame state: {state} AO value: {value}") time.sleep(0.5) App.run(user_loop=loop)

Detailed Instructions

  • Connect: Wire the flame sensor to the Arduino UNO Q as shown in the wiring diagram.
  • Open Arduino App Lab and create a new App named FlameSensorBridge.
  • Paste the MCU sketch into sketch/sketch.ino.
  • Paste the Python code into the Python file.
  • Install the library: Click the Add sketch library button (the open book icon with a + sign) in the left sidebar.
Add sketch library in Arduino App Lab on Arduino UNO Q
  • Search for Arduino_RouterBridge created by Arduino and click the Install button.
My Apps / DIYables Apps
Run
Bricks
No bricks added...
Sketch Libraries
No sketch libra...
Files
python
sketch
.gitignore
README.md
app.yaml
sketch.ino
Add sketch library
Arduino_RouterBridge Arduino

This library provides a simple RPC bridge for Arduino UNO Q boards, allowing communication between the board and other devices using MsgPack serialization.

0.4.1
Install
More Info
  • Upload: Click the Run button.
Click Run button in Arduino App Lab on Arduino UNO Q
  • Point the sensor at a candle — observe the flame event appear in both consoles.

App Lab Console Output

DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
Message (Enter to send a message to "Newbiely" on usb(2820070321))
New Line
9600 baud
[2026-04-29 09:00:01] Arduino UNO Q Flame Sensor Bridge ready [2026-04-29 09:00:06] FLAME DETECTED! AO value: 2843 [2026-04-29 09:00:10] Flame gone. No flame detected.
DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
[2026-04-29 09:00:02] Flame state: no_flame AO value: 48 [2026-04-29 09:00:04] Flame state: no_flame AO value: 50 [2026-04-29 09:00:06] Flame state: flame AO value: 2843 [2026-04-29 09:00:08] Flame state: flame AO value: 3102 [2026-04-29 09:00:10] Flame state: no_flame AO value: 49

Telegram

Receive instant Telegram fire alerts from the Arduino UNO Q flame sensor, and query flame state remotely.

MCU sketch: Keep the same MCU sketch from the previous Bridge section.

Python Code (Telegram)

/* * This Arduino UNO Q code was developed by newbiely.com * * This Arduino UNO Q code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-flame-sensor */ # COPYRIGHT newbiely.com # AUTHOR: newbiely # This code is made available for public use without restriction. # For complete instructions, tutorials, and further information, visit: # https://newbiely.com/tutorials/arduino-uno-q/arduino-uno-q-flame-sensor from arduino.app_utils import * import requests import time TELEGRAM_BOT_TOKEN = "YOUR_TELEGRAM_BOT_TOKEN" CHAT_ID = "YOUR_CHAT_ID" last_update_id = 0 def get_updates(): global last_update_id url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/getUpdates" params = {"offset": last_update_id + 1, "timeout": 5} try: response = requests.get(url, params=params, timeout=10) data = response.json() if data["ok"]: return data["result"] except Exception as e: print(f"Error getting updates: {e}") return [] def send_message(chat_id, text): url = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage" payload = {"chat_id": chat_id, "text": text} try: requests.post(url, data=payload, timeout=10) except Exception as e: print(f"Error sending message: {e}") def loop(): # Auto-alert on flame detection event = Bridge.call("get_event") if event == "flame_detected": value = Bridge.call("get_value") print(f"FLAME DETECTED! AO value: {value}") send_message(CHAT_ID, f"🔥 FLAME DETECTED! Intensity (AO): {value}") # Handle Telegram commands updates = get_updates() for update in updates: last_update_id = update["update_id"] if "message" not in update: continue message = update["message"] chat_id = message["chat"]["id"] text = message.get("text", "").strip() print(f"Received: {text}") if text == "/start": send_message(chat_id, "Arduino UNO Q Flame Sensor Bot\n" "/state - Current state (flame / no_flame)\n" "/value - Read analog intensity (0-4095)\n" "Automatic alert when flame is detected!") elif text == "/state": result = Bridge.call("get_state") send_message(chat_id, f"Flame state: {result}") elif text == "/value": result = Bridge.call("get_value") send_message(chat_id, f"AO intensity value: {result}") else: send_message(chat_id, "Unknown command. Send /start for help.") time.sleep(0.3) App.run(user_loop=loop)

Detailed Instructions

  • Replace YOUR_TELEGRAM_BOT_TOKEN with your actual bot token from BotFather.
  • Replace YOUR_CHAT_ID with your Telegram chat ID.
  • Paste this Python code into your App's Python file (keep the same MCU sketch).
  • Click the Run button — point the sensor at a flame to receive the Telegram alert.

App Lab Console Output

DIYables_Apps
Stop
sketch.ino
1#include "Arduino_RouterBridge.h"
Serial Monitor
Python
[2026-04-29 09:10:00] Waiting for Telegram messages... [2026-04-29 09:10:06] FLAME DETECTED! AO value: 2843 [2026-04-29 09:10:12] Received: /state [2026-04-29 09:10:15] Received: /value
Telegram
Telegram 12:45
Welcome to Telegram!
ArduinoBot 10:19
Chatting with Arduino...
telegram-botfather
BotFather Yesterday
Your bot has been created.

ArduinoBot

bot
Today
🔥 FLAME DETECTED! Intensity (AO): 2843
10:15 AM
/state
10:16 AM ✓✓
Flame state: no_flame
10:17 AM
/value
10:18 AM ✓✓
AO intensity value: 49
10:19 AM

OpenClaw

...OPENCLAW

OpenClaw support for Arduino UNO Q Flame Sensor is coming soon.

...OPENCLAW

Project Ideas

You can build many useful projects with the flame sensor and Arduino UNO Q:

  • Fire Alert System: Mount the flame sensor in a kitchen or tutorial — when a flame is detected, the MPU sends an urgent Telegram alert with the AO intensity value so you can take immediate action from anywhere
  • Automatic Fire Suppression: Connect the flame sensor with a relay-controlled solenoid valve — when flame is detected, the MCU opens the valve to release water or suppression agent, and Python sends a Telegram notification
  • Candle Monitoring: Place the sensor near a candle in an unattended room — receive a Telegram alert if the candle is still burning after a set time, or if a new flame appears unexpectedly
  • Fire Intensity Logger: Log AO values and timestamps to a CSV on Linux whenever flame is detected — send a daily Telegram report summarizing flame events with start time, end time, and peak intensity
  • Multi-Sensor Fire Safety System: Combine the flame sensor with the gas sensor tutorial — if both detect danger simultaneously, send a "FIRE + GAS LEAK" Telegram alert and trigger an audible alarm via relay

Challenge Yourself

Ready to go further with the flame sensor on Arduino UNO Q? Try these challenges:

  • Easy: Add a /history Telegram command that returns the last 5 flame events with timestamps and peak AO intensity values stored in a Python list.
  • Medium: Implement a false-alarm filter: the flame must be detected for at least 3 consecutive readings (1.5 seconds) before the MPU sends a Telegram alert — this prevents single-pulse false positives from bright lights.
  • Advanced: Build a multi-zone fire monitoring system using two flame sensors on different digital pins — expose separate Bridge functions for each zone, and Telegram alerts that specify which zone detected the flame with individual intensity readings.

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!