Corey HallJustin Ashby
Created November 13, 2018

Motion Detected

Tired of running to your mailbox only to see that the mail hasn't been delivered? This project will send mail updates to your phone!

15
Motion Detected

Things used in this project

Hardware components

Photon
Particle Photon
×2
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
×1
Grove - mini PIR motion sensor
Seeed Studio Grove - mini PIR motion sensor
×1
5 mm LED: Green
5 mm LED: Green
×1
Solderless Breadboard Half Size
Solderless Breadboard Half Size
×2

Software apps and online services

Particle Web IDE
IFTTT Particle Service
Google Sheets
Google Sheets

Story

Read more

Schematics

PIR Schematic

How to connect PIR sensor to Particle Photon

Breadboard Set Up

Code

Second Photon

C/C++
This code will subscribe the second photon to the event published by the first. It will take the data that is recorded and then send a text message alerting the user of the motion detected
 int LED = D2;
 
void setup()
{{
  Particle.subscribe("Got_Mail", mail, "3b003e001147343438323536");
  
 } 
 
  pinMode(LED, OUTPUT);    // sets pin as output
}





void mail(const char *event, const char *data){
    
  
   if (String(event)=="Got_Mail"){
        Particle.publish("Mail_Here");

}

}
    

    


void loop()
{
  
}

First Photon

C/C++
This is connected to the PIR sensor which triggers the motion and publishes the event.
#define PIR_PIN D0 
#define MIN_TIME_BETWEEN_TRIGGERS 2000  

void setup() {
   pinMode(PIR_PIN, INPUT); 
} 
void loop() { 
   
   if (digitalRead(PIR_PIN)) { 
       Particle.publish("Got_Mail","1"); 
       
       unsigned long motionTime = millis(); 
       
       while(millis() - motionTime < MIN_TIME_BETWEEN_TRIGGERS) { 
           if (digitalRead(PIR_PIN)) motionTime = millis(); 
       } 
   } 
}

Credits

Corey Hall

Corey Hall

1 project • 0 followers
Justin Ashby

Justin Ashby

0 projects • 0 followers

Comments