Swayam Nagpal
Published

SmartFlame Alert

It is a compact, low-cost fire detection system that leverages the power of IoT to instantly detect and alert users about fire hazards.

IntermediateFull instructions provided50
SmartFlame Alert

Things used in this project

Hardware components

LED (generic)
LED (generic)
×1
Buzzer
Buzzer
×1
Temperature Sensor
Temperature Sensor
×1
Bolt WiFi Module
Bolt IoT Bolt WiFi Module
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1

Software apps and online services

Replit

Story

Read more

Schematics

Hardware

Code

#conf.py

Python
API_KEY = 'API'      # Replace with your actual Bolt Cloud API key
DEVICE_ID = 'ID'   # Replace with your actual Device ID

#main.py

Python
import conf
from boltiot import Bolt
import time
import json

bolt = Bolt(conf.API_KEY, conf.DEVICE_ID)
THRESHOLD_TEMP = 30.50

def get_temperature():
    response = bolt.analogRead('A0')
    data = json.loads(response)

    if not data["success"]:
        print("Error reading analog value:", data["value"])
        return None
    analog_value = int(data["value"])

    temp_c = analog_value/10.24
    return temp_c

while True:
    temperature = get_temperature()
    if temperature is None:
        continue

    print(f"Temperature: {temperature:.2f}°C")

    if temperature > THRESHOLD_TEMP:
        print("High temperature detected! Activating alarm.")
        bolt.analogWrite('4', 230)  # LED ON
        bolt.analogWrite('1', 230)  # Buzzer ON
        time.sleep(1)
        bolt.analogWrite('4', 0)   # LED OFF
        bolt.analogWrite('1', 0)   # Buzzer OFF
        time.sleep(1)
    else:
        print("Temperature normal. No alarm.")
        bolt.digitalWrite('4', 'LOW')   # Ensure OFF
        bolt.digitalWrite('1', 'LOW')   # Ensure OFF
        time.sleep(5)  # Less frequent checks when safe

Credits

Swayam Nagpal
1 project • 0 followers

Comments