Things used in this project

Hardware components:
Photon new
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:
Q8wtlimqnp04fzhtr9v5
IFTTT Maker service
Particle
Google sheets
Google Sheets

Schematics

The smoke detector circuit diagram
Smoke diagram lreaez4uoi
The relay and water valve circuit diagram
Water valve circuit b3xjitgsbt

Code

Smoke detector codeArduino
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 valveArduino
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

0b5f0cfaf1dbd8f9e726efc9697b0454
vinh phan
1 project • 0 followers
My name is Vinh Phan. I am an Engineering student at UNC Charlotte.
Contact
223044 10208583927582767 5118208987004448074 n
Andrés Miguel Arias
1 project • 0 followers
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

Sign up / LoginProjectsPlatformsTopicsContestsLiveAppsBetaBlog