Phillip MouaLarry Saavedra

Smart Door Motion Sensor

This is a generic sensor that anyone can adapt and use for their particular situation.

BeginnerShowcase (no instructions)3 hours1,123
Smart Door Motion Sensor

Things used in this project


Read more


Motion sensor schematic

This is the bread board diagram. It shows how to set up the motion sensor with the particle photon.

Buzzer schematic

This is the bread board diagram for the buzzer. This shows you how to set up the buzzer with the particle photon.

Chart shows when motion sensor was triggered (Google sheets)

In this case 1 means that motion was detected, 0 is when no motion is detected.

Chart shows when motion sensor was triggered (console)

Legend is on chart. The chart shows when motion sensor was triggered, and when no motion was detected.

Motion Sensor and Buzzer

This is the motion sensor and buzzer alarm connected together. The motion sensor is attached to the primary Photon which communicates to the receiver Photon. The receiver Photon sends a signal to the buzzer which works as an alarm.


Door sensor code

This code is for the main motion sensor particle photon, it declares pins for set up. It also dictates the LED to turn on when it detects motion, and publishes particle data to the cloud for communication with the other particle photon.
int ledPin = D4;                 // PIN chosen for LED 
int inputPin = D1;             // Chosen pin for motion sensor reciever


void setup() {
  pinMode(ledPin, OUTPUT);       // Sets the output for the led
  pinMode(inputPin, INPUT);     //set input as input


void loop() {
  if (digitalRead(inputPin) == HIGH) {  // checks if the motion sensor output is on HIGH
    digitalWrite(ledPin, HIGH);         // tells the code to turn the led on, if HIGH
   Particle.publish("motion_detected", "1" );    //someone's at door
  } else {
    digitalWrite(ledPin, LOW); // turns LED OFF if no input
    Particle.publish("no_motion", "0");
  delay(3000);                           // wait 3.0s

Reciever code

The following code is for the reciever, it subscribes to the main motion sensor particle photon. It searches for any state change, turns led/buzzer on or off depending on the situation.
int led=D2;           // Sets pin for LED 

int person_moving;

void setup() {

     digitalWrite(led,LOW);                                              //sets D2 to LOW
     Particle.subscribe("motion_detected",led_on, "590034000a51353531343431");    // communicates with  motion sensor to see if motion is detected
     Particle.subscribe("no_motion",led_off, "590034000a51353531343431");  // communicated to motion sensor to see if no motion is detected
     Particle.variable("person_door", person_moving);                 // creates a variable for whether or not there is motion


void led_on(const char *event, const char *data) {
 digitalWrite(led,HIGH);                                                // if any motion is detected, LED is turned on

void led_off(const char *event, const char *data) {                     // if no motion is detected, LED is off
void loop() {


Phillip Moua

Phillip Moua

1 project • 0 followers
UNC Charlotte Engineering Student
Larry Saavedra

Larry Saavedra

1 project • 1 follower


Add projectSign up / Login