So, at first, I work out with this project doesn't means somebody break into my room and I need to get him. The real reason why I build this trespasser detector is because I happen to have some reed switches and some magnets. So I want to build some thing funny. And then, I came up with this idea.
The theory of this project is pretty simple.
- Detect the status of the door correctly.
- Monitor the status of the button after detect the door was opened. 3. send out the information to cloud and get a Email says some one break into your room.
The way to detect the door status is easy. I use two reed switch and a magnet to detect the door status.
So, from this schematic. I can figure out that in default mode, both D0 and D1 are high, but if S1 or S2 pressed down. Then D0 or D1 will be low. So that means I can figure out which switch was activated at first by monitor which port (D0/D1) go low first. Suppose I first pressed the S1 and then pressed S2, that means the D0 will go low early than D1. So, we can define if D0 go low early than D1, that means Open the door, and if D1 go low first than D0, that means Close the door. Pretty simple, right!
So above is the theory of detecting the door status. But how can it be realized? We use reed switch to do that job. Reed switch is a switch that controlled by magnet. If there is a magnet close to the center contact area of that switch, the contact area will contact with each other, then, it act just like a normal pressed switch.
I use two reed switches and solder them on one board, which will be installed on the wall, and I also get some magnet on another PCB board, which will be installed on door.
After that, I put the reed switch board on the doorframe and the magnet board on the door. So every time, when I open or close the door, the magnet will get a change to hover on both reed switch in a sequence, and the reed switch board can remain still.
When installing those board, I have to make sure the reed switch will be activated when the magnet hover under it.Monitor the status of the button.
After installing the door status detector successfully, the next step is add a button which can cease the alarm. That is super easy, just connect one side of button to D2 of Photon and another side wire to Ground, Also, need a weak pullup resistor from D2 to 3V3.
After finsih the prototype of the control board, the final step is install them into the wall switch box. Make sure to hidden the cease button under the box so that no one can find it after open the door.
After that, seal the box with a transparent cover, so that I can figure out the status of the photon through the RGB led without open it.
That is the picture with all the part of door detector, I actually need to use a smaller power adapter which can put int the wall switch box to power the Photon instead of using this black one:
After that, the next step is make it send me an Email everytime it get an alarm by use the Particle cloud and IFTTT service, open www.ifttt.com and open the channel named Particle. Chosen new event published as the trigger like below:
Then the action channel choose the Gmail. Filled in with Gmail address.
Then everything is done, I can now receive the email from IFTTT once I get an alarm from Photon.
Finally, I got an door status detector which can tell me more information by simply open the door.