Put the Internet to Work with IFTTT & Particle

Updated 09 September 2016

IFTTT logo

We’re in a golden age of connectivity, the internet we know today has given us the tools to connect anything to anything, and now with the platform brought to us by Particle, DIYers everywhere can connect the creations up to this vast network. Unless you’re a web developer, or know your way around any number of different programming languages and protocols, getting started with Particle’s web integration can be more than a little daunting. But it doesn’t have to be. One of the many platforms than Particle has officially partnered with is IFTTT.

What is IFTTT?

IFTTT is an online service based around a simple notion:

IFTTT banner

The idea is that you can create a recipe, which seamlessly integrates with hundreds of different online platforms looking for triggers, and then performs an action based of that trigger. No coding or server management required, just straightforward cause and effect. The trigger can be almost anything, an action from your smart appliance, a new Facebook status, a new song added to your Spotify playlist etc. and the you can decide what to do with that trigger. The possibilities are almost endless. And Particle is created a wonderfully simple integration with IFTTT which allows you to trigger events across the internet, or create hardware responses to what’s happening online.

The Goal

If it sounds a bit complicated, don’t worry, it’s not. Today we’re going to create a trigger on IFTTT which sends a weather report for the day to the Particle cloud, which we can read and print to a screen.

IFTTT recipe

In this tutorial we’ll be using a 16x2 character display, so if you’re not sure how to use one, check out our Character Displays with Particle tutorial first, as we’ll be focusing mostly on the IFTTT side. We’ll go through the circuit and code on our Particle device first, as we need to register the Particle function before we can create an IFTTT recipe to use it.

Something to bear in mind is that you can use either a Photon or an Electron for this tutorial, it’s up to you.

The Circuit

All of the data we’ll be using is handled on the software side, so the only circuitry required is the Character Display, go take a look at the Character Display tutorial, get your board setup and working, then we can move on the code. Bear in mind that the code provided below was written using the Adafruit OLED library, so you may need to change a couple of things if you're using the LiquidCrystal library.

The Code

The firmware we’re using is really quite simple, IFTTT does all the heavy lifting, and all we need to do is create a Particle.function which accepts the string data from IFTTT and does something with it (in this case, print it to our display). You can modify it however you like so feel free to play around with what it does.

#include "Adafruit_CharacterOLED_Particle/Adafruit_CharacterOLED_Particle.h"

Adafruit_CharacterOLED lcd(OLED_V2, 6, 5, 4, 3, 2, 1, 0);

int blink = 500;
int scrollRate = 150;
int waitTime = 2000;
int size;
int count;

int forcast(String forcast);

void setup() {
  lcd.begin(16, 2);
  lcd.clear();
  Particle.function("weather", forcast);
}

void loop() {
    lcd.setCursor(0,0);
    lcd.print("Nothing to see.");
    lcd.setCursor(15,0);
    lcd.print(".");
    delay(blink);
    lcd.setCursor(15,0);
    lcd.print(" ");
    delay(blink);
    //forcast("this is a test string");
    lcd.setCursor(0,0);
}

int forcast(String weather) {
    lcd.setCursor(0,0);
    lcd.print("Hey how are you?");
    delay(waitTime);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Guess what?");
    delay(waitTime);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Today is:");
    delay(waitTime);
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print(weather);
    delay(10000);
}

Go ahead and upload the firmware to your board, however don’t expect it to do much because we haven’t created the IFTTT recipe which powers it. The 99% of the code is simply handling the OLED display, The Photon simply hangs on the 'Nothing to see..' message until it receives the IFTTT trigger, then displays the current condition. Something to bear in mind is that you're limited by the amount of characters you can display on a single line of the display, so all the data from the IFTTT report may not fit all together, feel free to modify the IFTTT recipe to send whatever data you like.

Creating an IFTTT Recipe

We’ve got our Particle board setup and ready to go, now all we need is to call the function and give it some data using an IFTTT recipe. Go to IFTTT and create an account to get started.

Once you’ve got your account setup, go to ‘My Recipes’, and ‘Create a Recipe’. Now here’s what you want your recipe to look like:

  • Trigger Channel: Weather (choose your city and time)
  • Action Channel: Particle (select your device/function, and the data you wish to send)

IFTTT gif

And that’s it! You can test your function by choosing the next available time, monitoring the IFTTT recipe and Particle Console logs, and watching what happens on your devices screen.

What Now?

From here, the internet is your oyster. IFTTT provides such a wide range of channels that you can create so many different things with it. Have an explore around the IFTTT website to see what other people are doing, and check out the rest of our Particle articles.

Have a question? Ask the Author of this guide today!

Please enter minimum 20 characters

Your comment will be posted (automatically) on our Support Forum which is publicly accessible. Don't enter private information, such as your phone number.

Expect a quick reply during business hours, many of us check-in over the weekend as well.

Comments


Loading...
Feedback

Please continue if you would like to leave feedback for any of these topics:

  • Website features/issues
  • Content errors/improvements
  • Missing products/categories
  • Product assignments to categories
  • Search results relevance

For all other inquiries (orders status, stock levels, etc), please contact our support team for quick assistance.

Note: click continue and a draft email will be opened to edit. If you don't have an email client on your device, then send a message via the chat icon on the bottom left of our website.

Makers love reviews as much as you do, please follow this link to review the products you have purchased.