0

I have connected the Flame Sensor with the Raspberry Pi,

This is my connections,

Flame Sensor has 3pins, VCC, Ground and D0 (Digital Output).

VCC is connected to 5 volts (the range is 3.3Volts to 5volts) GND is connected to the Ground. and D0 is connected to the GPIO4.

A resistor is connected between the signal pin and the ground.

The output is either 1 or a 0.

Here is my code for the sensor Flame detection,

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(7,GPIO.IN)
input = GPIO.input(7)
while True:
  if (GPIO.input(7)):
    print("Flame Detected")
  else:
    print("Not Detected")

I want to know if I write the code correctly ? Because, even if I put the Flame sensor close to the Flame it still gives the output as "Not Detected".

It is the link for the Sensor Datasheet, http://www.fut-electronics.com/wp-content/plugins/fe_downloads/Uploads/Flame-sensor-arduino.pdf

6

You said you are using GPIO4, you are reading GPIO7. The code should read:

import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(4,GPIO.IN)
input = GPIO.input(4)
while True:
  if (GPIO.input(4)):
    print("Flame Detected")
  else:
    print("Not Detected")

Also Vcc should probably be connected to 3.3v, otherwise D0 may push 5v into the GPIO, which is not 5v tollerant!

| improve this answer | |
-1

If you are working with Flame sensor with 4 leg which is A0 & D0 it will not gives you output from above code... for reading these values it may be use ADS.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.