Flame sensor

The flame sensor module, KY-026 style: a black infrared receiver standing off the end of an LM393 comparator board. Aliases: fire sensor, IR flame sensor.

What it sees is not fire. It is light between about 760 and 1100 nm, the near infrared a flame gives off plenty of, through a black lens that blocks most visible light. The receiver is a phototransistor under a 10 k pull-up, so more infrared means a lower voltage on AO, and the comparator pulls DO low and lights its lamp when AO falls below the trimmer.

Pins

Pin What it does
AO The receiver under its pull-up: lower means more infrared.
GND Ground.
VCC Supply, 3.3 V to 5 V.
DO Low when a flame is close enough. Open collector with a 10 k pull-up.

Properties

threshold is the trimmer as a fraction of the supply, 0.5 by default.

While it runs

Drag the slider to bring a lighter's flame closer, from 150 cm (no flame) down to 5 cm. The flame drawn beside the receiver grows as it comes in.

What the model gets right

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.

What it does not model

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.

Common mistakes

Reading DO as "high means fire". It goes low on a flame.

Trusting it near a window. On a real bench it will see the sun.

See it in action

Comparator boards has a flame sensor lighting a lamp from DO, beside an MQ-2 and a TCRT5000. Open it at /templates.