Thomas KraseTyler Cheek
Published

Home Security System

This project lets users remotely lock and unlock a deadbolt to a door and record an intruder if the door is opened.

IntermediateShowcase (no instructions)2 hours793
Home Security System

Things used in this project

Hardware components

Photon
Particle Photon
×2
Standard Servo
×1
reed switch
×1
iPhone
Apple iPhone
The camera on the Iphone is utilized via manything app
×1

Software apps and online services

ThingSpeak API
ThingSpeak API
manything
Maker service
IFTTT Maker service
Mobicle
ControlEverything.com Mobicle

Story

Read more

Schematics

Door Position Vs. Time

Graphs the state of the door.
1 Represents Open, -1 Represents Closed

Main Photon Circuit

This circuit shows how the photon is connected to the servo motor and reed switch. The second photon is only used as a vessel of communication for ManyThing and ThingSpeak, therefore needing no circuit.

Welcome

components 1

components 2

Code

Turn Camera On

C/C++
Turns the phone camera on when door is open
int led = D7;


void setup() { 
    pinMode(led,OUTPUT); 
    digitalWrite(led,LOW);
    
    Particle.subscribe("OpenDoor", cameraon , "2e0021001951353337343731");    //subsribes from security camera photon when camera is on
    Particle.subscribe("ClosedDoor", cameraoff , "2e0021001951353337343731");
}

void cameraon(const char *event, const char *data)
{
    digitalWrite (led,HIGH);
    Particle.publish("Camera" , "CameraIsRecording" , PUBLIC);
}

void cameraoff(const char *event, const char *data)
{
    digitalWrite (led,LOW);
}

void loop() {

}

Reed Switch & Deadbolt Locker

C/C++
Controls the servo motor to lock/unlock the deadbolt and notifies second particle when door is open or close
Servo myservo; 
int pos = 0;                


void setup()
{
    Particle.function("lock", gong);
    myservo.attach(D0);                                    
    myservo.write(0);
    pinMode(D4, INPUT);
   
    
}



int gong(String command)
{                          
    if(command == "close")                                  
    {                            
     myservo.write(0);
    }
    else if(command == "open")
    {                               
     myservo.write(90);                             
     delay(1000);             
    }
  
}

void loop()
{
    if (digitalRead(D4) == HIGH)
    {
    String DoorOpen = String(1);
    Particle.publish("DoorOpen", DoorOpen , PRIVATE);
     Particle.publish("OpenDoor" , "Door is open" ,  PUBLIC);
     delay(5000);
    }
    
   
    if (digitalRead(D4) == LOW)
    {
        String DoorOpen = String(-1);
    Particle.publish("DoorOpen", DoorOpen , PRIVATE);
     Particle.publish("ClosedDoor" , "Door is closed" ,  PUBLIC);
    delay(5000);
    }
}

Credits

Thomas Krase

Thomas Krase

1 project • 0 followers
Tyler Cheek

Tyler Cheek

1 project • 0 followers

Comments