Christina CallahanTrenton Madden
Published

Home Motion Detector

This device is used to allow for active monitoring of an individuals home.

IntermediateShowcase (no instructions)916
Home Motion Detector

Story

Read more

Schematics

Device 1

This shows a particle photon receiving AC voltage.

Device 2

This shows the pinout for the particle photon and the passive infrared sensor (PIR).

Code

Device 1

C/C++
Device 1 subscribed to Device 2's particle.publish. This allowed for Device 2 to turn on its on-board LED located at D7 when the motion sensor attached to Device 1 triggered an event.
int led = D7;

void setup()
{
    pinMode(led,OUTPUT);
    digitalWrite(led,LOW);
    
Particle.subscribe("Motion", madden, "520034001451353432393433");

}

void madden(const char *event, const char *data)
{
 digitalWrite(led,HIGH);
}

Device 2

C/C++
Device 2 consisted of a particle photon and a PIR sensor. When the PIR sensor was triggered, it published an event that could be seen on the particle.io website as well as ThingSpeak.com.
int PIRSensor =D0;
int state =0;
int Motion =0;
int Power =0;

void myHandler(const char *event, const char *data) {
  // Handle the integration response
}

void setup(){
    
    pinMode(D7,OUTPUT);
    pinMode(PIRSensor,INPUT);

{
  // Subscribe to the integration response event
  Particle.subscribe("hook-response/Motion", myHandler);
}

}
  
  
void loop(){

{
  // Get some data
  String data = String(10);
  // Trigger the integration
  Particle.publish("Motion", data);
  // Wait 60 seconds
  delay(6000);
}
      
    

    if(Motion == HIGH){
        
        digitalWrite(D7,HIGH);
        Particle.publish("motion-detected");
    }

    else if (Motion==LOW){
        digitalWrite(D7,LOW);
        
    }
    

}

Credits

Christina Callahan

Christina Callahan

1 project • 1 follower
Trenton Madden

Trenton Madden

1 project • 2 followers

Comments