Site Tools


Sidebar

Content

pub:flame_sensor

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
+ VCC
- GND



Microbit

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

connection diagram:

Code:
makecode


Mu Python:

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

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:



Arduino

Components
- 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 +
GND -

Code:

 /***********************************************************
File name:   _22_FlameSensorModule.ino
Description: The information of flame sensor module has been
             detected by UNO R3,and displayed in the serial monitor 
Website: www.adeept.com
E-mail: support@adeept.com
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() 
{
  if(digitalRead(flamesensorSPin)==1){
    Serial.print("No flame .   Flame intensity:"); //send data to the serial monitor
  }else{
    Serial.print("Flame    .   Flame intensity:");   //send data to the serial monitor
  }
  Serial.println(analogRead(0));         //send analog data(A pin) to the serial monitor
  delay(50);
}

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

Components
- 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     : www.adeept.com
* E-mail      : support@adeept.com
* 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)
{
	//10:CH0
	//11:CH1
	uchar i;
	uchar dat1=0, dat2=0;
 
	digitalWrite(ADC_CS, 0);
 
	digitalWrite(ADC_CLK,0);
	digitalWrite(ADC_DIO,1);	delayMicroseconds(2);
	digitalWrite(ADC_CLK,1);	delayMicroseconds(2);
	digitalWrite(ADC_CLK,0);
 
	digitalWrite(ADC_DIO,1);    delayMicroseconds(2);
	digitalWrite(ADC_CLK,1);	delayMicroseconds(2);
	digitalWrite(ADC_CLK,0);
 
	digitalWrite(ADC_DIO,0);	delayMicroseconds(2); //CH0
	digitalWrite(ADC_CLK,1);
	digitalWrite(ADC_DIO,1);    delayMicroseconds(2);
	digitalWrite(ADC_CLK,0);
	digitalWrite(ADC_DIO,1);    delayMicroseconds(2);
 
	for(i=0;i<8;i++)
	{
		digitalWrite(ADC_CLK,1);	delayMicroseconds(2);
		digitalWrite(ADC_CLK,0);    delayMicroseconds(2);
 
		pinMode(ADC_DIO, INPUT);
		dat1=dat1<<1 | digitalRead(ADC_DIO);
	}
 
	for(i=0;i<8;i++)
	{
		dat2 = dat2 | ((uchar)(digitalRead(ADC_DIO))<<i);
		digitalWrite(ADC_CLK,1); 	delayMicroseconds(2);
		digitalWrite(ADC_CLK,0);    delayMicroseconds(2);
	}
 
	digitalWrite(ADC_CS,1);
 
	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;
	}
 
	while(1){
		res = get_ADC_Result();
		printf("analog = %d\n", res);
		delay(100);
	}
 
	return 0;
}
#!/usr/bin/env python
import RPi.GPIO as GPIO
import ADC0832
import time
 
FlamePin_S = 15
 
def init():
	GPIO.setmode(GPIO.BOARD)	
	GPIO.setup(FlamePin_S, GPIO.IN, pull_up_down=GPIO.PUD_UP)
	GPIO.add_event_detect(FlamePin_S, GPIO.FALLING, callback=myISR)
	ADC0832.setup()
 
def myISR(ev=None):
	print "Flame is detected !"
 
def loop():
	while True:
		res = ADC0832.getResult()
		print 'res = %d' %res
		time.sleep(0.1)
 
if __name__ == '__main__':
	init()
	try:
		loop()
	except KeyboardInterrupt:
		GPIO.cleanup()
		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/17_flame.py)

Step 3: Run

$ sudo python 17_flame.py

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:http://www.adeept.com/learn/ Download the kit information as needed.
Video link:http://www.adeept.com/video/

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