Mobile
Article

Monitoring Your Particle Devices With IFTTT

By Patrick Catanzariti

I build plenty of IoT demos here at SitePoint but there’s one thing I’d never considered – keeping track of whether or not my devices are online! It’s one of those downsides of the Internet of Things… without the Internet, they can become rather powerless things!

In this article, we’ll explore how to quickly and easily set up monitoring for Particle devices like the Core and Photon using IFTTT, Slack and Google Spreadsheets. We’ll get notifications on Slack about when our devices go online/offline and we’ll record that in a Google Spreadsheet for our records.

If you’re totally new to the Particle ecosystem, you can find out more on the Particle website. You may know them as “Spark Core”, as that was their previous name before they rebranded themselves. I put together a demo with the Particle Core and NeoPixels a few weeks back too. They’re basically cloud connected microcontrollers that are a lot of fun to work with!

What is IFTTT?

IFTTT is a wonderful online service that is short for “If This Then That”. It allows you to set up rules for various services that either provide an action that can be triggered remotely or provide the trigger for our actions. For example, about two months ago I built a demo on Connecting LIFX Light Bulbs to the IoT Using IFTTT. In that demo, smart lightbulbs would change color or turn on and off depending on various rules I’d set. If I set my Jawbone UP to sleep mode, my lights would know to turn off. If my favorite sporting team were playing, my lights could change color to the team colors to get some team spirit happening!

Connecting Particle to IFTTT

This article will assume you’ve already got an account on IFTTT set up and ready to go. If not, sign up on the IFTTT website to get started. If you need more info, we covered it in more detail in the previous IFTTT article mentioned above.

To get started, head over to the Particle IFTTT Channel page (or search for it on the IFTTT “Channels” page) and click “Connect”:

The Particle IFTTT Channel

It will prompt you for your Particle username and password. Enter those in and click “Sign In”:

Providing Particle Username and Password

Then click “Okay” to give IFTTT access to your Particle data:

Confirming Particle Access

If all goes well, you should have a “Channel Connected!” success message appear for a little bit and a Particle channel page that looks like so:

Particle Successfully Connected

Connecting Slack to IFTTT

Slack is pretty similar to connecting up the Particle channel, however it asks a few more questions. Start at the Slack IFTTT Channel page and click “Connect”:

The Slack IFTTT Channel

It will ask you to sign into the Slack domain you’d like the messages to appear inside. I used a domain I’ve got for an upcoming website project, rather than driving people at the SitePoint channel insane with my Particle alerts!

Choosing Your Slack Domain

Then click “Authorize” to allow Slack to post messages into that Slack domain.

Authorizing Slack Channel

Once your Slack domain and IFTTT are able to talk to each other, you should have a Slack Channel page that looks like so:

Slack Channel Connected

Creating Our Particle and Slack Recipes

Now we’ve got Particle and Slack connected up to IFTTT, lets create our recipes with them. Click on the dropdown with your name in the top right and choose “Create” to create a new IFTTT recipe:

Creating Our New IFTTT Recipe

Click “this” to get started choosing our trigger:

Starting With This

Type in Particle to find the Particle channel and select that as our trigger:

Finding Particle Channel Trigger

There are a range of triggers you can use with the Particle Channel. You could have it run when an event you’ve defined on your Particle fires, or when a variable changes. For our example, we’ll choose “Monitor your device status” which will give us access to when the device goes online or offline:

Choosing Particle trigger

In the next screen, choose the Particle device you’d like to monitor. (Mine was called “IagoCore” for reasons I don’t fully remember. It was a Lion King reference that made sense at the time.) Then choose the status you’d like to respond to. For my first rule I’ve chosen “Offline”, which will tell me if the Particle Core goes offline. Once you’ve made those all important choices, click “Create Trigger”.

Choosing Particle Device

Then, we choose “that” to move into defining our response to the Particle trigger:

Choosing "that"

Then type in “Slack” to find the Slack channel:

Finding Slack action

At the time of writing, there’s only one action option here, so this bit should be simple. Choose “Post to channel”, as that’s exactly what we want to do!

Choosing Post To Channel

Next, you can choose which channel you’d like IFTTT to post into. I chose the “general” Slack channel.

Turns out, you can also choose Direct Messages, so if I did set it up in SitePoint’s slack channel, I wouldn’t necessarily need to drive everyone insane after all! I could choose one person in particular!

Choosing Slack Channel

You can also customize the message and title of the message to your heart’s content. Once you are happy with it, click “Create Action”.

Setting Messages

You can customize the name of the recipe you’ve made, or just hit “Create Recipe” to save it and start it running. If you’d like extra alerts whenever your device goes down, you can also tick “Recieve notifications when this Recipe runs” so that it alerts you on your phone if you’ve got IFTTT installed.

Creating Recipe

When it is all done, you’ll see it waiting in your recipe list for the Particle device to go offline:

Recipe Finished

You can repeat this process to create a second recipe that runs when it comes back online too. I created one for both. This is what they look like when my Particle Core goes offline and online:

Slack and Particle In Action

Google Spreadsheets and Particle

Another option for the action you can take, is to log the online and offline activity in a Google Spreadsheet via IFTTT. You can run both this one and the Slack one simultaneously, so you’ll get alerts and have a nice history of how often the Particle device is coming online/offline throughout the week.

Head back to the “Create Recipe” page and set up another Particle trigger for when your Particle device goes offline (just as we did earlier).

For the action, type in “Google” to find the “Google Drive” channel. Choose that one.

Choosing Google Drive Channel

We’re doing things in a bit of a different order here. Chances are you don’t have the Google Drive channel connected yet. Luckily, IFTTT prompts you to connect it up before going further:

Connecting the Google Channel

Once you’ve connected it up, you’ll get to the “Choose an Action” screen. We’ll want to choose the “Add row to spreadsheet” option.

Choosing Google Spreadsheet Trigger

Finally, we can set up the spreadsheet settings. Set up a name for the spreadsheet – make sure it is exactly the same for all recipes you want to go into the same spreadsheet otherwise you’ll have duplicates! It will create a new spreadsheet if it does not find one with that name.

Adjust the row contents if you’d like (I kept them the same), the columns are marked with |||. You can also set which folder you’d like the spreadsheet to be saved to. When you are happy with that, click “Create Action”.

Google Spreadsheet Action Fields

Feel free to create a similar recipe for when it comes online too. Then take a look at your Google Spreadsheets and you should have a new spreadsheet:

New Spreadsheet Appearing

Within that spreadsheet, once your Particle device has come online/offline a few times, you should have a good set of data waiting for you:

IFTTT Spreadsheet Result

Conclusion

As you can see, setting up logging and alerts for your Particle Cores that are out in the wild is really simple to do thanks to the power of IFTTT! Do you have any IFTTT channels you’ve found that help you manage your Particle devices? Leave a note in the comments or get in touch with me on Twitter (@thatpatrickguy)!

No Reader comments

Recommended

Learn Coding Online
Learn Web Development

Start learning web development and design for free with SitePoint Premium!

Get the latest in Mobile, once a week, for free.