Make A Simple Fire Alarm With Raspberry Pi Pico

Hello, in this article we will make a fire alarm with Raspberry Pi Pico. As you know, fire emits infrared light and it is possible to detect this light with infrared sensors. That’s why we will use an infrared fire sensor in our project. Also a buzzer will be used as an audible warning when fire is detected. The materials required for our project are as follows:

1x Raspberry Pi
1xKY-26 Flame Sensor
1xBuzzer
and enough cables.

Connect the parts used in the project together as shown in the diagram given below.

Project Connection Diagram

You need to connect the AO output of KY-26 Flame Sensor to GPIO 28 pin on Raspberry Pi Pico and the buzzer to GPIO 17 pin. You can also use the VBUS pin to connect 5V energy for the KY-26 Flame Sensor.

After making the pin connections, open Thonny Python Editor, copy and paste the code below on a new page and run it.

import RPi.GPIO as GPIO
import time

# Set the GPIO pin numbers for the fire sensor digital output and the buzzer
fire_pin = 28
buzzer_pin = 17

# Set up the GPIO pins for input and output
GPIO.setmode(GPIO.BCM)
GPIO.setup(fire_pin, GPIO.IN)
GPIO.setup(buzzer_pin, GPIO.OUT)

# Loop cycle forever
while True:
    # Read the digital output of the fire sensor
    fire_detected = GPIO.input(fire_pin)

    # If a fire is detected, activate the alarm
    if fire_detected:
        print("Fire detected!")
        GPIO.output(buzzer_pin, GPIO.HIGH)
        time.sleep(0.3)
        GPIO.output(buzzer_pin, GPIO.LOW)
        time.sleep(0.3)
        GPIO.output(buzzer_pin, GPIO.HIGH)
        time.sleep(0.3)
        GPIO.output(buzzer_pin, GPIO.LOW)

    # Wait for a short time before reading the sensor again
    time. Sleep(0.1)

With this code, the buzzer will activate for half a second whenever a fire is detected. Note that you may want to adjust the volume of the buzzer or add additional components to increase the volume or range of the alarm.

In the developed version of the project, using Raspberry Pi Pico W, a notification can be sent to a mobile phone via IOT or an e-mail can be sent to a certain e-mail address. Maybe I can make these improvements in one of the next projects.
If you like the project, you can write a comment and share it with your friends. You can tell about the project in the comments section without any hesitation. Thank you for reading.

Leave a Reply

Your email address will not be published. Required fields are marked *