Benjamin GordonKathryn Lawther
Published

Alerts via Pushbullet When Smoke is Detected

This project uses two Particle Photons and Pushbullet to notify a user when smoke is detected by a smoke detector.

IntermediateFull instructions provided2 hours1,185
Alerts via Pushbullet When Smoke is Detected

Things used in this project

Hardware components

Jumper wires (generic)
Jumper wires (generic)
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×1
Kidde i9040 9V Ionization Smoke Detector
×1
Electrical Solder
×1
Resistor 1k ohm
Resistor 1k ohm
×1
Resistor 4.75k ohm
Resistor 4.75k ohm
×1
Resistor 475 ohm
Resistor 475 ohm
×1
Photon
Particle Photon
×1
Opto-Isolator
Opto-Isolator
×1
Multimeter
×1
USB Power Supply
×1
PCB Project Board
×1

Software apps and online services

Pushbullet
Maker service
IFTTT Maker service

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Cicuit Diagram

Circuit Made in Fritzing

Schematic

Photon/Opto Schematic

Code

Code for Photon 1 (in circuit)

C/C++
Code to notify Pushbullet, photon 2, and for graphing
#include "elapsedMillis/elapsedMillis.h"


#define SMOKE_READ_INTERVAL 1000


#define SMOKE_FIRST_ALARM 10000 //10 seconds
#define SMOKE_SECOND_ALARM 60000 //1 minute
#define SMOKE_THIRD_ALARM 300000 //5 minutes
#define SMOKE_FOURTH_ALARM 600000 //10 minutes
#define SMOKE_FIFTH_ALARM 900000 //15 minutes

#define SMOKE_NOTIF "SMOKE"

elapsedMillis smoke_timer;
elapsedMillis smoke_alarm_timer;

int smoke_alarms_array[5]={SMOKE_FIRST_ALARM, SMOKE_SECOND_ALARM, SMOKE_THIRD_ALARM, SMOKE_FOURTH_ALARM, SMOKE_FIFTH_ALARM};
int smoke_alarm_index = 0;
bool smoke_detected = false;
unsigned long smoke_next_alarm = 0;

int SMOKE_SENSOR = D7;


void setup() {
 pinMode(SMOKE_SENSOR, INPUT);
 


 
 
RGB.control(true);


RGB.brightness(0);


delay(1000);


RGB.control(false);

}

void loop() {
    

    smoke_check();
    
    if (smoke_detected) {
        smoke_notify_user();
    }
}

/*******************************************************************************
 * Function Name  : smoke_check
 * Description    : check smoke sensor at SMOKE_READ_INTERVAL, turns on led on D7 and raises alarm if smoke is detected
 * Return         : 0
 *******************************************************************************/
int smoke_check()
{
    if (smoke_timer < SMOKE_READ_INTERVAL) {
        return 0;
    }
    
    
    smoke_timer = 0;

    if (digitalRead(SMOKE_SENSOR)) {

        
        if (smoke_detected){
            return 0;
        }
        
        smoke_detected = true;
    
        
        smoke_alarm_timer = 0;

        
        smoke_alarm_index = 0;
        smoke_next_alarm = smoke_alarms_array[0];
        
    } else {
        
        smoke_detected = false;
    }
    return 0;
}

/*******************************************************************************
 * Function Name  : smoke_notify_user
 * Description    : will fire notifications to user at scheduled intervals
 * Return         : 0
 *******************************************************************************/
int smoke_notify_user()
{

    if (smoke_alarm_timer < smoke_next_alarm) {
        return 0;
    }

    
    
    smoke_alarm_timer = 0;
    
    
    if (smoke_alarm_index < arraySize(smoke_alarms_array)-1) {
        smoke_alarm_index = smoke_alarm_index + 1;
        smoke_next_alarm = smoke_alarms_array[smoke_alarm_index];
    }

    
    Particle.publish("smoke_has_been_detected_27", "Smoke detected! Save the cats!", 60);
    
    
    Particle.publish("pushbullet", "Smoke detected! Save the cats!", 60);
   
   return 0; 
}

Photon 2 D7 Flash Code

C/C++
Code to flash D7 when smoke alarm goes off
int boardLed = D7;


void setup()
{
    Particle.subscribe("smoke_has_been_detected_27", flickerled);
    Serial.begin(230400);
    pinMode(boardLed,OUTPUT); // Our on-board LED output
    Particle.subscribe("smoke_has_been_detected_27",button);
}
void flickerled (const char *event, const char *data)
{

    if(strcmp(data, "Smoke detected! Save the cats!")==0)
{
        digitalWrite(boardLed,HIGH);
        Serial.println("Smoke detected! Save the cats!");
}
}
void button(const char *event, const char *data)
{
    if(strcmp(data,"buttonpressed")==0)
    {
        digitalWrite(boardLed,LOW);
        delay(15000);
}
}

Credits

Benjamin Gordon

Benjamin Gordon

1 project • 0 followers
Kathryn Lawther

Kathryn Lawther

1 project • 1 follower
Mechanical Engineering Student @ UNCC with a focus in Motorsports

Comments