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.
Disclaimer:
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:
- Raspberry PI 2
- Cobbler and Cobbler cable
- Flame sensor (They cost $22 Aliexpress for 10 pieces, ($2.2 a piece) where I got this sensor.
- Wiring PI Xojo module from Paul Lefebvre
First thing is connecting the 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.
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.SetupGPIO 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” return end if App.DoEvents(1) next End Sub
Thats all there is to it!
(Updated 18. Oct 2015, adding US-015 sensor and sensor specs)