This guide will help you create an IoT-Based Fire Department Alerting System using Raspberry Pi. The system will detect fire incidents through smoke and temperature sensors and send automatic notifications to the fire department for prompt response.

Components Required

  • Raspberry Pi (Model 3 or later)
  • Smoke detector sensor
  • Temperature sensor (e.g., DHT11 or DHT22)
  • Relay module (for activating alarms or notifications)
  • Connecting wires and breadboard
  • Power supply (for Raspberry Pi and sensors)
  • Cloud service account (e.g., ThingSpeak, Blynk, or AWS IoT)
  • Notification system (e.g., email or SMS service)

Setting Up the Hardware

Follow these steps to set up the hardware:

  1. Connect the Smoke and Temperature Sensors

    Connect the smoke detector and temperature sensor to the Raspberry Pi using the GPIO pins. Ensure the sensors are properly calibrated and positioned for effective detection.

  2. Integrate the Relay Module

    Connect the relay module to the Raspberry Pi. The relay can be used to trigger alarms or notifications when a fire is detected.

  3. Power the System

    Ensure the Raspberry Pi and sensors are powered using appropriate power supplies. Check all connections before powering on.

Programming the Raspberry Pi

Write the code to monitor sensor data and send alerts when fire conditions are detected. Below is an example code using Python:


                import RPi.GPIO as GPIO
                import time
                import requests
                from Adafruit_DHT import DHT22, read_retry

                # Configuration
                SMOKE_SENSOR_PIN = 17
                TEMP_SENSOR_PIN = 4
                RELAY_PIN = 23
                CLOUD_URL = "https://api.thingspeak.com/update?api_key=YOUR_API_KEY"
                ALERT_EMAIL_URL = "https://api.emailservice.com/send?api_key=YOUR_API_KEY"

                # Setup
                GPIO.setmode(GPIO.BCM)
                GPIO.setup(SMOKE_SENSOR_PIN, GPIO.IN)
                GPIO.setup(RELAY_PIN, GPIO.OUT)
                
                def send_alert():
                    response = requests.get(ALERT_EMAIL_URL + "&message=Fire detected!")
                    print(f"Alert sent: {response.status_code}")

                def check_sensors():
                    humidity, temperature = read_retry(DHT22, TEMP_SENSOR_PIN)
                    smoke_detected = GPIO.input(SMOKE_SENSOR_PIN)
                    return smoke_detected, temperature

                try:
                    while True:
                        smoke, temp = check_sensors()
                        if smoke or temp > 30:  # Example temperature threshold
                            print("Fire detected!")
                            GPIO.output(RELAY_PIN, GPIO.HIGH)
                            send_alert()
                            time.sleep(10)  # Wait before next check
                        else:
                            GPIO.output(RELAY_PIN, GPIO.LOW)
                        time.sleep(5)  # Adjust as necessary

                except KeyboardInterrupt:
                    GPIO.cleanup()
            

This code monitors the smoke and temperature sensors. If a fire is detected (based on smoke or high temperature), it triggers the relay and sends an alert to the cloud and the fire department.

Setting Up Cloud Integration

To handle alerts and notifications, integrate your system with a cloud service. Configure your cloud service to receive data from the Raspberry Pi and set up notifications or alerts based on the data received. Use an email or SMS service to notify the fire department immediately.

Testing and Calibration

Test the system by simulating smoke and high temperature conditions to ensure that alerts are correctly sent and the relay triggers as expected. Adjust the sensor thresholds and code parameters as needed for reliable performance.

Conclusion

The IoT-Based Fire Department Alerting System provides an efficient solution for detecting fire incidents and notifying the fire department. By integrating smoke and temperature sensors with Raspberry Pi and cloud services, this system enhances fire safety through timely alerts and automated response.