I’m a Maker. I like to make things.

A few months ago, Greg Frank, a VictorOps developer, got me interested in Particle.io Photon Microcontrollers. Greg has completed several home automation projects using Arduino and Photon devices, as documented in this blog post on his Smart Home experiment.

Greg’s projects inspired me to consider my home alarm system, and how I could use VictorOps to alert me in a more sophisticated and cool way. Check out my 19-second video to see how it works:

My home security system is a pretty dumb, traditional, DSC Power 832 system that is built to alert a call center when something happens. Boring!

A more sophisticated home alarm system

So I decided to replace my home alarm system with a homebrew version that uses VictorOps to alert me when a door or window opens, and tell me which door or window was the culprit.

I set off to roll my own. I have some experience working in hardware, and I knew the basics of how to build the parts I would need.

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 a door or window opens, the magnet disconnects the reed switch, which breaks the circuit. Pretty simple.

In theory, if you wire that switch to a digital input on the Photon, you could determine whether the door or window is open or closed. Cool! The problem? My system has 24 instrumented windows and doors, and the Photon only has a few pins. My design will need a few more chips to read all those inputs.

Traditional systems only have four zones

Most basic commercial systems, such as the one in my house, only come with four zones. During setup, alarm installers connect the reed switches at a panel for a specific floor of the house, and then connect the panel to one of the four zones. This works in a rudimentary way. The system knows which floor contains the open window, but doesn’t know which window was opened.

My system will know which door or window was opened

As I planned my system, my first requirement was that each access point would be its own zone. I decided my system would have 48 zones, so each door or window could be individually addressed. My goal was receive VictorOps alerts that said something like “Kitchen North Window Opened.”

I started by designing my system on paper and building parts using breadboards to make sure they worked. Then I built more permanent versions where all the components were soldered in.

Making use of the Particle Photon board

The Particle Photon board is cool. Upon bootup, 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 the cloud on their site using their online IDE. Press the flash button and your code is compiled, uploaded to the Photon, and you’re off to the races. Very, very cool.

My system consists of four 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: Main Logic Board

Particle Photon Board 1

The 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 Registers

Particle Photon Board 2

The zone input shift register board (center) contains six 8 bit shift registers wired so they will cascade. Each door or window reed switch will terminate into one of these 8 bit chips. The bit state will be either a 1 or 0 based on the open or closed state of the window or door. You can cascade these to your heart’s content, so you could have infinite inputs if you like.

Board 3: The Terminal Board

Particle Photon Board 3

Finally, 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 that 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 loop

The Photon executive calls a setup() function that you define once when it boots up. Then it calls your loop() function endlessly. For this project, I have the executive delay() for a quarter second between calls so the system essentially runs at 4hz.

Logic Loop

My basic loop() function reads all 48 zone bits and updates the link list of zones with their new state.

Second Loop

A second loop then executes and when it finds a zone that has changed (a window has opened or closed) it 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”:,
“free_memory”:
}

I set up a webhook in the particle cloud to transform this information into a message that is then sent 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 event created a critical incident in VictorOps that instantly sent a push notification to my phone. The door was then closed about six seconds later. At that point, the paging policy I had set up was canceled and the incident auto resolved.

There are a lot of other bits and pieces I built into the system. My next plan is to implement moisture sensors in key locations in the house and send those along as well. I will probably use the VictorOps Transmogrifier in the Incident Automation Engine to create a different escalation policy for those alerts.

All in all, this was a pretty fun project. I posted the code and schematics to GitHub and the project to Particle if you want to build something like it yourself.