Krista BryanEthan Johnson
Published

The Fire Alert System

The Fire Alert System detects fires and immediately alerts the operator. The operator can then send a message back that help is on the way.

BeginnerWork in progress2 hours172
The Fire Alert System

Things used in this project

Hardware components

Argon
Particle Argon
×2
Elegoo Flame Sensor Module
×1
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×2
Breadboard (generic)
Breadboard (generic)
×2
SparkFun COM-10969 | Resistor Kit - 1/4W (500 Total) - 0 ohm resistor
×5
SparkFun COM-10969 | Resistor Kit - 1/4W (500 Total) - 100 ohm resistor
×1
LED (generic)
LED (generic)
×4
Jumper wires (generic)
Jumper wires (generic)
×1
Pushbutton switch 12mm
SparkFun Pushbutton switch 12mm
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
Microsoft Excel

Hand tools and fabrication machines

Bic Pocket Lighter

Story

Read more

Schematics

Argon1

Key:
Red wires -- positive voltage
Black wires -- ground
Yellow wires -- analog signal
Blue wires -- mixed signal

Red circle -- red LED
Green circle -- green LED
Red bar with black circle -- Flame sensor
Grey square with black circle -- button
Yellow rectangle with markings -- resistor

Argon2

Code

Argon1 -- Flame Detector

C/C++
//this is Argon1, the argon used in the room where fire is being detected. It sends alerts to an external operator (Argon2) in which the operator can send help.
int ledAlert = D0; //red LED
int ledStandby = D7; //blue LED built in
int ledHelp = D4; //green LED

int sensor = A5; //analog pinout for flame detector

int detect = 0; //sets initial analog value of fire to zero
 
bool fire = false; //sets initial status of fire to no fire

void setup(){ //sets up the pinouts and subscribes to information
    Serial.begin(9600); //necessary for code to function
    pinMode(ledAlert, OUTPUT); //red LED alerts the victim there is a fire
    pinMode(ledStandby, OUTPUT); //blue LED remains on when there is no fire to reassure that the system is functional
    pinMode(sensor, INPUT); //analog input from flame sensor
    pinMode(ledHelp,OUTPUT); //the help signal that help is on the way (green LED)
    Particle.variable("detect",detect); //claims a variable for the flame intensity values
    Particle.subscribe("ActionLine",actionLine); //subscribes to Argon2's messages in the console
}


void loop(){ //loops this code over and over
    detect = analogRead(sensor); //reads analog input from flame detector
    if(detect <= 2000 && fire == false){ //if there is now a new fire detected -- turn alert LED on and send message to console. Argon2 will interpet those messages and alert the operator
        String num = String(detect); //integer becomes string for publishing requirements
        digitalWrite(ledAlert, HIGH); //turns on red LED
        digitalWrite(ledStandby, LOW); //turns off the standby LED to again reassure the system is operational and that the red LED turning on is not a joke or malfunction
        Particle.publish("Fire_Sensor","on_fire",PRIVATE); //sends message to console that there is a fire
        Particle.publish("Fire_Value",num,PRIVATE); //provides the intensity of the fire via analog input
        fire = true; //sets the variable to true for fire
        delay(2000); //2 second delay to prevent overloading the console with messages
    }
    if(fire == true && detect >= 2000){ //if there is no longer a fire -- turn everything off/back to standby
        Particle.publish("Fire_Sensor", "not_on_fire", PRIVATE); //message the console that there is no fire
        digitalWrite(ledAlert, LOW); //turns off red LED
        digitalWrite(ledStandby, HIGH); //turns on standby LED
        fire = false; //sets variable for not a fire
    }
}

void actionLine(const char *event, const char *data){ //pulls data for use
    if(strcmp(data,"Help_is_on_the_way")==0){ //checks dataset to see if the message "Help_is_on_the_way" was sent
        digitalWrite(ledHelp, HIGH); //if true, turn on the green LED to tell the victim 
        delay(5000); //LED remains on for 5 seconds
        digitalWrite(ledHelp,LOW); //turn the LED off to prevent it from staying on forever
    }
}   

//__________________________bottom of code_____________________________________

Argon2 -- Operator

C/C++
//this is Argon2, the argon used by the safety operator in order to send help

int ledRed = D2;//d output -- red LED alerts the operator there is a fire as detected by the argon in the room
int button = D0;//d input (bottommost input on d port side)

void setup() {
    Particle.subscribe("Fire_Sensor",isThereFire); //pulls published data from the fire sensor
    pinMode(ledRed, OUTPUT); //establishes purpose of pinouts
    pinMode(button, INPUT);  //reciever for button impulses. There's also a blue LED that turns on when the button is pressed to confirm with the operator that it worked.
    Serial.begin(9600); //necessary for code to work
}

void loop() {
    if(digitalRead(button) == HIGH){ //if the button is pressed
        Particle.publish("ActionLine","Help_is_on_the_way",PRIVATE); //sends message to console, Argon1 then reads it and turns on Argon1's green LED 
        delay(2000); //wait 2 seconds before running the loop again. This prevents the system from spamming messages from single button impulses
    }
}


void isThereFire(const char *event, const char *data){ //chooses directory of data that we previously subscribed to
    if(strcmp(data,"on_fire")==0){ //checks to see if the value provided from the data matches "on_fire"
        digitalWrite(ledRed, HIGH); //if the values match, turn the LED on to tell the operator there's a fire
    }else if(strcmp(data,"not_on_fire")==0){ //this runs if the above is not true
        digitalWrite(ledRed,LOW); //turns the light off if it is on
    }
}

//_____________________________bottom of code_________________________________________________

Credits

Krista Bryan

Krista Bryan

1 project • 1 follower
Ethan Johnson

Ethan Johnson

0 projects • 1 follower

Comments

Add projectSign up / Login