Site Tools




Flame Sensor

what's flame sensor
The Flame Sensor detects flames by the special infrared receiver to capture the infrared rays of a specific wavelength in the flames. It supports a detection angle of as high as 60 degrees and works within -25 - 85℃. When in use, you need to pay attention and do not place the probe of the sensor too close to the flames in case of damages. Besides, the sensor can be used to detect light intensity. It can detect a light source with a wavelength of 760 - 1100nm. Pin A outputs the analog data collected by the sensor. You can adjust the potentiometer on the module to set the alarm threshold of the sensor. So when the value reaches the threshold, pin S will switch between High and Low.

S Digital Output
A Analog Output


1 * microbit
1 * microbit expansion board
1 * USB cable
1 * Flame Sensor
1 * Lighter with visible flame or match
- Several Jumper wires

connection diagram:


Mu Python:

# File name   : Fire
# Description : When there is fire, the motor turns to extinguish the fire.
# Author      : jason
# E-mail      :
# Website     :
# Date        : 2019/01/11
from microbit import *
while True:
    Flame = pin0.read_analog()

Click “flash” and download the code onto the micro:bit. The flame sensor, as its name suggests, is most sensitive to the flame, of course, it also responds to ordinary light. We can see the changes of data clearly on the serial monitor when we put the flame of the lighter close to the flame sensor.
Effect Picture:


- 1 * Adeept Arduino UNO R3 Board
- 1 * Flame Sensor Module
- 1 * USB Cable
- 1 * 4-Pin Wires

Build the circuit

Adeept UNO R3 Board Flame Sensor Module
D8 S
A0 A
5V +


File name:   _22_FlameSensorModule.ino
Description: The information of flame sensor module has been
             detected by UNO R3,and displayed in the serial monitor 
Author: Tom
Date: 2019/01/11 
int flamesensorSPin = 8;//connect S pin to digital 8 pin 
int flamesensorAPin = 0;//connect A pin to analog 0 pin
void setup() 
  pinMode(flamesensorSPin,INPUT);//initialize the flame sensor S pin as input
  pinMode(flamesensorAPin,INPUT);//initialize the flame sensor A pin as input
  Serial.begin(9600);   // opens serial port, sets data rate to 9600 bps
void loop() 
    Serial.print("No flame .   Flame intensity:"); //send data to the serial monitor
    Serial.print("Flame    .   Flame intensity:");   //send data to the serial monitor
  Serial.println(analogRead(0));         //send analog data(A pin) to the serial monitor

Compile and download the sketch to the UNO R3 board.

Open the Serial Monitor in Arduino IDE. Then you'll see the data detected by the Flame Sensor module on the window. The data includes two parts: “Flame”/“No flame” and “Flame intensity”.

Raspberry pi

- 1 * Raspberry Pi
- 1 * GPIO Extension Board
- 1 * 40-Pin GPIO Cable
- 1 * Breadboard
- 1 * ADC0832 Module
- 1 * Flame Sensor Moule
- 1 * 3-Pin Wires
- 1 * 4-Pin Wires
- 1 * 5-Pin Wires

Build the circuit

C code:

* File name   : flame.c
* Description : fire detection
* Website     :
* E-mail      :
* Author      : Jason
* Date        : 2019/01/11
#include <wiringPi.h>
#include <stdio.h>
typedef unsigned int  uint;
typedef unsigned char uchar;
#define     ADC_CS    0
#define     ADC_DIO   1
#define     ADC_CLK   2
#define     Flame_S   3
uchar get_ADC_Result(void)
	uchar i;
	uchar dat1=0, dat2=0;
	digitalWrite(ADC_CS, 0);
	digitalWrite(ADC_DIO,1);	delayMicroseconds(2);
	digitalWrite(ADC_CLK,1);	delayMicroseconds(2);
	digitalWrite(ADC_DIO,1);    delayMicroseconds(2);
	digitalWrite(ADC_CLK,1);	delayMicroseconds(2);
	digitalWrite(ADC_DIO,0);	delayMicroseconds(2); //CH0
	digitalWrite(ADC_DIO,1);    delayMicroseconds(2);
	digitalWrite(ADC_DIO,1);    delayMicroseconds(2);
		digitalWrite(ADC_CLK,1);	delayMicroseconds(2);
		digitalWrite(ADC_CLK,0);    delayMicroseconds(2);
		pinMode(ADC_DIO, INPUT);
		dat1=dat1<<1 | digitalRead(ADC_DIO);
		dat2 = dat2 | ((uchar)(digitalRead(ADC_DIO))<<i);
		digitalWrite(ADC_CLK,1); 	delayMicroseconds(2);
		digitalWrite(ADC_CLK,0);    delayMicroseconds(2);
	pinMode(ADC_DIO, OUTPUT);
	return(dat1==dat2) ? dat1 : 0;
void myISR(void)
	printf("Fire detected !!!\n");	
int main(void)
	int res;
	if(wiringPiSetup() == -1){
		printf("setup wiringPi failed !\n");
		return -1; 
	pinMode(Flame_S, INPUT);
	pinMode(ADC_CS,  OUTPUT);
	pinMode(ADC_CLK, OUTPUT);
	pullUpDnControl(Flame_S, PUD_UP);
	if(wiringPiISR(Flame_S, INT_EDGE_FALLING, myISR) < 0){
		printf("ISR setup error!\n");
		return -1;
		res = get_ADC_Result();
		printf("analog = %d\n", res);
	return 0;
#!/usr/bin/env python
import RPi.GPIO as GPIO
import ADC0832
import time
FlamePin_S = 15
def init():
	GPIO.setup(FlamePin_S, GPIO.IN, pull_up_down=GPIO.PUD_UP)
	GPIO.add_event_detect(FlamePin_S, GPIO.FALLING, callback=myISR)
def myISR(ev=None):
	print "Flame is detected !"
def loop():
	while True:
		res = ADC0832.getResult()
		print 'res = %d' %res
if __name__ == '__main__':
	except KeyboardInterrupt:
		print 'The end !'

For C language users:

Step 2: Edit and save the code with vim or nano.

(code path: /home/Adeept_Sensor_Kit_for_RPi_C_Code/17_flame/flame.c)

Step 3: Compile

$ sudo gcc flame.c -o flame -lwiringPi

Step 4: Run

$ sudo ./flame

For Python users:

Step 2: Edit and save the code with vim or nano.

(code path: /home/Adeept_Sensor_Kit_for_RPi_Python_Code/

Step 3: Run

$ sudo python

Then you'll see the data detected by the Flame Sensor module on the terminal. The data

includes two parts: “ Fire detected or not !!! ” and “Flame intensity”.

Link for code download: Download the kit information as needed.
Video link:

pub/flame_sensor.txt · Last modified: 2019/01/11 18:32 by Adeept