Flame sensor

In this example we are going to connect to flame sensor.

Programming for this sensor works on exactly the same principle as the HC-SR501 infrared sensor and the F85 vibration sensor except the signal from this sensor comes inverted. As in it will send 1 when everything is all right and zero if it sees flame.

I really liked this one, it  seemed to give very reliable readings when doing the lighter test with it.

We do not take any responsibility for possible errors in the guide or errors that you might do wiring it up. Incorrect wiring can result in damaged sensor or damaged Raspberry PI. If you light something on fire when doing flame test to test the sensor then thats your own fault and we are not responsible for that.

Pieces we use are:

First thing is connecting the sensor:

Flame sensor
Flame sensor

This sensor comes with good markings so its very easy to wire it.

  • (5V) Red is the 5V input – I always use red for the power input.
  • (GPIOX) Yellow is the Data pin.
  • (GND) Blue is the ground, I always use blue for ground.

Spec on this sensor is:

  • The working voltage of 3.3V to 5V
  • Output form: digital switch output (0 and 1)
  • Sensitivity adjustable digital potentiometer to adjust.
  • Detection Angle of 60 degrees or so, particularly sensitive to the flame spectrum.
  • Lighter flame test distance of 80 cm

The sensor will have red light showing that it is turned on, and green light also lights on it when it sees flame, making it send LOW signal, while when there is no flame it will be sending HIGH.

Connecting to the Cobbler:

Make sure your Raspberry PI is not powered on when you do the connections.

Cobbler for Raspberry PI

Cobbler for Raspberry PI

GPIO Header

In my example then I have it connected as follows:

  • Red to pin 2 (5V)
  • Blue to pin 25 (GND)
  • Yellow to GPIO 5 which is pin 29.

The Xojo code:

I have a timer to poll the sensor. we set the timer up and the pin mode in the Window Open event.

Sub Open()
Const kFlameSensorPin = 5
GPIO.PinMode(kFlameSensorPin, GPIO.INPUT)
Timer1.Mode = Timer.ModeMultiple
Timer1.Enabled = true
End Sub

In the Timer.Action event I got the following code:

(If you want it more responsive then you can increase the cycles of the for loop)

Sub Action()
Dim i as Integer
Const kFlameSensorPin = 5
for n as Integer = 1 to 10
i = GPIO.DigitalRead(kFlameSensorPin)
if i = 0 then // Note the zero here since the signal from this one is inverted.
Listbox1.AddRow “Flame detected”
end if
End Sub

Thats all there is to it!


(Updated 18. Oct 2015, adding US-015 sensor and sensor specs)


AliExpress.com Product – 2016 New Raspberry Pi 3 Model B 1GB RAM Quad Core 1.2GHz 64bit CPU WiFi & Bluetooth Third Generation Raspberry Pi Free Shipping

Leave a Reply

Einhugur technical blog that involves Xojo and Einhugur Xojo plugin related topics

%d bloggers like this: