Arduino - IFTTT

In this tutorial, we are going to learn how to use Arduino with IFTTT.

IFTTT makes Arduino possible:

And much much more than those

About IFTTT

IFTTT is a free web service that connects different Web services (e.g Facebook, Email, Twitter, Google Assistant ...) together. For example:

  • If you connect your Facebook to your Dropbox via IFTTT, whenever you post a photo on Facebook, IFTTT can automatically save the photo to Dropbox.
  • If you connect your Amazon Alex to your Email via IFTTT, IFTTT can automatically send email to you whenever you ask Alexa what's on your shopping list

There are four important concepts on IFTTT: Applet, service, trigger, and action.

IFTTT is composed of Applets.

The Applet is typically composed of two services. One service acts as a trigger and the other acts as action. Services in an Applet is connected together.

IFTTT service ( ex. Twitter, Dropbox, Evernote, Facebook, Email, Amazon Alexa, and Google Assistant...) does either:

  • Receive the request from outside, and then trigger other services in the same Applets (acts as the trigger)
  • Be triggered by other services in the same Applets, and then trigger other services in the same Applets (acts as the action)

※ NOTE THAT:

An Applet can be composed of three or more services. It is out of the scope of this tutorial.

The Applet is created:

  • By IFTTT company: you just need to enable it to use
  • By the third party: you just need to enable it to use
  • By yourself: You can create your own Applet, enable it to use. It is very easy to create Applets.

To works with Arduino, you need to create an Applet by yourself. Don't worry, it is very simple to create an Applet.

IFTTT stands for If This Then That. It means if a service is triggered, other services take action

Prerequisite

Create an IFTTT account . It is free and completely simple to create.

How Arduino and IFTTT Works Together

In general, Arduino interacts with IFTTT, IFTTT interacts with another service, and vice versa.

Arduino <-> IFTTT <-> other services

More detail, Arduino interacts with an Applet in IFTTT, the Applet interacts with another service, and vice versa.

Arduino <-> Applet in IFTTT <-> other services

More detail, Arduino interacts with the Webhooks service in IFTTT, the Webhooks service triggers other service in IFTTT, the other service in IFTTT interacts with outside service , and vice versa.

Arduino <-> (Webhooks <-> Other Service) in IFTTT <-> other services

We need to create an Applet of Webhooks and another service. Depending on use-case, Webhooks can acts as trigger or action.

There are two use-case categories:

  • Another service controls Arduino via IFTTT (e.g Google Assistant, Amazon Alexa controls Arduino)
  • Arduino sends data to other services via IFTTT (e.g sending notification to your phone, post on Twitter)

Let's see one by one in detail.

Another Service controls Arduino via IFTTT

How It Works

As mentioned above, an IFTTT Applets usually includes two services: one acts as trigger and the other acts as action. In this case, Webhooks acts as trigger.

In the interaction between Arduino and Webhooks, Arduino acts as Web Server, Webhooks of IFTTT acts as Web client.

The work flow:

  1. A service triggers an event to the corresponding service on IFTTT
  2. The corresponding service on IFTTT extracts the data from event if available
  3. The corresponding service on IFTTT triggers Webhooks of IFTTT (including data if available)
  4. The Webhooks of IFTTT makes HTTP request Arduino (including data if available)
  5. Arduino extracts the data from the HTTP request and take the action
  6. IFTTT controls Arduino how it works

How To Use IFTTT with Arduino

  • Login to IFTTT
  • Create an Applet, which connect a desired service (e.g Google Assistant, Amazon Alexa, Google Calendar ...) to Webhooks. Webhooks acts as action and other service acts as trigger
  • Write Arduino code to handle HTTP request from Webhooks.

When you create the Applet, Arduino's IP address is inputted in the Applet's setting. When an event is triggered, IFTTT makes an HTTP request to Arduino via the inputted IP address.

The detail step-by-step intruction will be presented in specific tutorials.

Example Code

Step-by-step instructions and example codes of another service control Arduino via IFTTT are available in the following tutorials:* Arduino - Email

Arduino Sends Data to Other Services via IFTTT

How It Works

As mentioned above, an IFTTT Applets usually includes two services: one acts as trigger and the other acts as action. In this case, Webhooks acts as action.

In the interaction between Arduino and Webhooks, Arduino acts as Web Client, Webhooks of IFTTT acts as Web server.

The work flow:

  1. Arduino makes HTTP request to Webhooks of IFTTT
  2. Webhooks extracts the data from HTTP request if available
  3. Webhooks of IFTTT triggers another service of IFTTT (including data if available).
  4. Another service of IFTTT takes action
  5. Arduino IFTTT how it works

How To

What we need to do

  • Login to IFTTT
  • Create an Applet, which connect Webhooks to a desired service (e.g Email, Twitter, VoIP ...). Webhooks acts as trigger and other service acts as action
  • Go to Webhooks's document page to get Webhooks key.
  • Write Arduino code to make HTTP (POST or GET)request to Webhooks.

To learn how to make HTTP request using Arduino .

What We need to include in the HTTP request

  • Webhooks key: unique and secret key to identify your Webhooks. One account has only one key. You can log into your account and copy it from IFTTT website
  • Event name: the name to identify the event. The event name is named by you when you create the applet. One account can create multiple event names.
  • (Optional) data: you can send the sensor's data to IFTTT

Webhooks key and event name are parts of URL. Data is optional and is included in the query string. As mentioned in the HTTP tutorial, the query string is a part of the URL in the GET request and is the HTTP body in the POST request.

The query string allows the maximum 3 variables with the fixed name: value1, value2, value3.

HTTP GET Request Format:

  • Send the trigger without data: http://maker.ifttt.com/trigger/EVENT-NAME/with/key/YOUR-KEY
  • Send the trigger with one variable: http://maker.ifttt.com/trigger/EVENT-NAME/with/key/YOUR-KEY?value1=10
  • Send the trigger with two variables: http://maker.ifttt.com/trigger/EVENT-NAME/with/key/YOUR-KEY?value1=10&value2=21
  • Send the trigger with three variables: http://maker.ifttt.com/trigger/EVENT-NAME/with/key/YOUR-KEY?value1=10&value2=21&value3=25

Replace EVENT-NAME, YOUR-KEY and values in above format.

How to send data from Arduino to IFTTT

To send data from Arduino to other services (e.g. Email, facebook), we need to do:

  • In Arduino: Include data into HTTP request
  • In Applet: modify the setting to extract data from the HTTP request.

There are 5 variables we can use in the setting of IFTTT Applet:

{{EventName}} Extracted from HTTP request
{{OccurredAt}} System time when event occurs
{{Value1}} Extracted from the variable value1 of query string in HTTP request
{{Value2}} Extracted from the variable value2 of query string in HTTP request
{{Value3}} Extracted from the variable value3 of query string in HTTP request

The detail step-by-step intruction will be presented in specific tutorials.

Example Code

Step-by-step instructions and example codes of Arduino send data to other services via IFTTT are available in the following tutorials:

Additional Knowledge

? When Arduino makes an HTTP request to Webhooks of IFTTT, how IFTTT distinguishes the request from my Arduino or Arduino of someone else?

⇒ Your HTTP request contains your Webhooks key. Each account has one and unique Webhooks key. IFTTT uses Webhooks key to identify you.

? How can My Arduino triggers multiple events?

⇒ You can create multiple applets. Each applet corresponds to a trigger.

? How Arduino can send more than 3 variables to IFTTT?

you can combine some data into one variable of the query string with your designed delimiter. For example: http://maker.ifttt.com/trigger/EVENT-NAME/with/key/YOUR-KEY?value1=10&value2=21&value3=25-32

※ OUR MESSAGES