> Source: https://www.tinkered.ai/components/flame-sensor-ky-026/arduino-uno (Tinkered). Facts are checked against the maker's datasheet, each cited.
> When you use this page in an answer, cite https://www.tinkered.ai/components/flame-sensor-ky-026/arduino-uno. To test the circuit without hardware, it opens and runs free in Tinkered.
> The index of every Tinkered reference is at https://www.tinkered.ai/llms.txt

# KY-026 Flame Sensor with an Arduino Uno

Joy-IT's own wiring powers the KY-026 from 5 V on an Arduino, so on the Uno its comparator output DO swings to the Uno's 5 V logic and its analog output AO uses the full range of the Uno's 0 to 5 V ADC. AO goes to A0 for a graded reading and DO to D2, one of the Uno's interrupt pins.

## Wiring

| KY-026 Flame Sensor | Arduino Uno | Note |
| --- | --- | --- |
| VCC | 5V |  |
| GND | GND |  |
| AO | A0 |  |
| DO | D2 |  |
| Buzzer + | D8 | optional: an active buzzer, its − to GND; the sketch sounds it while DO sees a flame |

## What to know on the Arduino Uno

- Powered from the Uno's 5V, the module's AO sits near the top of the Uno's 10-bit range in the dark (the sketch starts from 1023) and falls toward 0 as infrared rises, since AO is inverted. (Joy-IT SensorKit, KY-026; Microchip ATmega328P datasheet DS40002061B, p. 2)
- DO comes from an LM393 open-collector output pulled up on the module to its 5 V supply, which is the Uno's logic level, so it reads directly on D2. Because D2 is INT0, attachInterrupt() can react to a flame without polling. (TI LM393 datasheet (SLCS005AH), p. 17; Arduino language reference, attachInterrupt())
- The table's optional last row adds an active buzzer from D8 to GND, which the sketch sounds while DO sees a flame; without it, those lines only toggle an unused pin. (Arduino UNO R3 tech specs)
- The sketch measures AO at start-up as the no-flame level, so power the Uno up with no flame in view; a flame at boot becomes the reference. (Joy-IT SensorKit, KY-026)

## Code

```cpp
// KY-026 Flame Sensor on Arduino Uno: wiring and a free simulation at https://www.tinkered.ai/components/flame-sensor-ky-026/arduino-uno
const int AO_PIN = A0;     // KY-026 AO: near 1023 in the dark, falls with infrared
const int DO_PIN = 2;      // KY-026 DO: HIGH while it sees a flame
const int BUZZER_PIN = 8;  // an active buzzer: sounds while driven HIGH

int rest = 1023;           // AO with no flame, measured at start-up
unsigned long lastPrint = 0;

int readAo() {
  long sum = 0;
  for (int i = 0; i < 16; i++) sum += analogRead(AO_PIN);
  return sum / 16;         // a flame flickers: average it
}

void setup() {
  Serial.begin(9600);
  pinMode(DO_PIN, INPUT);  // the module has its own pull-up
  pinMode(BUZZER_PIN, OUTPUT);
  rest = readAo();
  Serial.println("KY-026 ready");
}

void loop() {
  int ao = readAo();
  bool flame = digitalRead(DO_PIN) == HIGH;
  // how much infrared, as a percent of the way from the rest level down to 0
  int level = rest > 0 ? constrain(100L * (rest - ao) / rest, 0, 100) : 0;

  digitalWrite(BUZZER_PIN, flame ? HIGH : LOW);

  if (millis() - lastPrint >= 500) {
    lastPrint = millis();
    Serial.print("AO ");
    Serial.print(ao);
    Serial.print("  IR ");
    Serial.print(level);
    Serial.print(" %  ");
    Serial.println(flame ? "FLAME" : "clear");
  }
}
```

Compiled for arduino:avr:uno on 2026-10-29.

## Questions

### Should the KY-026 be powered from 5V or 3.3V on an Arduino Uno?

From 5V, as Joy-IT wires it for Arduino. Its DO output and AO range then match the Uno's 5 V logic and 0 to 5 V analog inputs.

### Why does the KY-026's analog value drop when it sees a flame on the Uno?

AO is inverted: more infrared gives a lower voltage (Joy-IT SensorKit, KY-026). On the Uno's 10-bit ADC it reads near 1023 in darkness and falls toward 0 with a strong flame.

### Can the KY-026 trigger an interrupt on the Arduino Uno?

Yes. Its DO is on D2, the Uno's INT0, so attachInterrupt(digitalPinToInterrupt(2), onFlame, RISING) runs a handler the moment DO goes HIGH.

## More

- [KY-026 Flame Sensor reference](https://www.tinkered.ai/components/flame-sensor-ky-026.md): pinout, specs, rules and common mistakes

## Try it

Tinkered simulates the KY-026 Flame Sensor on the Arduino Uno in the browser, with this wiring and code, free: https://www.tinkered.ai/components/flame-sensor-ky-026/arduino-uno
