Source: https://mokxi.com/parts/flame
Updated: 2026-11-10

Part

# Flame sensor

An infrared eye on a comparator board. DO goes low when a flame comes within half a meter.

See every part

- 4 pins
- 1 setting
- In 2 projects
- In 1 lesson

Drawn live by the editor's own code, at the size you see it.

At a glance

## The Flame sensor in brief

What it is, and every setting the properties panel gives it.

The flame sensor module, KY-026 style, is an infrared phototransistor standing off the end of an LM393 comparator board, with pins AO, GND, VCC and DO. It runs on 3.3 to 5 volts, so it wires straight to an Uno or an ESP32: VCC to the board’s supply, DO to any digital pin, AO to an analog input. It does not see fire as such, only near infrared between about 760 and 1100 nanometers behind a black lens. More infrared pulls AO lower, and DO goes low, lighting the lamp, when AO falls below the trimmer, the opposite of what most first sketches assume. Mokxi models the receiver’s current falling with the square of the distance, 100 microamps at 80 centimeters, saturating closer than about 30 centimeters, so at the default threshold of 0.5 a lighter trips it at about half a meter and the analog reading only really tells far from near. A slider moves the flame from 5 to 150 centimeters. Sunlight, bulbs, remotes, flicker, the 60 degree cone and response time are not modeled, and like the real board the comparator has no hysteresis.

Family

Sensors

Pins

4

threshold

0.5

Pins

## 4 pins

Named as the editor names them, so a wire lands where you expect it.

Pin

Role

What it does

AO

Output

The receiver under its pull-up: lower means more infrared.

GND

Input or output

Ground.

VCC

Input or output

Supply, 3.3 V to 5 V.

DO

Output

Low when a flame is close enough. Open collector with a 10 k pull-up.

How to use it

## How to use a flame sensor with an Arduino

Wire VCC to 5 V, GND to GND and DO to pin 2. DO is an open-collector output with its own 10 k pull-up, and it goes LOW when a flame is close enough, so to the sketch a flame looks exactly like a pressed button: test for LOW, not HIGH. The example lights the LED on pin 13 while it does.

The trimmer sets the range. At the middle setting a lighter trips it at about half a meter; turn it up toward the supply and it reaches further. AO is worth wiring to an analog pin only to see the trend, since it bottoms out once the flame is within about 30 cm.

Part pin

Board pin

DO

Pin 2

VCC

5 V

GND

GND

The module runs from 3.3 V as well, so on an ESP32 or a Pico power it from 3.3 V and DO stays at a safe level for the pin.

Click to open it in the editor

This is the simulator itself, running here. Click anything to open it in the editor.

Read the full tutorial

How it is modeled

## What is true about the Flame sensor, here

In its help article’s own words: what the simulation gets right, and where it stops.

### Modeled

The light reaching the receiver falls with the square of the distance, and the
current follows the light: 100 µA at 80 cm, four times that at 40 cm, until the
transistor saturates at about 30 cm and AO sits on the floor. That makes the
datasheet's claim true: a lighter at 80 cm is just detectable with the trimmer turned
up to 0.8, and at the middle setting it trips at about half a meter. It is also why
AO is only good for "far" and "near", and why every sketch uses DO.

### Not modeled

Everything else that is infrared. Sunlight through a window trips a real one, and so
do an incandescent bulb, a TV remote and a warm radiator up close; here only the flame
on the slider exists. The flame is steady, not flickering. The 60 degree cone and the
board's response time are not modeled, and the comparator has no hysteresis, as on
the real board.

From Flame sensor, in full.

Projects

## See the Flame sensor in a project

2 built-in projects use it. Each opens in the editor, already wired.

Lessons

## Where it turns up in a lesson

One lesson places it in its own circuit.

### Learn articles

1 lesson

- Arduino Flame Sensor: Wiring, Code and Range

Boards

## The boards it is shown on

This board has a built-in project with the Flame sensor in it.

- Arduino Uno R3

More parts

## The rest of the bench

Every one of these is drawn and simulated the same way.

Full-size breadboard

A real 0.1 inch grid with the rails and the center channel, 63 columns wide.

Jumper wires

Drag from any pin or hole to any other. Corners snap, and you can drag them.

Power

A supply rail at the voltage you choose.

Ground

The other end of every circuit.

LED

Lights when current flows. Five colors, and the brightness is what your eye would see.

Filament lamp

A tungsten bulb in a holder: an inrush when it is switched on cold, tens of milliseconds to warm up, and dim on half its voltage.

Resistor

Any value you like, with the color bands drawn to match.

ESP32-C3-DevKitM-1

A RISC-V board that runs your firmware at 160 MHz on the real memory map.

Pushbutton

A 12 mm tactile switch. Hold it while the simulation runs.

Raspberry Pi Pico

The RP2040 board on our own Cortex-M0+ core. Pick a program and press Run.

Raspberry Pi Pico W

Raspberry Pi Pico W (RP2040). The same board and the same pinout as a Pico, with the CYW43439 on it. The WiFi is simulated (no radio; real internet through the Cloud panel’s switch), and the on-board LED, which hangs off that chip rather than off GP25, is driven through the same path. Everything else is the Pico.

Raspberry Pi 4 Model B

Raspberry Pi 4 Model B: the 40-pin header, driven by main.py with RPi.GPIO or gpiozero.

See every part

## Wire up the Flame sensor

Open the editor and push it into the breadboard. It is free, and it runs on your own machine.

Start building free Open the editor
