Hello, and welcome to my Instructable for building a cheap, simple, somewhat useful power outage monitor! If you're here, it's probably because, like me, you live in an area that experiences occasional power outages. Congratulations? At any rate, you've probably also done some searching for an IoT type product that works well enough and doesn't cost a lot of money...and no doubt you've been disappointed. Most of the monitors available are either dumb-devices (rely on physical presence and simply sound an alarm) or rely on a landline phone connection (remember those?) to call a pre-specified number. None of those are what I was looking for, which was just a simple device that could sense when it lost power, and send an alert to my phone.
What you're going to build here is not perfect; it relies on some indirect monitoring (basically, it detects that it was disconnected from an Internet connection and sends a message when it's back online). My long-term plan is to hopefully build something with a backup battery system, that works in tangent with a UPS (for the modem/router) and some intelligence to understand when it kicks over to battery. If you're interested in something like that, visit http://powersdown.launchrock.com and let me know; it might encourage me to put some effort into it.
Anyway...with back-story and caveats out of the way... on with the show...
Step 1: Purchase a Photon Board From Particle
To start with, we're going to base our device around the Photon board, from Particle. You're going to want to pick up the "Photon Kit" package, currently available for $29.00*. These boards are great, because once you get them set up, you can program them over the web via a web browser. It's really neat to watch them flicker as the code gets updated on the device!
*technically you can probably buy the $19.00 base package, I think. I don't have that one though, so you're on your own if something doesn't work.
Step 2: Open Up Your Photon Device
Particle does a great job packaging this thing up! If you bought the kit version, it will come attached to a neat breadboard thing where you can play around with attaching LEDs that you can light up over the web. Once the package arrives, open it up and pull everything out. For our project, we'll want to focus on two parts: the device itself and the USB cable (for power). This tutorial also assumes that you have a spare USB charger adapter sitting around that you can use to power the device.
Step 3: Get Your Photon Connected to the Internet
Ok, so this is going to be the trickiest part of the tutorial. If I say the phrase "CLI" and you know what that means, you'll be in good shape; if not, Particle has a really great documentation section that beginners can start from, and if you have some general knowledge of computers you'll be able to get through it (and if not, let me point you again to a page I set up to gauge interest in pre-built devices).
The specific set of instructions you'll need to get your Photon device online are available here. I won't re-hash them in this tutorial because it's a bit long, and frankly Particle did a great job writing it up anyway. One point worth mentioning is that you can set the device up either via WiFi + a mobile device (highly-recommended method) or over USB. For some reason, my device would not detect over Wifi + mobile device, so I was forced to go down the USB route, which was much more complicated. I never could nail down why that was (working theory was that the device did not like my 2.4GHz network), but suffice to say, if you can't set it up over the easy method, you'll have to try it over USB.
At any rate, follow the linked instructions to get your Photon device online and talking to the Internet, and then jump to the next step.
Step 4: Hook Your Photon Up to IFTTT
Once your Photon device is online, it should be smooth-sailing. We're going to be using IFTTT (IF This Then That) to set up an automatic alert system. If you've never used IFTTT before, it's a fantastic service for connecting the disparate, competing standards in the IoT world. Highly recommended.
The basic workflow on IFTTT is to set up a new "event" (called "recipes") by picking a "trigger" (the "This" part of the equation) and link it to an "action" (the "That" part of the equation). For our power monitor, we're going to want to pick our Photon device as the trigger. You'll need to give IFTTT permission to talk to your device, and you can do that from within the IFTTT app or on the website when you set up a new recipe for Particle (you'll need your Photon device ID, which you can get from within the Particle app on your phone).
For the action, you're going to want to choose either Email or Gmail (if you're using a Gmail account, obviously). You'll basically be telling the recipe that, if the Photon device goes offline, it should send an e-mail to the account you specified. The process is pretty straight-forward, but if you get stuck check the IFTTT about page for more information.
Step 5: Wrapping Up
So that's about it! If you made it this far, congratulations! About the only other thing I can recommend is that you might want to make a filter in your inbox to sort out e-mail notifications from IFTTT. The drawback of this simple system is that it also notifies you when your INTERNET goes down. For some of you, that might not be an issue, but in my area the Internet will go down for 15-20 seconds often multiple times a day, so I'll get bombarded with notifications. Hopefully you live in an area with more predictable Internet service, because I do get a lot of false-positives from time-to-time.
Thanks for reading the tutorial, hopefully it was helpful! I'll give one last shameless plug to my page to gauge interest on a better IoT power monitor. If there is enough interest, maybe I'll do some work, put something together, and stick it on Kickstarter.