I’m a Maker. I like to make things. A few months ago, one of our dev’s at VictorOps got me interested in Particle.io Photon Microcontrollers.
I wanted to replace my home alarm system with a homebrew version that could utilize VictorOps to alert me when a door or window opens (and tell me which one).
My traditional home security system is a pretty dumb DSC Power 832 system that is built to call out to a call center when something happens. Boring! I want to get a VictorOps Alert when windows open and close!
So, I setoff to roll my own. I have a little hardware background and knew basically how to build the parts needed. My house has wiring to each door and window, and each access point has a reed switch that is engaged by a magnet mounted to the door or window. When the door or window is open the magnet disconnects the reed switch breaking the circuit. Pretty simple. Basically, in theory, if you wire that switch to a digital input on the Photon, you could determine if the door or window was open or closed. Cool! Problem is I have 24 instrumented windows and doors in my system, so my design will need a few more chips to read all those inputs using only and few pins on the Photon.
So as I planned my system, my first requirement was that each access point would be its own zone in my system. Most simple commercial systems such as the one in my house basically only have four zones. The installers simply connect all the reed switches in series at the panel for a floor of the house and connect that to one of the four zones. It works but the system doesn’t know what window is open, rather what floor it happened on. That was boring, so I decided my system would have 48 zones so each door or window could be individually addressed. My goal was get VictorOps alerts that said something like “Kitchen North Window Opened”.
The Particle Photon board is cool. Upon boot up it attaches to your wifi and runs its executive code and any code you have written for it. You can do all your development in cloud on their site with their online IDE. Press the flash button, your code is compiled, uploaded to the Photon, and you’re off to the races. Very, very cool.
So I first designed my system on paper and built parts using breadboards to make sure they worked. Then I built more permanent versions where all the components were soldered in.
Basically, the system consists of 4 simple boards (only three are required, one is an LED board for display not discussed here). All these boards could easily be on one board but the proto boards I used to make the parts reduce the density of what you can achieve.
Board #1 – The Main Logic BoardThe first board (top board outlined in red) is the Main Logic Board that contains the Photon processor (left) and some supporting chips (middle) that change the logic
levels from the Photons 3V range to TTL 5V range. In addition, the four chips on the right are solid state relays that can be used to pass signals through to my legacy alarm system (these are also optional).
Board #2 – Zone Input Shift RegistersThe zone input shift register board (center) contains 6 8-bit shift registers wired so they will cascade. Each door or window reed switch will terminate into one bits of one of these 8 bit chips.
Basically, the bit state will be a 1 or 0 based on the open or closed state of the window or door. I think you can basically cascade these to your hearts content so you could have infinite inputs if you like.
Board #3: The Terminal boardFinally, the third (lowest) board is simply a terminal strip board with the screw down terminals for the set of wires coming from each door or window. These inputs are jumpered over to the middle board to connect to one of the input pins on a shift register (the white wires).
The resistors are pull-up resistors to make sure you get a valid logic level (+5V) when a door or window opens the circuit. Zero volts signifies the window or door is closed in the system. I’m only using about 24 of the zones so far, so I have room for expansion.
The Basic Logic LoopThe Photon executive basically calls a setup() function you define once when it boots up. Then it repeatedly calls your loop() function endlessly. For this project I have the executive delay() for a quarter second between calls so the system basically runs at 4hz.
My basic loop() function reads all 48 zone bits and updates the link list of zones with their new state.
A second loop then executes and when it find's a zone that has changed (a window has opened or closed) it then builds a particle message to send off to the particle cloud. The message is called access_changed. The json message looks something like this..
{
"channel_number":"SYSTEM",
"message_type":"CRITICAL",
"entity_id":"RF_E_W",
"entity_display_name":"Family Room East Window is OPEN",
"state_start_time":<seconds from epoch>,
"free_memory":<amount of free memory in photon>
}
I setup a webhook in the particle cloud to transform this information into a message that is then sent on to the VictorOps endpoint in the same format.
Paging me because the Garage Door is Open!In this case the Door to the Garage opened at 11:36:27 MDT. This created a critical incident in VictorOps that sent me a push notification to my phone instantly. The door was then closed about 6 seconds later. At that point the paging policy I have setup was canceled and the incident auto resolved.
There are lot of other bits and pieces I built into the system. My next plan is implement moisture sensors in key locations in the house and send those along as well. I will probably use the VictorOps Transmogrifier rules to create a different escalation for those (you know, water and all).
All-in-all, a pretty fun project. I posted the code and schematics to GitHub if anyone wants to build it themselves!
https://github.com/toddvernon/PhotonAlarmSystem
Enjoy!
Comments