Software apps and online services

Story

The purpose of this project is to notify user(s) when a door has opened or closed a door by having a button mounted in the door frame. Once the button is released (the door has been opened), the first Particle Photon will send an event to the Particle Cloud, and the second photon will receive a signal that the notification has been published confirming a two-way communication between the photons. This event will the be subscribed by another Particle Photon as well as the Thingspeak graphing platform. A link to the live graph can be found below. Additionally, an SMS notification will be sent to the user(s) mobile device via the IFTTT app. We decided to create this product as an alert system for any home/apartment application, especially for when the user(s) is/are away from home. The user(s) may also log into Thingspeak where a live stream can be viewed of the system. The video below shows a demonstration of our device successfully working. Enjoy!

Schematics

Circuit Diagram

Code

Photon 1

C/C++

This code takes the input from the buttons (used as sensors to see when the doors are opened or closed) and uploads it to the cloud for the other photon to download and then graph.

// We will be using D1 to control our LEDintledPin=D1;intled=D7;intlasttime=0;// Our button wired to D0intbuttonPin=D0;voidsetup(){pinMode(buttonPin,INPUT_PULLUP);// sets pin as inputpinMode(led,OUTPUT);pinMode(ledPin,OUTPUT);// sets pin as outputParticle.subscribe("Task_Complete",anything,"200022001247343438323536");}voidloop(){// find out if the button is pushed// or not by reading from it.intbuttonState=digitalRead(buttonPin);if(buttonState==1){// turn the LED OndigitalWrite(ledPin,HIGH);}else{// otherwise// turn the LED OffdigitalWrite(ledPin,LOW);}if((lasttime==0)&&(buttonState==1)){// Send a publish...intsuccess=Particle.publish("Door_Status","1",PRIVATE);delay(2000);}else{// Otherwise, this isn't a new status, and we don't have to do anything.}if((lasttime==1)&&(buttonState==0)){// Send a publish...Particle.publish("Door_Status","0",PRIVATE);delay(2000);}else{// Otherwise, this isn't a new status, and we don't have to do anything.}lasttime=buttonState;}voidanything(constchar*event,constchar*data){digitalWrite(led,HIGH);delay(1000);digitalWrite(led,LOW);delay(1000);}

Photon 2

C/C++

This code pulls the data from the cloud and then blinks the on-board LED in pin D7 and graphs sensor data using the Blynk application.