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.

Arduino Uno: flame sensorlive0.000 s 0.00x
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.

Boards

The boards it is shown on

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

Wire up the Flame sensor

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