HOME - - - - - - - - Table of contents, my Arduino "How To" articles
Other material for programmers      Delicious.Com Bookmark this on Delicious    StumbleUpon.Com Recommend to StumbleUpon

Using If This Then That to generate web requests

Example based on Arduino/ ESP8266 source of triggers
Written for people new to IfTTT.com

I've "known about" IfTTT.com for years. Just never got around to playing with "If This, Then That" before.

The good news: It is really, REALLY simple to get it to send out a URL to make a web attached "thing" do something!

The bad news: It is only really, really simple if you have already become familiar with how to use IfTTT.com to, say, send someone an email when a web-attached device sends IfTTT a "trigger".

But that's all written up for you at my tutorial about getting started with the brilliant, free, If This Then That service!

Once you have the skills and fundamental "bits" (like your own (free) IfTTT.com account), here's the next step.

This tutorial assumes you already have something like the ESP8266 discussed in the first tutorial, and that it is set up and online, and able to send the code that by the end of the first tutorial was causing IfTTT to send an email upon your demand, via pressing the SPST switch connected to your ESP8266.

Now.. forgive me for delaying mentioning this... I did say at the outset that what we were going to do was to send a web request to "a web attached 'thing'". So, you have to have a web attached thing, to play with these ideas quickly and easily. It might be an IP cam. It might be an Arduserver. (I have a tutorial about setting up an ESP8266 as an Arduserver. Yes... you would need two of them, I think... one to be the device "pulling" the trigger, one to be the device with the LED responding. Go on... you know you wanted a second ESP8266, anyway. They CAN both be at the same DDNS managed URL!

How to Make It Happen...

For the sake of the discussion below, we will assume that your trigger, used previously to cause IfTTT to send the email you set it up to send, is rather curiously called "door_trigger". (An unlikely name, I admit. But it arose through the history of my learning about these things. Sorry!)

That trigger can be left still triggering the emails, if you wish.

But we are going to create a new If This Then That recipe, one that will cause IfTTT to make a web request on our behalf when the trigger is "pulled". For the sake of a simple example, that web request will be the one we use to turn the Arduserver's LED on. (We could either make a second trigger for turning the LED off again, or we could just do that by hand.

In fact "by hand" is a good place to start.

If you paste the following into a web browser, you should get a page full of "stuff"...

http://mon7nc.dyndns.org:1202/led/0

If you do, it has come from something that cost $15, would fit in a coffee mug (comfortably), and is on the desk beside me as I write this. (If you don't, it is "down"... not impossible, with a hobbyist's Arduserver, which may have been sacrificed for a new project by now! Or maybe it's having a bad hair day... although I've found them very dependable in some limited testing.

Among the text, unless I've fixed a silly, trivial error, you will find "LED is now on". Which is odd as the result of a "zero" command. If you issue...

http://mon7nc.dyndns.org:1202/led/1

... which is the same as before, except for the last character, the webpage will say "LED is now off". Backwards. I know. Sorry. ("1" actually DOES turn the LED on, and "0" turns it off... it is just the message on the webpage which is backwards). Whatever! The main thing is: You can turn the LED on and off. (You have to type the command as shown, by the way. If you put "LED" in the command instead of "led", it will ignore your request.

OR... if you have the knowledge, you could send a web request to an IP Cam, telling it to take a photo, and send it to an FTP server. Anything you can get done by sending a URL from a browser you can get done by IfTTT in response to whatever trigger you want to specify!!!

HOW?...

Go into your IfTTT account. (Remember... I told you this essay assumes you've completed what's in my first IfTTT tutorial.)

From there go to the "Maker" part of IfTTT... https://ifttt.com/maker.

Click My Applets. Start a new (Maker) applet (you have to click on the little down-pointing chevron, upper right)

-

Click on the blue "+This" on the (IfTTT!) screen, to access the part where you specify a trigger.

Type as much of "maker" as you need to narrow the options down to...

-

.. and click on "Maker".

Click on the square with "Receive a web request", which is actually a button, even if it looks like a mere bit of "help" text.

Now! Pay attention, or you will get confused! At this point, you should see...

-

.. which I think is misleading. We're not so much creating a new trigger/ event as assigning one we made earlier to a new recipe. If you someday try to "create" a trigger, but don't go into the usual pages for setting it up, consider whether maybe you've accidentally entered the name of an existing trigger. (You can change the specs of what a trigger does... just not here!)

So... fill in "door_status", or whatever the trigger you made for the first tutorial is called. And click "Create Trigger". (You could, and probably will, in the future, make a new thing at this step. But we don't need to for the sake of this first exploration of the ideas we're working on here. So we'll use a bit of our previous work. A tested, debugged, etc bit.

That brings you back... almost... to the "If +This Then That" page... but this time, it is the "That" which is in blue, with a "+" in front of it. Click on it.

You come to a page headed "Choose Action Service". You are being given the chance to say what the "That" will be for this "If this then THAT" recipe!

Do what you did before to get down to "Maker" (Not WeMo Maker, not MeetThyMaker... just "Maker".)

That gives rise to something like the "Receive a web request" page, only this time the rather dull button's text starts "Make a web request".

Click on that, to go into the page where you supply the details of the request you want to go out.

For URL, if you want to affect the LED of my Arduserver, you fill in...

http://mon7nc.dyndns.org:1202/led/1

(I hope you have your own... they're easy enough to set up, and Arduservers exist primarily as an exercise to teach the BASICS of stuff that is very relevant to what you are wanting to be able to do, if you've read this far.)

Method: I'm not quite sure what this "ought" to be... but "post" works!

Content type: I'm not quite sure what this "ought" to be... but "application/json" works!

Body: Leave this field empty.

Click "Create Action". Click finish.

That's it! Baring typos, etc, IfTTT now has a new recipe which will be triggered by the same event that triggered the sending of emails by the end of the first tutorial. Now the trigger will still send an email, unless you've turned that recipe off, but it will also issue the LED changing command.

"Check now", by the way, doesn't cause the recipe to run. I think it is more about testing whether the recipe is put together properly.

But... but... but...

"But!...", I hear you ask. "Why involve IfTTT??? Why not just send the URL directly to the device you want controlled? You need something that can send to the internet in order to send the message that "pulls" the trigger at IfTTT. Why don't you just send direct to the Arduserver what you've set IfTTT up to send?

The answer is: You could!.

What we've done here could be done with that simpler, fewer- things- to- got- wrong route.

This exercise was just to get you started. To show you some of the steps. While you could do what we've done without IfTTT, that will not always be the case. And now you have the tools to use IfTTT to send web requests when you want to!


   Search this site or the web        powered by FreeFind
 
  Site search Web search
Site Map    What's New    Search

The search engine is not intelligent. It merely seeks the words you specify. It will not do anything sensible with "What does the 'could not compile' error mean?" It will just return references to pages with "what", "does", "could", "not".... etc.
In addition to the tutorials for which this page serves as Table of Contents, I have other sites with material you might find useful.....

Sequenced set of tutorials on Arduino programming and electronics interfacing.
Tutorials about the free database supplied with Open Office version 2.
      (If you experienced Adabas with Star Office, ooBase is nothing like it!)
Some pages for programmers.
Using the parallel port of a Windows computer.


If you visit 1&1's site from here, it helps me. They host my website, and I wouldn't put this link up for them if I wasn't happy with their service.




Ad from page's editor: Yes.. I do enjoy compiling these things for you... hope they are helpful. However.. this doesn't pay my bills!!! If you find this stuff useful, (and you run an MS-DOS or Windows PC) please visit my freeware and shareware page, download something, and circulate it for me? Links on your page to this page would also be appreciated!

Click here to visit editor's Sheepdog Software (tm) freeware, shareware pages.. Material on this page © TK Boyd March, 2016


And if you liked that, or want different things, here are some more pages from the editor of these tutorials....

Click here to visit the homepage of my biggest site.

Click here to visit the homepage of Sheepdogsoftware.co.uk. Apologies if the "?FrmAht" I added to that link causes your browser problems. Please let me know, if so?

Click here to visit editor's pages about using computers in Sensing and Control, e.g. weather logging.



To email this page's editor, Tom Boyd.... Editor's email address. Suggestions welcomed!


Valid HTML 4.01 Transitional Page tested for compliance with INDUSTRY (not MS-only) standards, using the free, publicly accessible validator at validator.w3.org


Why does this page cause a script to run? Because of the Google panels, and the code for the search button. Why do I mention the script? Be sure you know all you need to about spyware.

....... P a g e . . . E n d s .....