vinh phanAndrés Miguel Arias
Published

Smart Smoke Detector

This smoke detector sends a notification to your phone when smoke has been detected, and you can open the solenoid valve by a SMS.

Intermediate4 hours386
Smart Smoke Detector

Things used in this project

Hardware components

Photon
Particle Photon
×2
SunFounder 2 Channel DC 5V Relay
×1
Water Solenoid Valve
×1
BRK 7010B Hardwire Smoke Alarm
×1

Software apps and online services

Maker service
IFTTT Maker service
Particle
Google Sheets
Google Sheets

Story

Read more

Schematics

The smoke detector circuit diagram

Smoke diagram lreaez4uoi

The relay and water valve circuit diagram

Water valve circuit b3xjitgsbt

Code

Smoke detector code

Arduino
const int sensorPin = D3;  
const int ledPin =  D7;
int rssi =0;

void setup()
{
  pinMode(sensorPin, INPUT);
  pinMode(ledPin, OUTPUT);
  Particle.publish("State", "0",PRIVATE);
  Particle.variable("RSSI", &rssi, INT);
}


void loop()
{
  int  sensorSignal; 
  int i;
  int j;
  int n=60; //Published Low state every 60 minutes
  int m=60; //Published WiFi strength every 60 seconds 

   for (i = 0; i < n; i++) 
   {
        for (j = 0; j < m; j++) 
        {
           sensorSignal = digitalRead(sensorPin);
           if ( sensorSignal == HIGH)  
           {
                digitalWrite(ledPin, HIGH); 
                Particle.publish("State", "1",PRIVATE);
                delay(15000);
            }
            else
            {
                digitalWrite(ledPin, LOW);
            }
            delay(1000);
        }
        rssi = WiFi.RSSI();
        Particle.publish("rssi", String(rssi), 60, PRIVATE);
   } 
  Particle.publish("State", "0",PRIVATE);
}

Relay and water solenoid valve

Arduino
int openValve(String command);
const int valvePin = D7;
int rssi =0;

void setup()
{
 
  Particle.function("valve", openValve);
  Particle.variable("RSSI", &rssi, INT);
  pinMode(D7, OUTPUT);
}

void loop()
{
    rssi = WiFi.RSSI();
    Particle.publish("rssi", String(rssi), 60, PRIVATE);
    delay(60000);
}

int openValve(String command)
{

  if(command == "open")
  {
   digitalWrite(valvePin, HIGH);
   delay(10000);
   digitalWrite(valvePin, LOW);
       Particle.publish("Reopen", "Reopen Valve",PRIVATE);
        delay(1000);
    return 1;
  }
  else return -1;
}

Credits

vinh phan

vinh phan

1 project • 0 followers
My name is Vinh Phan. I am an Engineering student at UNC Charlotte.
Contact
Andrés Miguel Arias

Andrés Miguel Arias

1 project • 0 followers
Contact

Comments