1. Introduction
A flame sensor is used to detect fire or flame using infrared light emitted by fire. It is commonly used in fire detection and safety systems. This sensor helps in early fire detection and alert systems.
2. Components
- Raspberry Pi
- Flame Sensor Module
- LED
- 220Ω Resistor
- Breadboard
- Jumper Wires
3. Circuit and connections
| Raspberry Pi Pinout Diagram |

Pinout Diagram Flame Sensor
Connections:
- VCC → 3.3V (Pin 1)
- GND → GND (Pin 6)
- DO → GPIO17 (Pin 11)
- LED + → GPIO18 (Pin 12)
- LED – → GND (via 220Ω resistor)
4. Detailed Step By Step Circuit working
- Flame sensor detects infrared light from fire
- When flame is present → sensor output changes
- Digital output (DO) becomes LOW (in most modules)
- Raspberry Pi reads signal from GPIO17
- When flame detected → LED turns ON
- When no flame → LED OFF
5. Libraries to be included
import RPi.GPIO as GPIO
import time
6. Code
import RPi.GPIO as GPIO
import time
flame = 17
led = 18
GPIO.setmode(GPIO.BCM)
GPIO.setup(flame, GPIO.IN)
GPIO.setup(led, GPIO.OUT)
while True:
if GPIO.input(flame) == 0: # Flame detected
GPIO.output(led, True)
print("Flame Detected!")
else:
GPIO.output(led, False)
time.sleep(0.1)
7. Detailed Step By Step Code working
- Import GPIO and time libraries
- Assign flame sensor to GPIO17
- Assign LED to GPIO18
- Set GPIO mode to BCM
- Set flame sensor as input
- Set LED as output
- Read sensor value using GPIO.input()
- If LOW → flame detected → LED ON
- Else → LED OFF
- Add delay for stability
8. Tips
- Adjust sensitivity using onboard potentiometer
- Avoid sunlight interference
- Test with safe flame (like candle)
- Keep proper distance from flame
9. Uses
- Fire alarm systems
- Industrial safety systems
- Fire detection robots
- Smart safety devices
10. Conclusion
The flame sensor is a useful safety component for detecting fire. This project helps in building simple fire alert systems using Raspberry Pi.