Mini-Studio: IFTTT

Background

IoT projects are often used to monitor situations and alert people of significant events. For example, an IoT home monitoring system may monitor for water entering a home following a heavy rain. The system would alert home owners of the problem so action could be taken immediately.

Such systems often rely on notification systems or text messages to alert people of the events. There are a variety of messaging services that can be used:

  • Mobile device vendors have their own systems that work independently of cellular services
  • There are many companies that provide “Communications Platforms as a Service” (CPaaS). Developers may have to pay to use the platform, but the platforms usually provide more capabilityes (SMS texts, email, etc.) and can also interact with the other notification services (like Apple’s and Google’s) with a single API. Some CPaaS platforms are:

Although many of these services provide a “developer tier” to support free testing with their platform, they often require moderate study to intergrate them into an existing project.

Objectives

The objectives of today’s Studio are:

  • Practice using a light weight IoT integration platform
  • Integrate SMS texts and Notifications into a Photon project

1. Studio Setup

As usual, you should work in a group. Your usual group of four is desirable, but not required. Today’s studio checkout will be performed by TAs. There is no GitHub repo to get/commit.

2. Studio: IFTTT & Notifications

Today you’ll be using IFTTT.com for simple SMS/Notification support. According to IFTTT’s site:

“IFTTT is a free platform that helps you do more with all your apps and devices”

The name, “IFTTT”, stands for If This Then That. The primary paradigm is an event driven if event, then action. Users create “Applets” that monitor events and respond to them (if the event happens, do a specific action).

IFTTT applets can connect to a variety of services, including Particle.

2.1 Hardware

Configure your Photon with 1 button (you can probably use existing wiring for the Garage or Lamp).

2.2 Firmware

Create a small, simple script that will publish to a Particle event stream when the button is pressed (Particle.publish()):

  • You can debounce the button in whatever way you want
  • You can pick any event name you like
  • You can use NULL for data (the event occuring is the significant part)
  • Use a private stream

Just make sure that each time you press the button one event is sent to Particle. Use Particle’s Console to verify that your Photon is publishing data whenever the button is pressed.

2.3 IFTTT Account

  1. Create an account or login to IFTTT.com. If you’re asked about enabling Notifications, do so.

2.4 Mobile Notifications

Notifications on Apple and Android devices can be sent via their respective notification services rather than SMS. The IFTTT mobile app uses these notifications (which don’t have a quota and are often more responsive)

  1. Download the IFTTT app to your mobile device. Search for IFTTT on your App store or:
  2. Login to your IFTTT account on your device. If it asks about enabling notifications, do so.

2.5 IFTTT Integration with Particle Cloud

  1. Return to your IFTTT account in your web browser (the following don’t need to be done on your mobile device, although they can be)
  2. Create a new Applet: Select the account menu in the upper right (picture of a person’s head) and select Create
  3. Click on the +this part of the rule to select the event of interest.
  4. Search for Particle and then click on the Particle icon.
  5. Pick the specific type of Particle service you are interested in (Pick New event published, but note the other options that may be of use in your project)
    • The first time you use the service you will need to authorize integration with Particle. Hit the Connect button and provide your Particle credentials.
  6. Enter the information for the event and device, then hit the Create Trigger button.
  7. Click on the +that button to select the action (to respond to the event).
  8. Search for Notification .
  9. You can customize the message being sent if you choose, but you’re also welcome to just hit Create action
  10. Review your applet and click the Finish button.
  11. Stay on this final page with the Applet details and click the Settings button followed by the the View Activity button.

2.6 Test your work

The applet will be run periodically, but it often takes up to an hour to run (especially the first time). You can force it to run sooner by clicking on Check now.

  1. Click the button on your Photon and verify that the event is published via the Particle console.
  2. Click the Check now button to test your Applet.
    • It will be checked automatically, but sometimes the initial run takes a long time.
    • IFTTT indicates that they limit users to 100 texts per month. Be mindful of your quota when using it.

2.7 Explore other features and integrations of IFTTT

  • Search the Discover category on IFTTT to see other popular ways to integrate a variety of cloud-based services.
  • Create new applets that support activities of interest to you

3. In-Class Checkout

  • Show a TA your progress and any discoveries

4. Post-Class Checkout

None for this!