Things used in this project

Hardware components:
11026 02
Jumper wires (generic)
×1
826 04
Male/Female Jumper Wires
×1
Adafruit industries ada64 image 75px
Solderless Breadboard Half Size
×1
Kidde i9040 9V Ionization Smoke Detector
×1
Soldering Iron
×1
Electrical Solder
×1
Mfr 25frf52 1k sml
Resistor 1k ohm
×1
Mfr 25fbf52 4k75 sml
Resistor 4.75k ohm
×1
Mfr 25fbf52 475r sml
Resistor 475 ohm
×1
Photon new
Particle Photon
×1
Vishay semiconductor ild74 image 75px
Opto-Isolator
×1
Multimeter
×1
USB Power Supply
×1
PCB Project Board
×1
Software apps and online services:
Pushbullet
Q8wtlimqnp04fzhtr9v5
IFTTT Maker service

Schematics

Cicuit Diagram
Circuit Made in Fritzing
Fritzing fmjxopiatu
Schematic
Photon/Opto Schematic
Camera capture eo5us0fiw7

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 CodeC/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

Img 20170204 152218 354 pymil8cfai
Kathryn Lawther

Mechanical Engineering Student @ UNCC with a focus in Motorsports

Contact

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Other Clocks
Intermediate
  • 183
  • 3

Work in progress

A combination of 3 different clocks in one frame.

ConnectTheDots with Particle Azure IoT Hub Integration
Intermediate
  • 554
  • 6

Protip

This project will allow you to connect your Particle device into an Azure IoT Hub for viewing data in real-time through an ASP.NET web app!

Weather Aware Sprinkler Controller
Intermediate
  • 1,291
  • 16

Full instructions

6 station Photon controller uses the Weather Underground API to prevent watering when windy, rainy, or too cold.

Christmas Gift Box
Intermediate
  • 3,602
  • 595

Full instructions

Christmas Gift Box plays music and sends an email when it is opened.

Simple Environmental Monitoring
Intermediate
  • 1,536
  • 13

Full instructions

Particle Photon circuit allowing the display of environmental conditions (light, temperature, humidity, pressure) using the Blynk app.

THDweeter
Intermediate
  • 245
  • 2

Protip

Yet another temperature-humidity sensor publishing to dweeter, with WiFi auto-disconnect and a push button to read daily max and min values.

Add projectSign up / Login